diff --git a/src/scalar.jl b/src/scalar.jl index 10f907c7b..dda7329bd 100644 --- a/src/scalar.jl +++ b/src/scalar.jl @@ -128,7 +128,7 @@ function solve(prob::NonlinearProblem, ::Falsi, args...; maxiters = 1000, kwargs end mid = (fr * left - fl * right) / (fr - fl) for i in 1:10 - mid = max(left, prevfloat_tdir(mid, prob.u0...)) + mid = max_tdir(left, prevfloat_tdir(mid, prob.u0...), prob.u0...) end if mid == right || mid == left break diff --git a/src/utils.jl b/src/utils.jl index 061ee3838..aeb94b2a5 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -221,6 +221,10 @@ function nextfloat_tdir(x::T, x0::T, x1::T)::T where {T} x1 > x0 ? nextfloat(x) : prevfloat(x) end +function max_tdir(a::T, b::T, x0::T1, x1::T1)::T where {T, T1} + x1 > x0 ? max(a, b) : min(a, b) +end + alg_autodiff(alg::AbstractNewtonAlgorithm{CS,AD}) where {CS,AD} = AD alg_autodiff(alg) = false