|
!' マラー法(MULLER法)
PUBLIC NUMERIC T
INPUT PROMPT "X=":T
LET EPS=1E-8
LET X2=T
LET X0=1
LET X1=(X0+X2)/2
DO
LET A=((X1-X2)*F(X0)+(X2-X0)*F(X1)+(X0-X1)*F(X2))/((X0-X1)*(X1-X2)^2)
LET B=((X1-X2)*(2*X0-X1-X2)*F(X0)-(X0-X2)^2*F(X1)+(X0-X1)^2*F(X2))/((X0-X1)*(X1-X2)^2)
LET C=(X0-X2)*F(X0)/(X1-X2)
LET D=B*B-4*A*C
IF D>0 THEN
LET XA=(-B+SQR(D))/(2*A)
LET XB=(-B-SQR(D))/(2*A)
IF ABS(F(X0-XA))<ABS(F(X0)) THEN
LET XX=X0-XA
ELSEIF ABS(F(X0+XA))<ABS(F(X0)) THEN
LET XX=X0+XA
ELSEIF ABS(F(X0-XB))<ABS(F(X0)) THEN
LET XX=X0-XB
ELSEIF ABS(F(X0+XB))<ABS(F(X0)) THEN
LET XX=X0+XB
END IF
ELSE
LET XA=-B/(2*A)
IF ABS(F(X0-XA))<ABS(F(X0)) THEN
LET XX=X0-XA
ELSEIF ABS(F(X0+XA))<ABS(F(X0)) THEN
LET XX=X0+XA
END IF
END IF
PRINT XX
LET X2=X1
LET X1=X0
LET X0=XX
LOOP UNTIL ABS(F(XX))<EPS
PRINT XX;XX^4
END
EXTERNAL FUNCTION F(X)
LET F=X*X*X*X-T
END FUNCTION
|
|