5 ONERRORGOTO1000
10 MODE8:DIM:c$=CHR$(5):ANGLE0:a=1:b=0:c=0:d=0
20 CLS:PRINT"ax³+bx²+cx+d=0";
30 s$="a":z=a:GOSUB700:a=z:IFa=0 THEN30
40 s$="b":z=b:GOSUB700:b=z
50 s$="c":z=c:GOSUB700:c=z
60 s$="d":z=d:GOSUB700:d=z
70 LOCATE0,1:PRINTc$;".....";
100 u=b/a/3:p=c/a/3-u*u:q=2*u*u*u-u*c/a+d/a
102 IFABSp<u*u*1e-10 THENp=0
104 IFABSq<u*u*u*1e-10 THENq=0
110 t=q*q+4*p*p*p:IFABSt<q*q*5e-10 THENt=0
115 r=(q+SQR(ABSt))/2:s=(q-SQR(ABSt))/2:r=SGNr*CUR(ABSr):s=SGNs*CUR(ABSs)
120 v=r+s
130 ONSGNt+2 GOTO400,,300
140 x=-v-u:IFp THEN200
175 GOSUB520:PRINT"a(x-𝛼)³=0";:PRINT
180 PRINTc$;"𝛼 =";x;
190 GOSUB550:IFw=13 THEN20 ELSE190
200 y=v/2-u
205 GOSUB510:PRINT"a(x-𝛼)(x-𝛽)²=0";:PRINT
210 PRINTc$;"𝛼 =";x;
230 GOSUB550:IFw<>13 ANDw<>31 THEN230
240 PRINTc$;"𝛽 =";y;
260 GOSUB550:IFw=30 THEN210 ELSEIFw=13 THEN20 ELSE260
300 x=-v-u:y=v/2-u:z=ABS(SQR3/2*(r-s))
302 GOSUB500:PRINT"a(x-𝛼)(x-𝛽)(x-𝛾)=0";:PRINT
305 y$=STR$(y)+" ":z$=MID$(STR$(z),2):IFy=0 THENy$=""
310 PRINTc$;"𝛼 =";x;
330 GOSUB550:IFw<>13 ANDw<>31 THEN330
340 PRINTc$;"𝛽 =";y$;:IFy THENPRINT"+";
350 IFz-1 THENPRINT" ";z$;"i"; ELSEPRINT" i";
360 GOSUB550:IFw=30 THEN310 ELSEIFw<>13 ANDw<>31 THEN360
370 PRINTc$;"𝛾 =";y$;"-";:IFy THENPRINT" ";
380 IFz-1 THENPRINTz$;"i"; ELSEPRINT"i";
390 GOSUB550:IFw=30 THEN340 ELSEIFw=13 THEN20 ELSE390
400 h=ACS(q/2/SQR(ABS(-p*p*p)))/3:i=-2*SQR(ABS(-p)):x=i*COSh-u:y=i*COS(h+120)-u:z=i*COS(h+240)-u
405 GOSUB500:PRINT"a(x-𝛼)(x-𝛽)(x-𝛾)=0";:PRINT
410 PRINTc$;"𝛼 =";x;
430 GOSUB550:IFw<>13 ANDw<>31 THEN430
440 PRINTc$;"𝛽 =";y;
460 GOSUB550:IFw=30 THEN410 ELSEIFw<>13 ANDw<>31 THEN460
470 PRINTc$;"𝛾 =";z;
490 GOSUB550:IFw=30 THEN440 ELSEIFw=13 THEN20 ELSE490
500 IFz<>0 ANDABSz>=1e-90 THENz=ROUND(z,LOG(ABSz)-7)
502 IFz<>0 ANDABSz<1e-90 THENz=z*1e10:z=ROUND(z,LOG(ABSz)-7):z=z/1e10
505 IFABSz<ABSu*1e-10 THENz=0
510 IFy<>0 ANDABSy>=1e-90 THENy=ROUND(y,LOG(ABSy)-7)
512 IFy<>0 ANDABSy<1e-90 THENy=y*1e10:y=ROUND(y,LOG(ABSy)-7):y=y/1e10
515 IFABSy<ABSu*1e-10 THENy=0
520 IFx<>0 ANDABSx>=1e-90 THENx=ROUND(x,LOG(ABSx)-7)
522 IFx<>0 ANDABSx<1e-90 THENx=x*1e10:x=ROUND(x,LOG(ABSx)-7):x=x/1e10
525 IFABSx<ABSu*1e-10 THENx=0
530 CLS:RETURN
550 LOCATE0,0:LOCATE0,1:w=ASC(INPUT$(1,@)):RETURN
700 LOCATE0,1:PRINTc$;s$;"=";z;"?";:INPUT@42;z:LOCATE0,0:RETURN
1000 IFERR=1 THENCLS:ONERRORGOTO0
1010 IFERL=700 THENRESUME700
1050 LOCATE0,1:PRINTc$;"not found";:z$=INPUT$(1,@):RESUME20