|
!' 割線法 (SECANT法)
PUBLIC NUMERIC T
INPUT PROMPT "X=": T
LET EPS=1E-8
LET X0 = T + 1
LET X1 = T
DO WHILE ABS(X0 - X1) > EPS
LET X = X0 - F(X0) / G(X0, X1)
PRINT X
LET X0 = X1
LET X1 = X
LOOP
PRINT X;X*X
END
EXTERNAL FUNCTION F(X)
LET F=X*X-T
END FUNCTION
EXTERNAL FUNCTION G(X0,X1) !' f'(x)の代用
LET G=(F(X0) - F(X1)) / (X0 - X1)
END FUNCTION
|
|