Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tan tangent function missing roots #196

Closed
PeterARBork opened this issue Feb 16, 2024 · 1 comment · Fixed by #203
Closed

tan tangent function missing roots #196

PeterARBork opened this issue Feb 16, 2024 · 1 comment · Fixed by #203
Assignees
Labels

Comments

@PeterARBork
Copy link

I expected roots to find all the roots of the tangent function in the simple case below, but it doesn't. The roots should be $n \pi$ with $n$ an integer.

roots(tan, 0..10)

1-element Vector{Root{Interval{Float64}}}:
 Root([6.28318, 6.28319], :unique)

find_zeros finds too many

find_zeros(tan, [0, 10])

7-element Vector{Float64}:
 0.0
 1.5707963267948966
 3.141592653589793
 4.71238898038469
 6.283185307179586
 7.853981633974483
 9.42477796076938

Am I missing something?

@Kolaru
Copy link
Collaborator

Kolaru commented Feb 19, 2024

Yep that's a bug. It is probably due to an assumption that fails because tan is not continuous (and diverges).

The branch IA_v0.22 (work in progress to update to the latest IntervalArithmetic which is more careful with those cases), has the correct behavior:

julia> roots(tan, interval(-1, 10))
7-element Vector{Root{Interval{Float64}}}:
 Root(Interval{Float64}(-5.9220971777070724e-8, 4.47088230066256e-9, com, NG), :unique)
 Root(Interval{Float64}(1.570796246929277, 1.5707963269211673, com), :unknown)
 Root(Interval{Float64}(3.141592653589474, 3.141592653589817, com, NG), :unique)
 Root(Interval{Float64}(4.712388946492333, 4.712389022821055, com), :unknown)
 Root(Interval{Float64}(6.283185307098206, 6.28318530826717, com, NG), :unique)
 Root(Interval{Float64}(7.85398162069253, 7.853981705843563, com), :unknown)
 Root(Interval{Float64}(9.42477796076779, 9.424777960769498, com, NG), :unique)

There are extra roots because there is no way currently to prove that there is no zero at the singularities.

@Kolaru Kolaru self-assigned this Feb 19, 2024
@Kolaru Kolaru added the bug label Feb 19, 2024
@OlivierHnt OlivierHnt linked a pull request Jun 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants