# Spherical Bessel functions

**URL:** <https://discourse.julialang.org/t/spherical-bessel-functions/32487>\
**Category:** General Usage\
**Created:** [December 19, 2019, 4:48pm UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487 "2019-12-19T16:48:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![urp](https://avatars.discourse-cdn.com/v4/letter/u/b38774/32.png) [@urp](https://discourse.julialang.org/u/urp)\
**Post date:** [December 19, 2019, 4:48pm UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487/1 "2019-12-19T16:48:44Z")

</div>

Is “spherical Bessel function” available in any of the libraries in Julia? I am aware that SpecialFunctions.jl package has Bessel function.

---

<div class="post-metadata">

**Author:** ![Oliver\_Lylloff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oliver_lylloff/32/9022_2.png) [@Oliver\_Lylloff](https://discourse.julialang.org/u/Oliver_Lylloff)\
**Post date:** [December 19, 2019, 6:09pm UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487/2 "2019-12-19T18:09:29Z")

</div>

Looks like GSL.jl might have (on phone so cannot check). BTW, found it via [pkg.julialang.org](http://pkg.julialang.org) - that might help with the search.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [December 19, 2019, 7:37pm UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487/3 "2019-12-19T19:37:45Z")

</div>

If you use SpecialFunctions.jl You can define the spherical bessel `j` and `y` functions in one line each:

```julia
sphericalbesselj(ν, x) = √(π/2x)*besselj(ν+1/2, x)

sphericalbessely(ν, x) = √(π/2x)*bessely(ν+1/2, x)

```

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [December 20, 2019, 2:56am UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487/4 "2019-12-20T02:56:53Z")

</div>

I have to admit SpecialFunctions is a magical-magical package. It should be in Base julia :).

---

<div class="post-metadata">

**Author:** ![urp](https://avatars.discourse-cdn.com/v4/letter/u/b38774/32.png) [@urp](https://discourse.julialang.org/u/urp)\
**Post date:** [December 20, 2019, 6:45pm UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487/5 "2019-12-20T18:45:59Z")

</div>

Thanks, this link will be very useful. GSL library does have the spherical bessel functions.

---

<div class="post-metadata">

**Author:** ![urp](https://avatars.discourse-cdn.com/v4/letter/u/b38774/32.png) [@urp](https://discourse.julialang.org/u/urp)\
**Post date:** [December 20, 2019, 6:51pm UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487/6 "2019-12-20T18:51:57Z")

</div>

Yes, this is what I had implemented originally. I was concerned about two things:

- Need to write an additional check if x is close to 0.
- My guess is that the spherical Bessel functions might be faster to compute than cylindrical Bessel functions because they may be expressed in terms of trig functions.

My program calls these functions several thousand of times so performance was important.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [December 20, 2019, 7:47pm UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487/7 "2019-12-20T19:47:01Z")

</div>

Maybe those should be defined in SpecialFunctions.jl?

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [December 21, 2019, 12:25am UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487/8 "2019-12-21T00:25:38Z")

</div>

It used to be.  
It was removed do it can be extended more easily. Without being tied to the very slow language release cycle, and being updatable for people still on the LTS.

E.g. in this case we might get a win from it since that can, as @dpsanders suggests. Be added with a simple PR

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [December 21, 2019, 1:30am UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487/9 "2019-12-21T01:30:34Z")

</div>

Ah that makes even more sense 🙂 thanks for explaining.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [December 21, 2019, 8:21pm UTC](https://discourse.julialang.org/t/spherical-bessel-functions/32487/10 "2019-12-21T20:21:32Z")

</div>

I have made a PR to SpecialFunctions.jl with the spherical bessel functions. Test / performance / reliability suggestions much appreciated! [https://github.com/JuliaMath/SpecialFunctions.jl/pull/196](https://github.com/JuliaMath/SpecialFunctions.jl/pull/196)
