```python
import sympy as sp
```


```python
sp.__version__
```




    '1.6.2'



### Use `dsolve` in `sympy` to solve differential equations


```python
from sympy.solvers.ode import dsolve
```


```python
t = sp.var('t')
f = sp.Function('f')
```


```python
f_ = sp.Derivative(f(t), t)
```


```python
f_
```




$\displaystyle \frac{d}{d t} f{\left(t \right)}$




```python
f__ = sp.Derivative(f(t),t,t)
```


```python
f__
```




$\displaystyle \frac{d^{2}}{d t^{2}} f{\left(t \right)}$




```python
ode = f__ - 4*f_ + 4
ode
```




$\displaystyle - 4 \frac{d}{d t} f{\left(t \right)} + \frac{d^{2}}{d t^{2}} f{\left(t \right)} + 4$




```python
dsolve(ode,f(t))
```




$\displaystyle f{\left(t \right)} = C_{1} + C_{2} e^{4 t} + t$




```python
dsolve(ode,f(t), ics={f(0):sp.E, f(4):sp.E})
```




$\displaystyle f{\left(t \right)} = t + \frac{4 e^{4 t}}{1 - e^{16}} - \frac{4}{1 - e^{16}} + e$



226870da0e9f0fa5f83d9c02a42a122e216356b7
ipynb
Jupyter Notebook
posts/am105/sympy_dsolve.ipynb
minhuanli/notes
9d54787dc784c6b8c647db4da8d299b22703c75e
MIT
posts/am105/sympy_dsolve.ipynb
minhuanli/notes
9d54787dc784c6b8c647db4da8d299b22703c75e
MIT
posts/am105/sympy_dsolve.ipynb
minhuanli/notes
9d54787dc784c6b8c647db4da8d299b22703c75e
MIT
Qwen/Qwen-72B
1. YES
2. YES