|
!' ???(不明です)
PUBLIC NUMERIC N,T
INPUT PROMPT "n乗根=":N
INPUT PROMPT "X=": T
LET XX = T
LET EPS=1E-8
!' XA=X-F(X)/F'(X) G(X)=F(X)/F'(X)
!' XB=X-G(X)/G'(X)
!' X=(XA+XB)/2
DO
LET X=XX
LET X1 = X - F(X)/DF(X)
LET X2 = X - G(X)/DG(X)
LET XX = (X1 + X2)/2
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
|
|