Skip to content

Commit

Permalink
clean up mess; close issue #373 (#374)
Browse files Browse the repository at this point in the history
* clean up mess; close issue #373

* doctest
  • Loading branch information
jverzani authored May 2, 2023
1 parent f28f3fc commit 5ade3d0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Roots"
uuid = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
version = "2.0.13"
version = "2.0.14"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
6 changes: 3 additions & 3 deletions src/Bracketing/alefeld_potra_shi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function calculateΔ(::A2425{K}, F::Callable_Function, c₀::T, ps) where {K,T}
a, b, d, fa, fb, fd = bracket(a, b, c, fa, fb, fc)

iszero(fc) && break
if (isnan(fc) || isfinite(c))
if (isnan(fc) || !isfinite(c))
c = c₀
break
end
Expand Down Expand Up @@ -244,7 +244,7 @@ function calculateΔ(::A57{K}, F::Callable_Function, c₀::T, ps) where {K,T}
a, b, d, fa, fb, fd = bracket(a, b, c, fa, fb, fc)

iszero(fc) && break # fa or fb is 0
if (!isfinite(fc) || isfinite(c))
if (!isfinite(fc) || !isfinite(c))
c = c₀
break
end
Expand Down Expand Up @@ -328,7 +328,7 @@ function newton_quadratic(a, b, d, fa, fb, fd, k::Int)
A = f_abd(a, b, d, fa, fb, fd)
B = f_ab(a, b, fa, fb)

(iszero(A) || isfinite(A)) && return a - fa / B
(iszero(A) || !isfinite(A)) && return a - fa / B

r = sign(A) * sign(fa) > 0 ? a : b

Expand Down
5 changes: 2 additions & 3 deletions src/trace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ julia> find_zero(sin, (3, 4), Roots.A42(), tracks=tracker) ≈ π
true
julia> get(tracker)
5-element Vector{NamedTuple{names, Tuple{Float64, Float64}} where names}:
4-element Vector{NamedTuple{names, Tuple{Float64, Float64}} where names}:
(a = 3.0, b = 4.0)
(a = 3.0, b = 3.157162792479947)
(a = 3.14154625558915, b = 3.1416390553287794)
(a = 3.1415926535730327, b = 3.141592653606554)
(a = 3.141592614491745, b = 3.1415926926910007)
(a = 3.141592653589793, b = 3.141592653589794)
julia> last(tracker)
Expand Down
7 changes: 7 additions & 0 deletions test/test_bracketing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,11 @@ end

# last bit of accuracy, when close issue #368
@test find_zero(x -> sinpi(-1/40 + x / 40) + 1 - x, (0,2), A42()) == 1.0

# sloppy bug using isfinite (#373)
f = x -> 1 - x / (x - 1)^2
xleft = 1 + eps(BigFloat)
xright = 3 * xleft
x =find_zero(f, (xleft, xright))
@test abs(f(x)) <= 2eps(BigFloat)
end

2 comments on commit 5ade3d0

@jverzani
Copy link
Member Author

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/82720

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 v2.0.14 -m "<description of version>" 5ade3d0aeda118e6858580decf35184c30134fed
git push origin v2.0.14

Please sign in to comment.