5 ONERRORGOTO1000
10 DEFCHR$(255)="0000FE0000":MODE8:DIM:PRINTCHR$(15);
30 f$="":c$=CHR$(5):s=0:t=0:e=1e-7:m=30:ANGLE1
50 CLS:PRINT"Method of bisection f(x)=0 1:f(x),x0,x1 2:š,loop";
60 k=ASC(INPUT$(1,@)):IFk=13 ORk=49 THEN90 ELSEIFk=50 THEN170
80 GOTO60
90 CLS:PRINT"Define function";
100 LOCATE0,1:PRINTc$;"f(x) ?";f$;:LOCATE0,0:LOCATE6,1:INPUT@100;f$:LOCATE0,0:z=VALF(f$)
110 IFLEN(f$)<25 THENg$=f$ ELSEg$=LEFT$(f$,21)+"ć»ć»ć»"
120 m$="f(x) = "+g$:s$="x0":z=s:GOSUB800:s=z
130 s$="x1":z=t:GOSUB800:t=z:GOTO250
170 m$="Err āXn+1-Xnā<š (š>0)":s$="š":z=e:GOSUB800:e=z:IFe<1e-90 THEN170
200 m$="Max loop (n>0)":s$="n":z=m:GOSUB800:m=z:IFm=<0 ORFRACm<>0 THEN200 ELSE50
250 CLS:PRINTm$;TAB(0);"x = .....";:u=s:v=t
270 x=u:g=VALF(f$):IFg=0 THEN500
280 x=v:h=VALF(f$):IFh=0 THEN500
310 FORi=1 TOm:x=(u+v)/2:f=VALF(f$):IFf=0 THEN500
330 IFSGNg=SGNh ANDSGNh=SGNf THENGOSUB450:GOTO50
340 IFSGN(f*g)=1 THENu=x:g=f ELSEv=x:h=f
350 IFABS(u-v)=<e THEN500
370 NEXT:GOSUB450
390 PRINTc$;"loop =";m;TAB(11);":Xn =";STR$(x);:LOCATE0,0:LOCATE1,1:z$=INPUT$(1,@):GOTO50
450 LOCATE0,1:PRINTc$;"not found";:z$=INPUT$(1,@):RETURN
500 x=ROUND(x,INTLOG(ABSe)-1):PRINTc$;"x =";x;:z$=INPUT$(1,@):GOTO50
800 CLS:PRINTm$;
810 LOCATE0,1:PRINTc$;s$"=";z;"?";:INPUT@10;z:LOCATE0,0:RETURN
1000 IFERR=1 THENCLS:ONERRORGOTO0
1010 IFERL=100 THENIFERR=2 THENRESUME100 ELSERESUMENEXT
1015 IFERL=810 THENRESUME810
1020 GOSUB450:RESUME50