|
!' ラゲール法(LAGUERRE法)
PUBLIC NUMERIC T,N
INPUT PROMPT "n乗根=":N
INPUT PROMPT "X=":T
LET EPS=1E-8
LET X=T
DO
LET XX=X-N*F(X)/(DF(X)+SGN(DF(X))*SQR(H(X)))
PRINT XX
LET X=XX
LOOP UNTIL ABS(F(X))<EPS
PRINT X;X^N
END
EXTERNAL FUNCTION H(X)
LET H=(N-1)^2*DF(X)^2-N*(N-1)*F(X)*DF2(X)
END FUNCTION
EXTERNAL FUNCTION F(X)
LET F=X^N-T
END FUNCTION
EXTERNAL FUNCTION DF(X)
LET DF=N*X^(N-1)
END FUNCTION
EXTERNAL FUNCTION DF2(X)
LET DF2=N*(N-1)*X^(N-2)
END FUNCTION
|
|