|
!' スラー法
PUBLIC NUMERIC N,T
INPUT PROMPT "n乗根=":N
INPUT PROMPT "X=": T
LET EPS=1E-8
LET XX = T
DO
LET X=XX
LET XX = X - G(X) / DG(X) !' f(x)=x^n-t g(x)=f(x)/f'(x) x=x-g(x)/g'(x)
PRINT XX
LOOP UNTIL ABS(X-XX)<EPS
PRINT XX;XX^N
END
EXTERNAL FUNCTION F(X)
LET F=X^N-T
END FUNCTION
EXTERNAL FUNCTION DF(X)!' f'(x)
LET DF=N*X^(N-1)
END FUNCTION
EXTERNAL FUNCTION DF2(X)!' f''(x)
LET DF2=N*(N-1)*X^(N-2)
END FUNCTION
EXTERNAL FUNCTION G(X)
LET G=F(X)/DF(X)
END FUNCTION
EXTERNAL FUNCTION DG(X)!' (f(x)/f'(x))'
LET DG=(DF(X)^2-DF2(X)*F(X))/DF(X)^2
END FUNCTION
|
|