# Math Help - Ode with variable in trig function

1. ## Ode with variable in trig function

What method would I use to solve ode that look like

x'' + sin(x)=0. And

x' + sin(x)=0?

They are different problems so not a system. On a side not, is there a quick way to numerically solve with Matlab?
Any help appreciated.

3. ## Re: Ode with variable in trig function

Originally Posted by Dagger2006
What method would I use to solve ode that look like

x'' + sin(x)=0. And

x' + sin(x)=0?

They are different problems so not a system. On a side not, is there a quick way to numerically solve with Matlab?
Any help appreciated.
\displaystyle \begin{align*} \frac{dx}{dt} + \sin{x} &= 0 \\ \frac{dx}{dt} &= -\sin{x} \\ -\frac{1}{\sin{x}}\,\frac{dx}{dt} &= 1 \\ -\frac{\sin{x}}{\sin^2{x}}\,\frac{dx}{dt} &= 1 \\ -\frac{\sin{x}}{1 - \cos^2{x}}\,\frac{dx}{dt} &= 1 \\ \int{-\frac{\sin{x}}{1 - \cos^2{x}}\,\frac{dx}{dt}\,dt} &= \int{1\,dt} \\ \int{-\frac{\sin{x}}{1 - \cos^2{x}}\,dx} &= t + C_1 \\ \int{\frac{1}{1 - u^2}\,du} &= t + C_1 \textrm{ if we let } u = \cos{x} \implies du = -\sin{x}\,dx \\ \int{\frac{1}{(1 - u)(1 + u)}\,du} &= t + C_1 \\ \int{\frac{1}{2(1 - u)} + \frac{1}{2(1 + u)}\,du} &= t + C_1 \\ -\frac{1}{2}\ln{|1 - u|} + \frac{1}{2}\ln{|1 + u|} + C_2 &= t + C_1 \\ \frac{1}{2}\ln{\left|\frac{1 + u}{1 - u}\right|} &= t + C_1 - C_2 \\ \ln{\left|\frac{1 + u}{1 - u}\right|} &= 2t + C \textrm{ where } C = 2C_1 - 2C_2 \\ \ln{\left|\frac{2}{1 - u} - 1\right|} &= 2t + C \\ \left|\frac{2}{1 - u} - 1\right| &= e^{2t + C} \\ \frac{2}{1 - u} - 1 &= A\,e^{2t}\textrm{ where }A = \pm e^C\end{align*}

\displaystyle \begin{align*} \frac{2}{1 - u} &= A\,e^{2t} + 1 \\ \frac{1 - u}{2} &= \frac{1}{A\,e^{2t} + 1} \\ 1 - u &= \frac{2}{A\,e^{2t} + 1} \\ u &= 1 - \frac{2}{A\,e^{2t} + 1} \\ u &= \frac{A\,e^{2t} + 1 - 2}{A\,e^{2t} + 1} \\ u &= \frac{A\,e^{2t} - 1}{A\,e^{2t} + 1} \\ \cos{x} &= \frac{A\,e^{2t} - 1}{A\,e^{2t} + 1} \\ x &= \arccos{\left(\frac{A\,e^{2t} - 1}{A\,e^{2t} + 1}\right)} \end{align*}

4. ## Re: Ode with variable in trig function

Thanks for the result. That's around the direction i was thinking with the 1st order on. Would I solve the 2nd order ODE the same way, or is there another method I should try? Thanks!

5. ## Re: Ode with variable in trig function

Hello, Dagger2006!

$\frac{dx}{dt} + \sin x \:=\:0$

$\frac{dx}{dt} \:=\:-\sin x \quad\Rightarrow\quad \csc x\,\frac{dx}{dt} \:=\:-1$

$\text{Integrate: }\:\int \csc x\,dx \;=\;-\int dt$

. . . . $\ln|\csc x - \cot x| \;=\;-t + C$