Regula Falsi step. With a protection to fall back to bisection if:
Type | Intent | Optional | 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 |
intersection of line connecting x1,x2 with x-axis
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