---
author: Nathan Carter (ncarter@bentley.edu)
---

This answer assumes you have imported SymPy as follows.


```python
from sympy import *                   # load all math functions
init_printing( use_latex='mathjax' )  # use pretty math output
```

Let's compute the area under $\sin x$ from $x=0$ to $x=\pi$.

We use the same technique as in how to write and evaluate indefinite integrals,
except that we add the lower and upper bounds together with $x$, as shown below.


```python
var( 'x' )
formula = sin(x)
Integral( formula, (x,0,pi) )
```




$\displaystyle \int\limits_{0}^{\pi} \sin{\left(x \right)}\, dx$



The above code just displays the definite integral.
To evaluate it, use the `integrate` command.


```python
integrate( formula, (x,0,pi) )
```




$\displaystyle 2$



69773fd3c9a6a20e113ef96cf99b648679c33b38
ipynb
Jupyter Notebook
database/tasks/How to write and evaluate definite integrals/Python, using SymPy.ipynb
nathancarter/how2data
7d4f2838661f7ce98deb1b8081470cec5671b03a
MIT
database/tasks/How to write and evaluate definite integrals/Python, using SymPy.ipynb
nathancarter/how2data
7d4f2838661f7ce98deb1b8081470cec5671b03a
MIT
database/tasks/How to write and evaluate definite integrals/Python, using SymPy.ipynb
nathancarter/how2data
7d4f2838661f7ce98deb1b8081470cec5671b03a
MIT
2021-07-18T19:01:29.000Z
2022-03-29T06:47:11.000Z
Qwen/Qwen-72B
1. YES
2. YES