Skip to content

When nu is large enough, the root finding fails. #29

Closed

Description

@zhaiyusci

When nu is large enough, the root finding fails.

(@v1.12) pkg> st FunctionZeros
Status `~/.julia/environments/v1.12/Project.toml`
  [b21f74c0] FunctionZeros v1.1.0

julia> besselj_
besselj_deriv_zero
besselj_zero
julia> besselj_zero(73.5, 2)
ERROR: DomainError with -57.89075833371584:
`x` must be nonnegative.
Stacktrace:
  [1] besselj(nu::Float64, x::Float64)
    @ SpecialFunctions ~/.julia/packages/SpecialFunctions/6nmlv/src/bessel.jl:527
  [2] #_besselj_zero##0
    @ ~/.julia/packages/FunctionZeros/aNQPA/src/FunctionZeros.jl:93 [inlined]
  [3] Callable_Function
    @ ~/.julia/packages/Roots/odaES/src/functions.jl:29 [inlined]
  [4] update_state
    @ ~/.julia/packages/Roots/odaES/src/DerivativeFree/secant.jl:39 [inlined]
  [5] update_state
    @ ~/.julia/packages/Roots/odaES/src/DerivativeFree/secant.jl:29 [inlined]
  [6] solve!(𝐙::Roots.ZeroProblemIterator{Roots.Secant, Roots.AlefeldPotraShi, Roots.Callable_Function{…}, Roots.UnivariateZeroState{…}, Roots.UnivariateZeroOptions{…}, Roots.NullTracks}; verbose::Bool)
    @ Roots ~/.julia/packages/Roots/odaES/src/hybrid.jl:54
  [7] solve!
    @ ~/.julia/packages/Roots/odaES/src/hybrid.jl:30 [inlined]
  [8] solve(𝑭𝑿::Roots.ZeroProblem{FunctionZeros.var"#_besselj_zero##0#_besselj_zero##1"{Float64}, Float64}, M::Roots.Order0, p::Nothing; verbose::Bool, kwargs::@Kwargs{tracks::Roots.NullTracks})
    @ Roots ~/.julia/packages/Roots/odaES/src/find_zero.jl:498
  [9] solve
    @ ~/.julia/packages/Roots/odaES/src/find_zero.jl:490 [inlined]
 [10] #find_zero#40
    @ ~/.julia/packages/Roots/odaES/src/find_zero.jl:220 [inlined]
 [11] find_zero (repeats 2 times)
    @ ~/.julia/packages/Roots/odaES/src/find_zero.jl:210 [inlined]
 [12] find_zero
    @ ~/.julia/packages/Roots/odaES/src/find_zero.jl:243 [inlined]
 [13] _besselj_zero
    @ ~/.julia/packages/FunctionZeros/aNQPA/src/FunctionZeros.jl:92 [inlined]
 [14] besselj_zero(nu::Float64, n::Int64)
    @ FunctionZeros ~/.julia/packages/FunctionZeros/aNQPA/src/FunctionZeros.jl:117
 [15] top-level scope
    @ REPL[6]:1
Some type information was truncated. Use `show(err)` to see complete types.

Activity

  1. simonp0420 commented on Dec 25, 2025

    @simonp0420
    Contributor

    This is fixed in the pending PR #28 as shown below:

    julia> using Pkg: Pkg
    
    julia> Pkg.activate(temp=true)
      Activating new project at `C:\Users\peter\AppData\Local\Temp\jl_FCgDwf`
    
    julia> Pkg.add(url="https://github.com/simonp0420/FunctionZeros.jl", rev="fix_overflow")
        Updating git-repo `https://github.com/simonp0420/FunctionZeros.jl`
       Resolving package versions...
        Updating `C:\Users\peter\AppData\Local\Temp\jl_FCgDwf\Project.toml`
      [b21f74c0] + FunctionZeros v1.1.0 `https://github.com/simonp0420/FunctionZeros.jl#fix_overflow`
        Updating `C:\Users\peter\AppData\Local\Temp\jl_FCgDwf\Manifest.toml`
      [7d9f7c33] + Accessors v0.1.43
      [38540f10] + CommonSolve v0.2.4
      [a33af91c] + CompositionsBase v0.1.2
      [187b0558] + ConstructionBase v1.6.0
      [ffbed154] + DocStringExtensions v0.9.5
      [b21f74c0] + FunctionZeros v1.1.0 `https://github.com/simonp0420/FunctionZeros.jl#fix_overflow`
      [3587e190] + InverseFunctions v0.1.17
      [92d709cd] + IrrationalConstants v0.2.6
      [692b3bcd] + JLLWrappers v1.7.1
      [2ab3a3ac] + LogExpFunctions v0.3.29
      [1914dd2f] + MacroTools v0.5.16
      [21216c6a] + Preferences v1.5.1 [loaded: v1.5.0]
      [f2b01f46] + Roots v2.2.10
      [276daf66] + SpecialFunctions v2.6.1
      [efe28fd5] + OpenSpecFun_jll v0.5.6+0
      [56f22d72] + Artifacts v1.11.0
      [ade2ca70] + Dates v1.11.0
      [8f399da3] + Libdl v1.11.0
      [37e2e46d] + LinearAlgebra v1.12.0
      [de0858da] + Printf v1.11.0
      [fa267f1f] + TOML v1.0.3
      [4ec0a83e] + Unicode v1.11.0
      [e66e0078] + CompilerSupportLibraries_jll v1.3.0+1
      [4536629a] + OpenBLAS_jll v0.3.29+0
      [05823500] + OpenLibm_jll v0.8.7+0
      [8e850b90] + libblastrampoline_jll v5.15.0+0
    
    julia> Pkg.add("SpecialFunctions")
       Resolving package versions...
        Updating `C:\Users\peter\AppData\Local\Temp\jl_FCgDwf\Project.toml`
      [276daf66] + SpecialFunctions v2.6.1
        Manifest No packages added to or removed from `C:\Users\peter\AppData\Local\Temp\jl_FCgDwf\Manifest.toml`
    
    julia> using FunctionZeros: besselj_zero
    
    julia> using SpecialFunctions: besselj
    
    julia> x = besselj_zero(73.5, 2)
    87.8434178096031
    
    julia> besselj(x, 2)
    1.0754863847166907e-134
    
  2. zhaiyusci commented on Dec 31, 2025

    @zhaiyusci
    Author

    Great! I will close this issue after your PR is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions