|
!'Halley's Irrational Formula
INPUT T
LET X=T
DO
LET J=DF1(X)^2-2*F(X)*DF2(X)
IF J=<0 THEN LET J=0 ELSE LET J=SQR(J)
LET X1=X+(-DF1(X)+J)/DF2(X)
LET X2=X+(-DF1(X)-J)/DF2(X)
IF ABS(F(X1))<ABS(F(X2)) THEN LET X=X1 ELSE LET X=X2
PRINT X
LOOP UNTIL ABS(F(X))<1E-13
PRINT X;X^3
FUNCTION F(X)
LET F=X*X*X-T
END FUNCTION
FUNCTION DF1(X)
LET DF1=3*X^2
END FUNCTION
FUNCTION DF2(X)
LET DF2=6*X
END FUNCTION
END
|
|