On Thu, May 14, 2009 at 3:53 PM, Gael Varoquaux
<gael.varoqu...@normalesup.org> wrote:
> Ondrej, please enlight me, what are going to be the pros and cons of
> doing this with sympy rather than scipy?

Well, one big pro is that after my patch is accepted, sympy can return
analytical formulas for the spherical bessel functions of the first
kind:

In [1]: jn(5, z)
Out[1]:
⎛945   420   15⎞          ⎛  1   945   105⎞
⎜─── - ─── + ──⎟⋅sin(z) + ⎜- ─ - ─── + ───⎟⋅cos(z)
⎜  6     4    2⎟          ⎜  z     5     3⎟
⎝ z     z    z ⎠          ⎝       z     z ⎠

In [2]: jn(5, S(1)/3)
Out[2]: -226803⋅cos(1/3) + 655020⋅sin(1/3)

and second kind too. You can then evaluate them:

In [14]: jn(5, S(1)/3).n()
Out[14]: 3.94196482167865e-7

and compare it to scipy to make sure scipy is correct:

In [13]: sph_jn(5, 1/3)[0][-1]
Out[13]: 3.94196482168e-07

But you can get any precision you want with sympy:

In [16]: jn(5, S(1)/3).n(100)
Out[16]:
0.0000003941964821678649390840998829757777240779239598155772550451058081905608
121697285237272330996351440135

and it's exact --- scipy is using a special algorithm for sph_jn and
if you look at its fortran sources, one may not be exactly sure it's
correct.

Ondrej

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to