Secent 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 secant step with x-axis
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