Mark Wickens

5 ONERRORGOTO500
10 MODE8:DIM:c$=CHR$(5)
20 CLS:PRINT"Yn(x)         (0≤n≤9,0<x≤30)";
30 LOCATE0,1:PRINTc$;"n?   :x?      :Y=";
40 LOCATE2,1:INPUT@3;n$:LOCATE0,0:n=VALF(LEFT$(n$,3)):u=ABSn:IFn<0 ORu>=10 ORFRACu<>0 THEN400
60 LOCATE8,1:INPUT@6;x$:LOCATE0,0:x=VALF(LEFT$(x$,6)):v=ABSx:IFx=<0 ORv>30 THEN410
80 LOCATE17,1:PRINT" .....";:GOSUB220
100 IFn<0 THENr=r*(-1)^u
110 IFr<>0 ANDABSr>=1e-90 THENr=ROUND(r,LOG(ABSr)-7)
115 IFr<>0 ANDABSr<1e-90 THENr=r*1e10:r=ROUND(r,LOG(ABSr)-7):r=r/1e10
120 LOCATE18,1:PRINT"     ";:LOCATE17,1:PRINTr;:z$=INPUT$(1,@):GOTO30
220 k=INT(1+3*v^(1/12)+9*v^(1/3)+(ABS(u-v)+ABS(u+v))/2)
230 s=0:b=1.5:c=0:j=0
240 a=2*k/x*b-c:k=k-1
250 IFk=1 THENd=a
260 IFk=0 THEN290
270 IF(k MOD 2)=0 THENs=s+a:j=j+2*a*(-1)^(k/2-1)/k
280 c=b:b=a:GOTO240
290 s=2*s+a:j=j/s
300 j=(a*(.577215664901+LN(v/2))/s+2*j)*2/PI
310 IFn=0 THENr=j:RETURN
320 y=(d/s*j-2/PI/v)/a*s
330 IFu=1 THENr=y:RETURN
340 FORi=2 TOu:e=2*(i-1)*y/x-j:j=y:y=e:NEXT
350 r=e:RETURN
400 LOCATE2,1:PRINT"   ";:GOTO40
410 LOCATE8,1:PRINT"      ";:GOTO60
500 IFERR=1 THENCLS:ONERRORGOTO0
510 IFERL=40 THENRESUME400
520 IFERL=60 THENRESUME410
530 LOCATE17,1:PRINT"not found";:z$=INPUT$(1,@):RESUME20