Roots of a function: Difference between revisions

Content added Content deleted
No edit summary
Line 236:
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
<lang fortran> PROGRAM ROOTS_OF_A_FUNCTION
IMPLICIT NONE
Line 261:
END DO
END PROGRAM ROOTS_OF_A_FUNCTION </lang>
The following approach uses the Secant Method[http://en.wikipedia.org/wiki/Secant_method] to numerically find one root. Which root is found will depend on the start values x1 and x2 and if these are far from a root this method may not converge.
<lang fortran> INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(15)
INTEGER :: i=1, limit=100
REAL(dp) :: d, e, f, x, x1, x2
Line 284:
x2 = x2 - d
i = i + 1
END DO </lang>
 
=={{header|J}}==