'Program SSCANZ.BAS makes bifurcation diagram for paramsz.dat '\$error all on defext a-z screen 12 call invertcolors n&=100 tmax&=1e4 dr=1e-12 dr2=dr*dr lemax=.03## smin=0.8## smax=1.8## dim x(n&),xe(n&),dx(n&),dxdt(n&) seed&=val(command\$) if seed&=0 then seed&=timer s=smin tmaxo&=tmax& t&=0 cls randomize seed& for j&=1 to n&: x(j&)=rnd: xe(j&)=x(j&): next j&: xe(1)=xe(1)+dr locate 2,7: print "PARAMSZ.DAT" locate 3,7: print"N =";n&; locate 1,2: print lemax locate 8,2: print"LLE" locate 15,3: print 0 locate 29,2: print -lemax smin\$=trim\$(str\$(smin)) smax\$=trim\$(str\$(smax)) locate 30,5: print smin\$; locate 30,43: print"S"; locate 30,81-len(smax\$): print smax\$; line(39,0)-(639,460),,b line(39,230)-(639,230),,,&h4444 while q\$<>chr\$(27) if q\$=chr\$(0,72) then s=s*1.01##: t&=0 if q\$=chr\$(0,80) then s=s/1.01##: t&=0 if ucase\$(q\$)="C" then cls: t&=0 q\$="" if t&=tmax& then t&=0 s=s+(smax-smin)/600## if abs(x(1)-x(2))smax then exit loop incr t& for i&=1 to 20 RK4 x(), dxdt(), n&, .05, x() RK4 xe(), dxdt(), n&, .05, xe() next i& rs2=0 FOR j&=1 to n& dx(j&)=x(j&)-xe(j&) rs2=rs2+dx(j&)*dx(j&) NEXT j& if rs2>0 then rs=SQR(rs2/dr2) 'Calculate Lyapunov exponent FOR j&=1 to n&: xe(j&)=x(j&)+dx(j&)/rs: NEXT j& if t&=1 then ltot=0 IF t&>tmax&/10 THEN ltot=ltot+LOG(rs) le=ltot/(t&-tmax&/10) END IF if t&=tmax& then xp=39+600*(s-smin)/(smax-smin) if abs(le)>lemax then le=lemax*sgn(le) yp=230-230*le/lemax if s=smin then pset(xp,yp) else line-(xp,yp) end if q\$=inkey\$ wend while inkey\$<>chr\$(27): wend end SUB invertcolors () 'Sets the RGB palette to iverted gray scale in 16-color VGA screen modes FOR pal& = 0 TO 15 PALETTE pal&, pal& c& = 63-INT(4.2 * pal&) OUT &h3C8, pal& OUT &h3C9, c& OUT &h3C9, c& OUT &h3C9, c& NEXT pal& END SUB SUB DERIVS (x(), dxdt(), n&) 'Returns the time derivatives dxdt(i&) of x(i&) shared s FOR i&=1 TO n& i1&=1+(i&-3+n&) mod n& 'i2&=1+(i&-2+n&) mod n& i3&=1+i& mod n& 'i4&=1+(i&+1) mod n& dxdt(i&)=x(i&)*(1##-s*x(i1&)-x(i&)-s*x(i3&)) NEXT i& END SUB SUB RK4 (X(), DXDT(), N&, H, XNEW()) 'Fourth-order Runge-Kutta integrator DIM XT(N&), DXT(N&), DXM(N&) HH = H * .5## H6 = H / 6## CALL DERIVS(X(), DXDT(), N&) FOR I& = 1 TO N& XT(I&) = X(I&) + HH * DXDT(I&) NEXT I& CALL DERIVS(XT(), DXT(), N&) FOR I& = 1 TO N& XT(I&) = X(I&) + HH * DXT(I&) NEXT I& CALL DERIVS(XT(), DXM(), N&) FOR I& = 1 TO N& XT(I&) = X(I&) + H * DXM(I&) DXM(I&) = DXT(I&) + DXM(I&) NEXT I& CALL DERIVS(XT(), DXT(), N&) FOR I& = 1 TO N& XNEW(I&) = X(I&) + H6 * (DXDT(I&) + DXT(I&) + 2## * DXM(I&)) NEXT I& ERASE DXM, DXT, XT END SUB