newton_module Module

Basic Newton solver.


Uses

  • module~~newton_module~~UsesGraph module~newton_module newton_module module~kind_module kind_module module~newton_module->module~kind_module module~numbers_module numbers_module module~newton_module->module~numbers_module iso_fortran_env iso_fortran_env module~kind_module->iso_fortran_env module~numbers_module->module~kind_module

Used by

  • module~~newton_module~~UsedByGraph module~newton_module newton_module proc~kepler_classical kepler_module::kepler_classical proc~kepler_classical->module~newton_module

Abstract Interfaces

abstract interface

  • private subroutine func(x, f)

    interface for the function and derivative

    Arguments

    Type IntentOptional Attributes Name
    real(kind=wp), intent(in) :: x
    real(kind=wp), intent(out) :: f

Subroutines

public subroutine newton(x, f, dfdx, ftol, xtol, max_iter, xs, fx, iflag)

Newton's method for root finding of scalar function f(x)

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

initial point (initial guess)

procedure(func) :: f

function f(x)

procedure(func) :: dfdx

first derivative function f'(x)

real(kind=wp), intent(in) :: ftol

convergence tolerance for f(x)

real(kind=wp), intent(in) :: xtol

convergence tolerance for x

integer, intent(in) :: max_iter

the maximum number of iterations

real(kind=wp), intent(out) :: xs

the value where f(x) is zero

real(kind=wp), intent(out) :: fx

the value of f(x) at the root xs

integer, intent(out) :: iflag

status flag: 0 : absolute convergence in f 1 : relative convergence in x -1 : Error: derivative is zero -2 : Error: max iterations exceeded