Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/BracketingNonlinearSolve/src/itp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ function SciMLBase.__solve(
span = right - left
k1 = alg.scaled_k1 * span^(1 - k2) # k1 > 0
n0 = alg.n0
n_h = exponent(span / (2 * ϵ))
ϵ_s = ϵ * exp2(n_h + n0)
if span / 2 > ϵ * floatmax(typeof(span))
# Workaround for when span / (2 * ϵ) == Inf
ϵ_s = span / 2 * exp2(n0)
else
n_h = exponent(span / (2 * ϵ))
ϵ_s = ϵ * exp2(n_h) * exp2(n0)
Comment on lines +103 to +104
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't this still exp2(n_h+n0)? I would expect that to be faster.

end
T0 = zero(fl)

i = 1
Expand Down
10 changes: 10 additions & 0 deletions lib/BracketingNonlinearSolve/test/rootfind_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ end
@test result_tol > ϵ
end
end

# Some solvers support abstol=0.0 and converge to floating point precision
@testset for alg in (Bisection(), ITP(), Brent())
sol = solve(prob, alg; abstol = 0.0)
# Test that solution is to floating point precision
@test sol.retcode == ReturnCode.FloatingPointLimit
@test quadratic_f(sol.left, 2.0) < 0
@test quadratic_f(sol.right, 2.0) > 0
@test nextfloat(sol.left) == sol.right
end
end

@testitem "Flipped Signs and Reversed Tspan" setup=[RootfindingTestSnippet] tags=[:core] begin
Expand Down
Loading