|
!' ウェグスティン法(WEGSTEIN法)
PUBLIC NUMERIC T
INPUT PROMPT "X=": T
LET EPS=1E-8
LET X0 = T
LET X1 = F(X0)
DO WHILE ABS(F(X2) - X2) > EPS
LET X2 = X1 + (X1 - X0) / ((X0 - F(X0)) / (X1 - F(X1)) - 1)
PRINT X2
LET X0 = X1
LET X1 = X2
LOOP
PRINT X2;X2*X2
END
EXTERNAL FUNCTION F(X) !' X=F(X) F(X)-X=0
LET F=X * X + X - T
END FUNCTION
|
|