Skip to content

Conversation

@simonp0420
Copy link
Contributor

@simonp0420 simonp0420 commented Oct 17, 2025

Add methods to bessel_zero_asymptotic and bessel_deriv_zero_asymptotic that promote nu from Integer to float. Fixes Issue #27

@simonp0420
Copy link
Contributor Author

simonp0420 commented Oct 17, 2025

I submitted this PR a little too early. All tests ran successfully on my machine where Int === Int64, but I see some have failed in CI on x86 machines, where Int === Int32, and the @test_broken tests are actually no longer broken. I also now see from the comments preceding the "high nu" test set that Issue #27 overlaps with Issue #10. I'll modify this PR to replace the @test_broken tests to @test after which I think everything should work ok.

@simonp0420 simonp0420 changed the title Fix Issue #27 WIP: Fix Issue #27 Oct 17, 2025
@simonp0420
Copy link
Contributor Author

Edit: Changing this to a WIP (Work In Progress) PR since the problem still occurs for even higher nu values. Please don't merge yet.

@simonp0420
Copy link
Contributor Author

simonp0420 commented Oct 19, 2025

Ok, I've implemented an asymptotic formula from DLMF that is appropriate for large nu and small n. Now the first ten zeros of any of the four treated functions are returned correctly for any positive nu value. All zeros are returned correctly for nu less than or equal to at least 150. This corrects the problem mentioned in this comment to Issue #10.

Here is an example of finding the correct first 25 zeros for the derivative of a Bessel Y function of order 150:

julia> using FunctionZeros, SpecialFunctions, Plots

julia> t = [bessely_deriv_zero(150, n) for n in 1:25]
25-element Vector{Float64}:
 159.85254354288477
 167.76036070522397
 174.32071688833557
 180.22537114717298
 185.71690058288073
   ⋮
 255.3186728810697
 259.1858488958748
 263.0241588781523
 266.8356390609487
 270.6221130091581

julia> bessely_deriv(nu, x) = 0.5 * (bessely(nu-1, x) - bessely(nu+1, x))
bessely_deriv (generic function with 1 method)

julia> maximum(x -> abs(bessely_deriv(150, x)), t)
8.847089727481716e-16

julia> plot(;legend=nothing); plot!(range(140, 272, 600), x -> bessely_deriv(150, x)); scatter!(t, zeros(length(t)))
image

And here is an example showing that the first 10 zeros are correctly found for a ridiculously large value of nu = 10_000:

julia> t = [bessely_deriv_zero(10_000, n) for n in 1:11]
11-element Vector{Float64}:
 10039.277992159914
 10069.79405626667
 10094.526103710305
 10116.360982858023
 10136.3273778352
 10154.945576301201
 10172.525286577882
 10189.26979494539
 10205.321627357598
 10220.78559381645
 11243.12462090691

julia> maximum(x -> abs(bessely_deriv(10_000, x)), t[1:10])
3.3608255067818504e-12

julia> plot(;legend=nothing); plot!(range(10038, 11245, 600), x -> bessely_deriv(10_000, x)); scatter!(t, zeros(length(t)))
image
  • Removed WIP from title of PR.
  • Ready for review

@simonp0420 simonp0420 changed the title WIP: Fix Issue #27 Fix Issue #27 Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant