|
!' 改良ニュートン法
PUBLIC NUMERIC T
INPUT PROMPT "X=":T
LET EPS=1E-8
LET XX=T
DO
LET X=XX
LET L=DF(X)*(F(X)-F(X-F(X)/DF(X)))
IF L=0 THEN
LET XX=X
EXIT DO
END IF
LET XX=X-F(X)^2/L
PRINT XX
LOOP UNTIL ABS(X-XX)<EPS
PRINT XX;XX^3
END
EXTERNAL FUNCTION F(X)
LET F=X*X*X-T
END FUNCTION
EXTERNAL FUNCTION DF(X)!' f'(x)
LET DF=3*X^2
END FUNCTION
|
|