Fortran77
PROGRAM regulaFalsi
REAL e, funcion, x1, x2, funxm, funx1, funx2, dm
INTEGER n, i
PARAMETER (d2 = 9999.0)
e = 0.01
i = 2
n = 25
x1 = 0.0
x2 = 2.0
IF((funcion(x1) * funcion(x2)) .LT. 0.0) THEN
WRITE(*,*) 'Garantiza Convergencia'
DO WHILE (i .LT. n)
funx1 = funcion(x1)
funx2 = funcion(x2)
funxm = (x2 - (funx2 * ((x1 - x2))/(funx1 - funx2)))
IF(calculo_d(funxm, x2) .LT. e) THEN
WRITE(*,*) 'muere'
GOTO 666
ENDIF
i = i + 1
dm = funcion(funxm)
IF((dm * funx2) .LT. 0) THEN
x1 = x2
funx1 = funx2
ENDIF
x2 = funxm
funx2 = dm
END DO
IF(funxm .LE. e) THEN
i = i + 1
ENDIF
ELSE
WRITE(*,*) 'No garantiza Convergencia'
ENDIF
666 STOP
END PROGRAM regulaFalsi
REAL FUNCTION funcion(xn)
REAL xn
funcion = xn**2 - 1
RETURN
END
REAL FUNCTION calculo_d(a, b)
REAL a, b, c
c = a - b
calculo_d = ABS(c)
RETURN
END
Suscribirse a:
Entradas (Atom)