Skip to content

Commit

Permalink
Make bisection test more expressive (#156)
Browse files Browse the repository at this point in the history
* make bisection test more expressive

* Simplify in_solution_set
  • Loading branch information
gwater authored Jun 26, 2020
1 parent 9272e39 commit b5a76bb
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(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

2 comments on commit b5a76bb

@dpsanders
Copy link
Member

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/17009

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.4 -m "<description of version>" b5a76bbbccac62f0345db5cbc00e247bbc7e3d2c
git push origin v0.5.4

Please sign in to comment.