secant Function

private pure function secant(x1, x2, f1, f2, ax, bx) result(x3)

Secent step. With a protection to fall back to bisection if:

  • the computed point is outside the original interval ([ax,bx]).
  • f2 == f1

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x1
real(kind=wp), intent(in) :: x2
real(kind=wp), intent(in) :: f1
real(kind=wp), intent(in) :: f2
real(kind=wp), intent(in) :: ax

original interval lower bound

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

original interval upper bound

Return Value real(kind=wp)

intersection of secant step with x-axis


Calls

proc~~secant~~CallsGraph proc~secant root_module::secant proc~bisect root_module::bisect proc~secant->proc~bisect

Called by

proc~~secant~~CalledByGraph proc~secant root_module::secant proc~anderson_bjorck root_module::anderson_bjorck_solver%anderson_bjorck proc~anderson_bjorck->proc~secant proc~anderson_bjorck_king root_module::anderson_bjorck_king_solver%anderson_bjorck_king proc~anderson_bjorck_king->proc~secant proc~pegasus root_module::pegasus_solver%pegasus proc~pegasus->proc~secant proc~zhang root_module::zhang_solver%zhang proc~zhang->proc~secant

Source Code

    pure function secant(x1,x2,f1,f2,ax,bx) result(x3)

    implicit none

    real(wp),intent(in) :: x1,x2,f1,f2
    real(wp),intent(in) :: ax !! original interval lower bound
    real(wp),intent(in) :: bx !! original interval upper bound
    real(wp) :: x3 !! intersection of secant step with x-axis

    if (f2==f1) then
        x3 = bisect(x1,x2)
    else
        ! secant step:
        x3 = x2 - f2 / ( (f2 - f1) / (x2 - x1) )
        if (x3<ax .or. x3>bx) x3 = bisect(x1,x2)
    end if

    end function secant