[Numpy-discussion] about sympy

Ronan Lamy ronan.lamy@gmail....
Sun Mar 11 10:46:39 CDT 2012


Le dimanche 11 mars 2012 à 01:31 -0600, Val Kalatsky a écrit :
> Can you?
> The question should be: Why sympy does not have Fresnel integrals?
> 
Well, the development version has hypergeometric functions, which is
enough to integrate sin(x**2):

>>> from sympy import *
>>> x = Symbol('x')
>>> integrate(sin(x**2))
x**3*gamma(3/4)*hyper((3/4,), (3/2, 7/4), -x**4/4)/(4*gamma(7/4))
>>> integrate(sin(x**2), (x, 0, oo))
sqrt(2)*sqrt(pi)/4

It can also create a numerical function for the result, but it uses
mpmath, so it won't play well with numpy:

>>> f = lambdify(x, integrate(sin(x**2)))
>>> f(4567.)
mpf('0.62676518399179759')
>>> f(np.linspace(-5., 5., 10))
Traceback (most recent call last):
  File "<ipython-input-35-97e0996f77c3>", line 1, in <module>
    f(np.linspace(-5., 5., 10))
  File "<string>", line 1, in <lambda>
  File "/home/ronan/dev/sympy/sympy/mpmath/functions/hypergeometric.py",
line 199, in hyper
    z = ctx.convert(z)
  File "/home/ronan/dev/sympy/sympy/mpmath/ctx_mp_python.py", line 662,
in convert
    return ctx._convert_fallback(x, strings)
  File "/home/ronan/dev/sympy/sympy/mpmath/ctx_mp.py", line 556, in
_convert_fallback
    raise TypeError("cannot create mpf from " + repr(x))
TypeError: cannot create mpf from array([ -1.56250000e+02,  -5.71797363e
+01,  -1.48843545e+01,
        -1.92901235e+00,  -2.38149672e-02,  -2.38149672e-02,
        -1.92901235e+00,  -1.48843545e+01,  -5.71797363e+01,
        -1.56250000e+02])


> On Sun, Mar 11, 2012 at 1:06 AM, aa <telukpalu@gmail.com> wrote:
>         why sympy cannot integrate sin(x**2)??
>         _______________________________________________
>         NumPy-Discussion mailing list
>         NumPy-Discussion@scipy.org
>         http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 
> 
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion




More information about the NumPy-Discussion mailing list