```python
from sympy import *
init_printing(use_latex='mathjax')
n = symbols('n', integer=True)
x, y, z = symbols('x,y,z')
```

## Integrals

In the first section we learned symbolic differentiation with `diff`.  Here we'll cover symbolic integration with `integrate`.

Here is how we write the indefinite integral

$$ \int x^2 dx = \frac{x^3}{3}$$


```python
# Indefinite integral
integrate(x**2, x)
```

And the definite integral

$$ \int_0^3 x^2 dx = \left.\frac{x^3}{3} \right|_0^3 = \frac{3^3}{3} - \frac{0^3}{3} = 9 $$


```python
# Definite integral
integrate(x**2, (x, 0, 3))
```

As always, because we're using symbolics, we could use a symbol wherever we previously used a number

$$ \int_y^z x^n dx $$


```python
integrate(x**n, (x, y, z))
```

### Exercise

Compute the following integrals:

$$ \int \sin(x) dx $$
$$ \int_0^{\pi} \sin(x) dx $$
$$ \int_0^y x^5 + 12x^3 - 2x + 1  $$
$$ \int e^{\frac{(x - \mu)^2}{\sigma^2}} $$

Feel free to play with various parameters and settings and see how the results change.


```python
# Use `integrate` to solve the integrals above


```

Are there some integrals that SymPy can't do?  Find some.


```python
# Use `integrate` on other equations. Symbolic integration has it limits, find them.
```

e60fb298839c464949658ce0eb6aefa5fd8ecdc7
ipynb
Jupyter Notebook
tutorial_exercises/03-Integrals.ipynb
gvvynplaine/scipy-2016-tutorial
aa417427a1de2dcab2a9640b631b809d525d7929
BSD-3-Clause
2016-06-21T21:11:02.000Z
2021-02-04T07:51:03.000Z
tutorial_exercises/03-Integrals.ipynb
gvvynplaine/scipy-2016-tutorial
aa417427a1de2dcab2a9640b631b809d525d7929
BSD-3-Clause
2016-07-02T20:24:06.000Z
2016-07-11T11:31:44.000Z
tutorial_exercises/03-Integrals.ipynb
gvvynplaine/scipy-2016-tutorial
aa417427a1de2dcab2a9640b631b809d525d7929
BSD-3-Clause
2016-06-25T09:04:24.000Z
2021-08-09T06:46:01.000Z
Qwen/Qwen-72B
1. YES
2. YES