Updates:
Labels: Integration
Comment #1 on issue 2234 by asmeurer: Incorrect integration of exp(...) and
E**(...) vs N(E)**(...)
http://code.google.com/p/sympy/issues/detail?id=2234
Well, the .0e+2 is a little strange (at least to me), but it is actually
doing it correct. If you add chop=True, it gives you what you want. By
the way, exp(x) is exactly the same as E**x.
In [9]: integrate(sin(pi*x)*exp(-I*2*pi*x),(x,-S(1)/2, S(1)/2))
Out[9]:
-4⋅ⅈ
────
3⋅π
In [10]: integrate(sin(pi*x)*exp(-I*2*pi*x),(x,-S(1)/2, S(1)/2)).evalf()
Out[10]: -0.424413181578388⋅ⅈ
In [11]: integrate(sin(pi*x)*exp(-I*2*pi*x),(x,-.5, .5))
Out[11]:
-1.0⋅π⋅ⅈ
-1.0⋅π⋅ⅈ
cos(0.5⋅π) 2⋅ⅈ⋅sin(0.5⋅π) 2⋅ⅈ⋅ℯ ⋅sin(0.5⋅π) cos(0.5⋅π)⋅ℯ
────────── - ────────────── + ──────────────────────── +
────────────────────
3⋅π 3⋅π 3⋅π 3⋅π
In [12]: integrate(sin(pi*x)*exp(-I*2*pi*x),(x,-.5, .5)).evalf()
Out[12]: .0e-148 + .0e+2⋅ⅈ
In [13]: integrate(sin(pi*x)*exp(-I*2*pi*x),(x,-.5, .5)).evalf(100)
Out[13]: .0e-219 + .0e+2⋅ⅈ
In [14]: integrate(sin(pi*x)*exp(-I*2*pi*x),(x,-.5, .5)).evalf(chop=True)
Out[14]: -0.424413181578388⋅ⅈ
By the way, if you want a numerical answer from integration, you might be
better off using Integral.evalf(), which does numerical integration (the
above computes the integral first and then numerically evaluates the
result). Doing that gives:
In [15]: Integral(sin(pi*x)*exp(-I*2*pi*x),(x,-.5, .5)).evalf()
Out[15]: .0e-18 - 0.424413181578388⋅ⅈ
In [16]: Integral(sin(pi*x)*exp(-I*2*pi*x),(x,-.5, .5)).evalf(chop=True)
Out[16]: -0.424413181578388⋅ⅈ
I'm leaving this open until someone can explain to me why the .0e+2 thing
is or is not a bug.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.