Skip to content

Commit 297db29

Browse files
committed
Incorporate Muller into test suite
Add `left` and `right` fields to solution
1 parent ccae744 commit 297db29

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

lib/BracketingNonlinearSolve/src/BracketingNonlinearSolve.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ end
4545

4646
@reexport using SciMLBase, NonlinearSolveBase
4747

48-
export Alefeld, Bisection, Brent, Falsi, Muller, ITP, Ridder
48+
export Alefeld, Bisection, Brent, Falsi, ITP, Muller, Ridder
4949

5050
end

lib/BracketingNonlinearSolve/src/muller.jl

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ function CommonSolve.solve(prob::IntervalNonlinearProblem, alg::Muller, args...;
4343
# Termination Check
4444
if abstol abs(fxᵢ₊₁)
4545
return SciMLBase.build_solution(prob, alg, xᵢ₊₁, fxᵢ₊₁;
46-
retcode = ReturnCode.Success)
46+
retcode = ReturnCode.Success,
47+
left = xᵢ₊₁, right = xᵢ₊₁)
4748
end
4849

4950
xᵢ₋₂, xᵢ₋₁, xᵢ = xᵢ₋₁, xᵢ, xᵢ₊₁
5051
fxᵢ₋₂, fxᵢ₋₁, fxᵢ = fxᵢ₋₁, fxᵢ, fxᵢ₊₁
5152
end
5253

5354
return SciMLBase.build_solution(prob, alg, xᵢ₊₁, fxᵢ₊₁;
54-
retcode = ReturnCode.MaxIters)
55+
retcode = ReturnCode.MaxIters,
56+
left = xᵢ₊₁, right = xᵢ₊₁)
5557
end

lib/BracketingNonlinearSolve/test/rootfind_tests.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ end
77
@testitem "Interval Nonlinear Problems" setup=[RootfindingTestSnippet] tags=[:core] begin
88
using ForwardDiff
99

10-
@testset for alg in (Bisection(), Falsi(), Ridder(), Brent(), ITP(), Alefeld(), nothing)
10+
@testset for alg in (Alefeld(), Bisection(), Brent(), Falsi(), ITP(), Muller(), Ridder(), nothing)
1111
tspan = (1.0, 20.0)
1212

1313
function g(p)
@@ -52,7 +52,7 @@ end
5252
prob = IntervalNonlinearProblem(quadratic_f, (1.0, 20.0), 2.0)
5353
ϵ = eps(Float64) # least possible tol for all methods
5454

55-
@testset for alg in (Bisection(), Falsi(), ITP(), nothing)
55+
@testset for alg in (Bisection(), Falsi(), ITP(), Muller(), nothing)
5656
@testset for abstol in [0.1, 0.01, 0.001, 0.0001, 1e-5, 1e-6]
5757
sol = solve(prob, alg; abstol)
5858
result_tol = abs(sol.u - sqrt(2))
@@ -62,7 +62,7 @@ end
6262
end
6363
end
6464

65-
@testset for alg in (Ridder(), Brent())
65+
@testset for alg in (Brent(), Ridder())
6666
# Ridder and Brent converge rapidly so as we lower tolerance below 0.01, it
6767
# converges with max precision to the solution
6868
@testset for abstol in [0.1]
@@ -76,7 +76,7 @@ end
7676
end
7777

7878
@testitem "Flipped Signs and Reversed Tspan" setup=[RootfindingTestSnippet] tags=[:core] begin
79-
@testset for alg in (Alefeld(), Bisection(), Falsi(), Brent(), ITP(), Ridder(), nothing)
79+
@testset for alg in (Alefeld(), Bisection(), Brent(), Falsi(), ITP(), Muller(), Ridder(), nothing)
8080
f1(u, p) = u * u - p
8181
f2(u, p) = p - u * u
8282

0 commit comments

Comments
 (0)