/* Given: 1) some "small" characteristic exponent h>0, and 2) (optionally) the number of significative decimals Q>=0, we compute the Lazutkin homoclinic invariant lhi of the primary homoclinic orbit on the symmetry line {y=0} of the Henon map (x,y) -> ( x+y+epsilon*x(1-x), y+epsilon*x*(1-x) ) up to Q significative decimals. (By default, Q=50.) Here, epsilon = 4*sinh^2(h/2) = lambda-2+1/lambda and lambda=exp(h). The symmetric homoclinic orbit is found by a Newton's method which doubles the precision after each iteration. Variables: * lambda=exp(h) is the characteristic multiplier * S=2*Pi^2/(h*log(10)) is the number of decimal digits lost by cancellation * P_single is the "single" precision of the multiple precision arithmetic * P is the "final" precision of the multiple precision arithmetic * p is the "variable" precision of the multiple precision arithmetic * K is the order of the Taylor expansions * N is the number of iterations to reach the symmetry line from the fundamental domain * [r1/lambda, r1), r1>0, is the fundamental interval * m(r)=(X(r),Y(r)) is the natural parameterization of the unstable curve * { (x,y) : G(x,y)=y=0 } is the symmetry line * Z(r)=G(f^N(m(r))=0 is the one-dimensional equation for the homoclinic point * r0 is the solution of the above equation in the fundamental interval * [x,y] are the coordinates of the point on which acts the Henon map * [dx,dy] is the tangent vector on which acts the differetial of the Henon map, or the tangent vector to the unstable curve at the homoclinic * [dxs,dys]=[dx-dy,-dy] is the tangent vector to the stable curve * lhi is the Lazutkin homoclinic invariant User-defined functions (in order of appearance): * Taylor() computes the Taylor expansion of m(r)=(X(r),Y(r)) up to order K * f() iterates the Henon map * df() iterates the differential of the Henon map * fN() iterates N times the Henon map * dfN() iterates N times the differential of the Henon map * XY(r) evaluates m(r)=(X(r),Y(r)) by Horner's rule * dXY(r) evaluates m(r)=(X(r),Y(r)) and its derivative by Horner's rule * Z(r) evaluates the function Z(r)=G(f^N(m(r)) * Z_Newton(r) evaluates the "Newton step" Z(r)/Z'(r) Some GP-instructions: * vector(N,n,expr(n)) creates the vector [expr(1),...,expr(N)] * if(cond,"seq1","seq2") executes "seq1" if cond != 0, else "seq2" * for(k=a,b,"seq") executes "seq" for k=a,a+1,...,b-1,b * while(cond,"seq") executes "seq" while cond != 0 * sum(k=a,b,"expr") sums "expr" from k=a to k=b * default(realprecision,p) sets the precision equal to p * default(format,"val") sets the exit format equal to "val" * solve(r=a,b,"expr") finds the root of "expr" between a and b * x\/y = ceil(x/y) * x%y = remainder of the Euclidean division x/y To run this program: 1) Open a GP session, 2) Read this file: \r Henon.gp, 3) Call the main function: LHI_Henon(h,Q), for some real h and integer Q. */ \\ Main function LHI_Henon(h,Q=50)= { local(K,N,p,P,P_single,S); local(epsilon,lambda); local(X,Y); local(x,y,dx,dy,dxs,dys); local(lhi,r0,r1); local(time_Taylor,time_homoclinic,time_LHI); P_single=28; S=ceil( 2*Pi*Pi/(h*log(10)) ); P=max(ceil(1.1*(Q+S)),P_single); h=precision(h,P); default(realprecision,P); lambda=exp(h); epsilon=lambda-2+1/lambda; default(format,"e0.10"); print("The characteristic exponent is ",h,"."); print1("The multiple-precision works with P=1.1(Q+S)=1.1("); print(Q,"+",S,")=",P," decimals."); K=max(20, ceil((14*P*log(10)/h)^(1/3)) ); print1("Computing the Taylor expansions up to order K=",K,"... "); gettime(); X=vector(K,k,0.); Y=vector(K,k,0.); Taylor(); time_Taylor=gettime(); print("Done in ",time_Taylor," ms."); print1("Computing the homoclinic orbit "); default(realprecision,P_single); r1=5*10^(-P/(K+1)); XY(r1/lambda); N=-1; while(y>0,N++;f()); print1("using N=",N," iterations... "); r0=solve(r=r1/lambda,r1,Z(r)); p=P; while(p>=P_single-3,p=p\/2); while( p