I want to integrate the equation:
f(x) = integral(E^(-i * omega * t)), from
-a
toa
.
I wrote the following code:
from sympy import *
from sympy.abc import a, omega, t
init_printing(use_unicode=False, wrap_line=False, no_global=True)
f = E**(-I * omega * t)
integrate(f, (omega, -a, a))
But the result is just the entered definite integral. When I change the integrally limits to 0
to a I
get a result... Does anyone know how to get a solution from -a
to a
?
Many thanks in advance.
John
The SymPy package contains integrals module. It implements methods to calculate definite and indefinite integrals of expressions. The integrate() method is used to compute both definite and indefinite integrals. To compute an indefinite or primitive integral, just pass the variable after the expression.
Definite integrals are the extension after indefinite integrals, definite integrals have limits [a, b]. It gives the area of a curve bounded between given limits. It denotes the area of curve F(x) bounded between a and b, where a is the lower limit and b is the upper limit.
integrate() method, we can find the integration of mathematical expressions in the form of variables by using sympy. integrate() method.
Sympy does not know about all the things you assume about your variables, so you need to tell sympy explicitly. For example a
is supposed to be a positive (and hence real) number. If I tell this to sympy, then I get a nice answer. Try
a = symbols('a', positive=True)
right before
integrate(f, (omega, -a, a))
And make sure you use a sufficiently recent version of sympy. 1.0 works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With