Skip to content

Commit ccae744

Browse files
committed
Fix bug with complex roots
1 parent fb9d5a4 commit ccae744

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/BracketingNonlinearSolve/src/muller.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function CommonSolve.solve(prob::IntervalNonlinearProblem, alg::Muller, args...;
2020

2121
xᵢ₊₁, fxᵢ₊₁ = xᵢ₋₂, fxᵢ₋₂
2222

23-
abstol = NonlinearSolveBase.get_tolerance(
24-
xᵢ₋₂, abstol, promote_type(eltype(xᵢ₋₂), eltype(xᵢ)))
23+
abstol = abs(NonlinearSolveBase.get_tolerance(
24+
xᵢ₋₂, abstol, promote_type(eltype(xᵢ₋₂), eltype(xᵢ))))
2525

2626
for _ 1:maxiters
2727
q = (xᵢ - xᵢ₋₁)/(xᵢ₋₁ - xᵢ₋₂)

lib/BracketingNonlinearSolve/test/muller_tests.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,20 @@
5353

5454
@test sol.u π
5555
end
56+
57+
@testset "Complex roots" begin
58+
f(u, p) = u^3 - 1
59+
60+
tspan = (-1.0, 1.0*im)
61+
prob = IntervalNonlinearProblem{false}(f, tspan)
62+
sol = solve(prob, Muller())
63+
64+
@test sol.u (-1 + 3*im)/2
65+
66+
tspan = (-1.0, -1.0*im)
67+
prob = IntervalNonlinearProblem{false}(f, tspan)
68+
sol = solve(prob, Muller())
69+
70+
@test sol.u (-1 - 3*im)/2
71+
end
5672
end

0 commit comments

Comments
 (0)