Repository: JuliaMath/Roots.jl
Pull request #322 (2022-09-17 12:51:05)

close issue #321

codecov[bot]: # [Codecov](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath) Report
Base: **84.61**% // Head: **84.82**% // Increases project coverage by **`+0.20%`** :tada:
> Coverage data is based on head [(`5e473b3`)](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath) compared to base [(`0036bcc`)](https://codecov.io/gh/JuliaMath/Roots.jl/commit/0036bccdddec93b32d38b1b56145313f2ec52525?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath).
> Patch coverage: 100.00% of modified lines in pull request are covered.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master     #322      +/-   ##
==========================================
+ Coverage   84.61%   84.82%   +0.20%     
==========================================
  Files          32       33       +1     
  Lines        2061     2089      +28     
==========================================
+ Hits         1744     1772      +28     
  Misses        317      317              
```


| [Impacted Files](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath) | Coverage Δ | |
|---|---|---|
| [src/abstract\_types.jl](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL2Fic3RyYWN0X3R5cGVzLmps) | `100.00% <100.00%> (ø)` | |
| [src/trace.jl](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL3RyYWNlLmps) | `23.00% <0.00%> (-0.47%)` | :arrow_down: |
| [src/Bracketing/bisection.jl](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL0JyYWNrZXRpbmcvYmlzZWN0aW9uLmps) | `100.00% <0.00%> (ø)` | |
| [src/hybrid.jl](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL2h5YnJpZC5qbA==) | `97.84% <0.00%> (+0.02%)` | :arrow_up: |
| [src/find\_zero.jl](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL2ZpbmRfemVyby5qbA==) | `96.96% <0.00%> (+0.04%)` | :arrow_up: |
| [src/Bracketing/alefeld\_potra\_shi.jl](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL0JyYWNrZXRpbmcvYWxlZmVsZF9wb3RyYV9zaGkuamw=) | `85.71% <0.00%> (+0.08%)` | :arrow_up: |
| [src/alternative\_interfaces.jl](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL2FsdGVybmF0aXZlX2ludGVyZmFjZXMuamw=) | `94.73% <0.00%> (+0.14%)` | :arrow_up: |
| [src/find\_zeros.jl](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL2ZpbmRfemVyb3Muamw=) | `96.09% <0.00%> (+0.19%)` | :arrow_up: |
| [src/simple.jl](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL3NpbXBsZS5qbA==) | `93.10% <0.00%> (+0.24%)` | :arrow_up: |
| [src/Derivative/lith.jl](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath#diff-c3JjL0Rlcml2YXRpdmUvbGl0aC5qbA==) | `71.04% <0.00%> (+0.61%)` | :arrow_up: |
| ... and [1 more](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath) | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/JuliaMath/Roots.jl/pull/322?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaMath).


Patch:
diff --git a/Project.toml b/Project.toml
index e656a4d..cdf6c57 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,6 +1,6 @@
 name = "Roots"
 uuid = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
-version = "2.0.2"
+version = "2.0.3"
 
 [deps]
 CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
diff --git a/src/abstract_types.jl b/src/abstract_types.jl
index 895eb3e..13c3e2d 100644
--- a/src/abstract_types.jl
+++ b/src/abstract_types.jl
@@ -1,5 +1,6 @@
 ### Method types
 abstract type AbstractUnivariateZeroMethod end
+Base.broadcastable(method::AbstractUnivariateZeroMethod) = Ref(method)
 
 abstract type AbstractBracketingMethod <: AbstractUnivariateZeroMethod end
 abstract type AbstractBisectionMethod <: AbstractBracketingMethod end
diff --git a/src/find_zero.jl b/src/find_zero.jl
index 5f4177a..689ca5e 100644
--- a/src/find_zero.jl
+++ b/src/find_zero.jl
@@ -185,7 +185,7 @@ julia> fn = x -> (sin(x)*cos(x) - x^3 + 1)^9;
 
 julia> x0, xstar = 1.0,  1.112243913023029;
 
-julia> find_zero(fn, x0, Order2()) ≈ xstar
+julia> isapprox(find_zero(fn, x0, Order2()), xstar; atol=1e-4)
 true
 
 julia> find_zero(fn, x0, Order2(), maxiters=3)    # need more steps to converge


Test patch:
diff --git a/test/test_find_zero.jl b/test/test_find_zero.jl
index 6a77b31..1cecf68 100644
--- a/test/test_find_zero.jl
+++ b/test/test_find_zero.jl
@@ -195,6 +195,14 @@ end
     @test @inferred(solve(fx, p=[-1 / 10, 1 / 10])) ≈
           @inferred(find_zero(x -> cos(x) - x / 10 - 1 / 10, (0, pi / 2)))
 
+
+    ### issue 321, solve and broadcasting
+    myfun(x, p) = x * sin(x) - p
+    prob = ZeroProblem(myfun, (0.0, 2.0))
+    ps = (1/4, 1/2, 3/4, 1)
+    as = (0.5111022402679033, 0.7408409550954906, 0.9333080372907439, 1.1141571408719302)
+    @test all(solve.(prob, Bisection(), ps) .≈ as)
+
     ## test with early evaluation of bracket
     f = x -> sin(x)
     xs = (3.0, 4.0)