# Further information

## How can we plot a function

It is possible to plot a function using `sympy` using the `sympy.plot` function:

````{tip}
```
sympy.plot(expression)
```
````

So for example, here is a plot of $f(x)=x^2 + 3x + 1$:


```python
import sympy as sym

x = sym.Symbol("x")
sym.plot(x ** 2 + 3 * x + 1)
```

It is possible to specify the x limits and combine it with other plots:


```python
sym.plot(x ** 2 + 3 * x + 1, xlim=(-5, 5))
```

**This plotting solution is fine it you want to take a look at a function
quickly but it is not recommended.** The main library for plotting is called
`matplotlib` and {ref}`matplotlib` covers this.

- Here is the `sympy` documentation for plotting:
  <https://docs.sympy.org/latest/modules/plotting.html>
- Here is the official `matplotlib` documentation: <https://matplotlib.org>

0721fbef32e22b03c6ec7f77b1f573194472b703
ipynb
Jupyter Notebook
book/tools-for-mathematics/03-calculus/why/.main.md.bcp.ipynb
11michalis11/pfm
c91b1eda70d7cde3fbe065db4667f84853947850
MIT
2020-09-24T21:02:41.000Z
2020-10-14T08:37:21.000Z
book/tools-for-mathematics/03-calculus/why/.main.md.bcp.ipynb
11michalis11/pfm
c91b1eda70d7cde3fbe065db4667f84853947850
MIT
2020-09-21T15:54:23.000Z
2021-12-19T23:26:15.000Z
book/tools-for-mathematics/03-calculus/why/.main.md.bcp.ipynb
11michalis11/pfm
c91b1eda70d7cde3fbe065db4667f84853947850
MIT
2020-10-02T09:21:27.000Z
2021-07-08T14:46:27.000Z
Qwen/Qwen-72B
1. YES
2. YES