why does "integrate(exp(-x**2),x)" not show erf(x)?

132 views
Skip to first unread message

benhough

unread,
Jan 27, 2010, 5:57:04 PM1/27/10
to sympy
Hi!
I am new to sympy, and my first attempt was to integrate exp(-x^2):

In [1]: from sympy import *
In [2]: x=Symbol('x'); integrate(exp(-x**2),x)
Out[2]: Integral(exp(-x**2), x)

I expected erf(x) as result of the integration (times some constant),
but got Integral(exp(-x**2), x) instead. But sympy knows about erf.
This is obvious when I try "integrate(exp(-x**2)*erf(x), x)". Why is
erf not recognized as integral of exp(-x**2)?

Thanks
Benjamin

Aaron S. Meurer

unread,
Jan 27, 2010, 6:17:15 PM1/27/10
to sy...@googlegroups.com
It works, but you need to use integrate() instead of Integral. Alternately, you can use Integral().doit():

In [3]: print integrate(exp(-x**2), x)
pi**(1/2)*erf(x)/2

In [4]: print Integral(exp(-x**2), x).doit()
pi**(1/2)*erf(x)/2

This is because Integral represents an unevaluated integral, so it does not evaluate by default (this is what .doit() is for). integrate(), on the other hand, tries to evaluate the integral and only returns an Integral if it cannot do it.

Aaron Meurer

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

Reply all
Reply to author
Forward
0 new messages