NewtonMin1D Function

public function NewtonMin1D(tol, a, b, maxstep, x, fobj) result(fmin)

Newton's iterative algorithm to find the minimimum of function f(x) in the interval [a,b], using df(x)=0 and the derivative

Arguments

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

abort tolerance

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

search interval

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

search interval

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

max|dx| allowed

real(kind=wp), intent(inout) :: x

initial guess on input, result on output

class(c_newton_Min1D), intent(in) :: fobj

functional to minimize with f(x), d/dx f(x), d^2/dx^2 f(x)

Return Value real(kind=wp)

on output =f(x)


Calls

proc~~newtonmin1d~~CallsGraph proc~newtonmin1d NewtonMin1D FR FR proc~newtonmin1d->FR interface~newtonroot1d NewtonRoot1D proc~newtonmin1d->interface~newtonroot1d interface~newtonroot1d->interface~newtonroot1d

Source Code

FUNCTION NewtonMin1D(tol,a,b,maxstep,x,fobj) RESULT (fmin)
  ! MODULES
  IMPLICIT NONE
  ! INPUT VARIABLES -------------------------!
  REAL(wp),INTENT(IN)               :: tol  !! abort tolerance
  REAL(wp),INTENT(IN)               :: a,b  !! search interval
  REAL(wp),INTENT(IN)               :: maxstep  !! max|dx| allowed
  CLASS(c_newton_Min1D),INTENT(IN)  :: fobj !! functional to minimize with f(x), d/dx f(x), d^2/dx^2 f(x)
  ! OUTPUT VARIABLES -------------------------!
  REAL(wp),INTENT(INOUT) :: x    !! initial guess on input, result on output
  REAL(wp)               :: fmin !! on output =f(x)
  ! LOCAL VARIABLES --------------------------!
  REAL(wp)                                      :: x0
  TYPE(t_newton_Root1D_wrap_Min1D), ALLOCATABLE :: fobj_wrap
  ! CODE --------------------------------------------------------------------------------------------------------------------------!
  fobj_wrap = t_newton_Root1D_wrap_Min1D(fobj)
  x0=x
  x=NewtonRoot1D(tol,a,b,maxstep,x0,0.0_wp,fobj_wrap)
  fmin=fobj%FR(x)
  DEALLOCATE(fobj_wrap)
END FUNCTION NewtonMin1D