```python
import loader
from sympy import *
init_printing()
from root.solver import *
```

#### Solve the nonhomogeneous differential equation $y'' + y = \sec t + \tan t + t$ using variation of parameters


```python
yc, p = nth_order_const_coeff(1, 0, 1)
p.display()
yp, p = variation_of_parameters(yc, sec(t) + tan(t) + t)
p.display()
```


$\displaystyle \text{Characteristic equation: }$



$\displaystyle r^{2} + 1 = 0$



$\displaystyle \text{Roots: }\left\{ \begin{array}{ll}r_{1} = i\\r_{2} = - i\\\end{array} \right.$



$\displaystyle \text{General Solution: }$



$\displaystyle y = C_{1} \sin{\left (t \right )} + C_{2} \cos{\left (t \right )}$



$\displaystyle \text{Compute the Wronskian determinant}$



$\displaystyle W = \left|{\left[\begin{matrix}\sin{\left (t \right )} & \cos{\left (t \right )}\\\cos{\left (t \right )} & - \sin{\left (t \right )}\end{matrix}\right]}\right| = -1$



$\displaystyle \text{Compute }W_i$



$\displaystyle \begin{align*}&W_{1} = \left|{\left[\begin{matrix}0 & \cos{\left (t \right )}\\1 & - \sin{\left (t \right )}\end{matrix}\right]}\right| = - \cos{\left (t \right )}\\&W_{2} = \left|{\left[\begin{matrix}\sin{\left (t \right )} & 0\\\cos{\left (t \right )} & 1\end{matrix}\right]}\right| = \sin{\left (t \right )}\\\end{align*}$



$\displaystyle \text{Calculate and simplify }\frac{g(t)}{W(t)}$



$\displaystyle \frac{1}{-1} \left(t + \tan{\left (t \right )} + \sec{\left (t \right )}\right) = - t - \tan{\left (t \right )} - \frac{1}{\cos{\left (t \right )}}$



$\displaystyle \text{Compute }\mu_i = \int \frac{g(t)W_i(t)}{W(t)} dt$



$\displaystyle \begin{align*}&\mu_{1} = \int \left(t \cos{\left (t \right )} + \cos{\left (t \right )} \tan{\left (t \right )} + 1\right)\, dt = t \sin{\left (t \right )} + t\\&\mu_{2} = \int \left(- t \sin{\left (t \right )} - \sin{\left (t \right )} \tan{\left (t \right )} - \frac{\sin{\left (t \right )}}{\cos{\left (t \right )}}\right)\, dt = t \cos{\left (t \right )} + \frac{1}{2} \ln{\left (\sin{\left (t \right )} - 1 \right )} - \frac{1}{2} \ln{\left (\sin{\left (t \right )} + 1 \right )} + \ln{\left (\cos{\left (t \right )} \right )}\\\end{align*}$



$\displaystyle \text{Compute the sum }\sum_{i=1}^{k} y_i \int \frac{g(t)W_i(t)}{W(t)} dt$



$\displaystyle \begin{align*}&y_{p} = \left(t \sin{\left (t \right )} + t\right) \sin{\left (t \right )} + \left(t \cos{\left (t \right )} + \frac{1}{2} \ln{\left (\sin{\left (t \right )} - 1 \right )} - \frac{1}{2} \ln{\left (\sin{\left (t \right )} + 1 \right )} + \ln{\left (\cos{\left (t \right )} \right )}\right) \cos{\left (t \right )}\\&y_{p} = t \sin{\left (t \right )} + t + \frac{\cos{\left (t \right )}}{2} \ln{\left (\sin{\left (t \right )} - 1 \right )} - \frac{\cos{\left (t \right )}}{2} \ln{\left (\sin{\left (t \right )} + 1 \right )} + \ln{\left (\cos{\left (t \right )} \right )} \cos{\left (t \right )}\\\end{align*}$



$\displaystyle \text{Complementray + particular = general}$



$\displaystyle y = t + \left(C_{1} + t\right) \sin{\left (t \right )} + \left(C_{2} + \frac{1}{2} \ln{\left (\sin{\left (t \right )} - 1 \right )} - \frac{1}{2} \ln{\left (\sin{\left (t \right )} + 1 \right )} + \ln{\left (\cos{\left (t \right )} \right )}\right) \cos{\left (t \right )}$


#### Solve the nonhomogeneous differential equation $y'' - 12 y' + 36y = t^{-2} e^{6t} + 14t^2$ using variation of parameters


```python
yc, p = nth_order_const_coeff(1, -12, 36)
p.display()
yp, p = variation_of_parameters(yc, t ** (-2) * exp(6 * t) + 14 * t ** 2)
p.display()
```


$\displaystyle \text{Characteristic equation: }$



$\displaystyle r^{2} - 12 r + 36 = 0$



$\displaystyle \text{Roots: }\left\{ \begin{array}{ll}r_{1,2} = 6\\\end{array} \right.$



$\displaystyle \text{General Solution: }$



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



$\displaystyle \text{Compute the Wronskian determinant}$



$\displaystyle W = \left|{\left[\begin{matrix}e^{6 t} & t e^{6 t}\\6 e^{6 t} & 6 t e^{6 t} + e^{6 t}\end{matrix}\right]}\right| = e^{12 t}$



$\displaystyle \text{Compute }W_i$



$\displaystyle \begin{align*}&W_{1} = \left|{\left[\begin{matrix}0 & t e^{6 t}\\1 & 6 t e^{6 t} + e^{6 t}\end{matrix}\right]}\right| = - t e^{6 t}\\&W_{2} = \left|{\left[\begin{matrix}e^{6 t} & 0\\6 e^{6 t} & 1\end{matrix}\right]}\right| = e^{6 t}\\\end{align*}$



$\displaystyle \text{Calculate and simplify }\frac{g(t)}{W(t)}$



$\displaystyle \frac{14 t^{2} + \frac{e^{6 t}}{t^{2}}}{e^{12 t}} = \frac{e^{- 12 t}}{t^{2}} \left(14 t^{4} + e^{6 t}\right)$



$\displaystyle \text{Compute }\mu_i = \int \frac{g(t)W_i(t)}{W(t)} dt$



$\displaystyle \begin{align*}&\mu_{1} = \int \left(- 14 t^{3} e^{- 6 t} - \frac{1}{t}\right)\, dt = \frac{e^{- 6 t}}{108} \left(252 t^{3} + 126 t^{2} + 42 t + 7\right) - \ln{\left (t \right )}\\&\mu_{2} = \int \left(14 t^{2} e^{- 6 t} + \frac{1}{t^{2}}\right)\, dt = \frac{e^{- 6 t}}{54} \left(- 126 t^{2} - 42 t - 7\right) - \frac{1}{t}\\\end{align*}$



$\displaystyle \text{Compute the sum }\sum_{i=1}^{k} y_i \int \frac{g(t)W_i(t)}{W(t)} dt$



$\displaystyle \begin{align*}&y_{p} = t \left(\frac{e^{- 6 t}}{54} \left(- 126 t^{2} - 42 t - 7\right) - \frac{1}{t}\right) e^{6 t} + \left(\frac{e^{- 6 t}}{108} \left(252 t^{3} + 126 t^{2} + 42 t + 7\right) - \ln{\left (t \right )}\right) e^{6 t}\\&y_{p} = \frac{7 t^{2}}{18} + \frac{7 t}{27} - e^{6 t} \ln{\left (t \right )} - e^{6 t} + \frac{7}{108}\\\end{align*}$



$\displaystyle \text{Complementray + particular = general}$



$\displaystyle y = C_{2} t e^{6 t} + \frac{7 t^{2}}{18} + \frac{7 t}{27} + \left(C_{1} - \ln{\left (t \right )}\right) e^{6 t} + \frac{7}{108}$



```python

```

46175f3bb823f33f1320762d1b1846dbc21f5198
ipynb
Jupyter Notebook
notebooks/variation-of-parameters.ipynb
kaiyingshan/ode-solver
30c6798efe9c35a088b2c6043493470701641042
MIT
2019-02-17T23:15:20.000Z
2019-02-17T23:15:27.000Z
notebooks/variation-of-parameters.ipynb
kaiyingshan/ode-solver
30c6798efe9c35a088b2c6043493470701641042
MIT
notebooks/variation-of-parameters.ipynb
kaiyingshan/ode-solver
30c6798efe9c35a088b2c6043493470701641042
MIT
Qwen/Qwen-72B
1. YES
2. YES