Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate exponential function using sympy

I am trying to integrate e^(-x) from 0 to 1 using sympy but I am getting the following error:

ValueError: Invalid limits given: ((exp(-x), 0, 1),)

Here is my code:

from sympy import *
x = Symbol('x')
exact_value = integrate(exp(-x), (exp(-x), 0, 1))
like image 579
Prog101 Avatar asked Jul 18 '26 12:07

Prog101


1 Answers

Following the documentation the only problem is the tuple you establish as a limit (exp(-x), 0, 1), since it has to be (x, 0, 1) following the previously mentioned structure.

So the edited code would be:

from sympy import *
x = Symbol('x')

exact_value = integrate(exp(-x), (x, 0, 1))
like image 189
Yoshi Avatar answered Jul 21 '26 03:07

Yoshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!