Issue
I want to integrate xe^(-4(x^2)) from x=0 to x=1. When i get integral result, result seems not numerical.
My code is:
import sympy as sp
def f(x):
return x * sp.exp(-4 * (x ** 2))
x = sp.symbols('x')
integral = sp.integrate(f(x), (x, 0, 1))
print(f'Result of analytic integration = {integral}')
Output is:
Result of analytic integration = 1/8 - exp(-4)/8
Solution
The return type is an instance of sympy.core.add.Add
. You can convert it to float by doing:
>>> integral
1/8 - exp(-4)/8
>>> float(integral)
0.12271054513890822
Answered By - abc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.