program main
T=1.
C 这儿给个初值
K=0
10 K=K+1
F=T*T+4*T+4
C 公式
CALL WEGSTEIN(T,F,E,K)
IF(E.GT.1E-5) GOTO 10
WRITE(*,*)X
STOP
END program main
SUBROUTINE WEGSTEIN(X,FX,ERROR,K)
COMMON/ITER/X0,F0
IF(K.LE.1) THEN
DX=FX-X
ELSE
DX=(X-X0) * (FX-X)/(X-X0-FX+F0)
ENDIF
ERROR=ABS(DX)/(ABS(X)+1.)
X0=X
F0=FX
X=X+DX
RETURN
END
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |