'Program DDELEMAP.BAS (c) 2006 by J. C. Sprott 'Calculates Lyapunov exponent for the Mackey-Glass equation (Euler method) 'Use PowerBasic Console Compiler #DEBUG ERROR OFF DEFEXT a-z FUNCTION PBMAIN() CLS n&=1e2 h=23##/n& 'Iteration step size for tau=23 DIM x(n&),xe(n&),xnew(n&),xenew(n&),dx(n&) dr=1e-10 'Separation of orbits FOR i&=0 TO n&: x(i&)=0.9: xe(i&)=x(i&): NEXT i& xe(0)=x(0)+dr 'Nearby initial condition dr2=dr*dr tp&=1e7/n& 'Number of iterations between prints DO CALL MAP (x(), n&, h, xnew()) CALL MAP (xe(), n&, h, xenew()) INCR its&& dx2=0 FOR i&=0 TO n& x(i&)=xnew(i&) xe(i&)=xenew(i&) dx=x(i&)-xe(i&) dx2=dx2+dx*dx dx(i&)=dx NEXT i& rs=SQR(dx2/dr2) FOR i&=0 TO n&: xe(i&)=x(i&)+dx(i&)/rs: NEXT i& IF its&&>tp& THEN ltot=ltot+LOG(rs) IF (its&& MOD tp&)=0 THEN le=ltot/(h*(its&&-tp&)) PRINT FORMAT\$(le," #.#######") END IF IF INKEY\$=CHR\$(27) THEN EXIT LOOP END IF LOOP END FUNCTION SUB MAP (x(), n&, h, xnew()) xnew(0)=x(0)+h*(0.2##*x(n&)/(1##+x(n&)^10)-0.1##*x(0)) FOR i&=1 TO n&: xnew(i&)=x(i&-1): NEXT i& END SUB