diff --git a/src/bracketing/bisection.jl b/src/bracketing/bisection.jl index d55a0ce..adcf72a 100644 --- a/src/bracketing/bisection.jl +++ b/src/bracketing/bisection.jl @@ -39,6 +39,12 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Bisection, prob, alg, right, fr; retcode = ReturnCode.ExactSolutionRight, left, right) end + if sign(fl) == sign(fr) + @warn "The interval is not an enclosing interval, opposite signs at the boundaries are required." + return build_solution( + prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right) + end + i = 1 if !iszero(fr) while i < maxiters diff --git a/src/bracketing/brent.jl b/src/bracketing/brent.jl index 649286e..4ba311f 100644 --- a/src/bracketing/brent.jl +++ b/src/bracketing/brent.jl @@ -26,6 +26,12 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Brent, args...; prob, alg, right, fr; retcode = ReturnCode.ExactSolutionRight, left, right) end + if sign(fl) == sign(fr) + @warn "The interval is not an enclosing interval, opposite signs at the boundaries are required." + return build_solution( + prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right) + end + if abs(fl) < abs(fr) c = right right = left diff --git a/src/bracketing/falsi.jl b/src/bracketing/falsi.jl index ee78b73..00b2970 100644 --- a/src/bracketing/falsi.jl +++ b/src/bracketing/falsi.jl @@ -25,6 +25,12 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Falsi, args...; prob, alg, right, fr; retcode = ReturnCode.ExactSolutionRight, left, right) end + if sign(fl) == sign(fr) + @warn "The interval is not an enclosing interval, opposite signs at the boundaries are required." + return build_solution( + prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right) + end + # Regula Falsi Steps i = 0 if !iszero(fr) diff --git a/src/bracketing/itp.jl b/src/bracketing/itp.jl index 4c92645..9405cc2 100644 --- a/src/bracketing/itp.jl +++ b/src/bracketing/itp.jl @@ -75,6 +75,13 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::ITP, args...; return build_solution( prob, alg, right, fr; retcode = ReturnCode.ExactSolutionRight, left, right) end + + if sign(fl) == sign(fr) + @warn "The interval is not an enclosing interval, opposite signs at the boundaries are required." + return build_solution( + prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right) + end + ϵ = abstol #defining variables/cache k2 = alg.k2 diff --git a/src/bracketing/ridder.jl b/src/bracketing/ridder.jl index a974824..772f568 100644 --- a/src/bracketing/ridder.jl +++ b/src/bracketing/ridder.jl @@ -25,6 +25,12 @@ function SciMLBase.solve(prob::IntervalNonlinearProblem, alg::Ridder, args...; prob, alg, right, fr; retcode = ReturnCode.ExactSolutionRight, left, right) end + if sign(fl) == sign(fr) + @warn "The interval is not an enclosing interval, opposite signs at the boundaries are required." + return build_solution( + prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right) + end + xo = oftype(left, Inf) i = 1 if !iszero(fr)