Skip to content

Commit

Permalink
make bisection test more expressive
Browse files Browse the repository at this point in the history
  • Loading branch information
gwater committed Jun 25, 2020
1 parent 0f18ac9 commit 6b090cf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/roots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ newtonlike_methods = [Newton, Krawczyk]
end


in_solution_set(point, solution_intervals) =
any(map(interval -> point in interval, solution_intervals))

@testset "2D roots" begin
f(x, y) = SVector(x^2 + y^2 - 1, y - 2x)
f(X) = f(X...)
X = (-6..6) × (-6..6)

# Bisection
rts = roots(f, X, Bisection, 1e-3)
@test length(rts) == 4
exact_sol = [sqrt(1/5), 2sqrt(1/5)]
@test in_solution_set(exact_sol, interval.(rts))
@test in_solution_set(-exact_sol, interval.(rts))

for method in newtonlike_methods
deriv = xx -> ForwardDiff.jacobian(f, xx)
Expand Down

0 comments on commit 6b090cf

Please sign in to comment.