regula_falsi_step Function

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

Regula Falsi 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 line connecting x1,x2 with x-axis


Calls

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

Called by

proc~~regula_falsi_step~~CalledByGraph proc~regula_falsi_step root_module::regula_falsi_step proc~illinois root_module::illinois_solver%illinois proc~illinois->proc~regula_falsi_step proc~regula_falsi root_module::regula_falsi_solver%regula_falsi proc~regula_falsi->proc~regula_falsi_step

Source Code

    function regula_falsi_step(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 line connecting x1,x2 with x-axis

    real(wp) :: delta

    delta = f2-f1

    if (delta /= 0.0_wp) then
        ! intersection with x-axis of line connecting the two points:
        x3 = x1 - (f1/delta) * (x2-x1)
        if (x3>ax .and. x3<bx) return ! must be a new point in the range
    end if

    ! fall back to bisection for any problem
    x3 = bisect(x1,x2)

    end function regula_falsi_step