Skip to content

Commit 56e331b

Browse files
committed
Add more explanations
Show explicitly how to transform a second order ODE to a system of first order ODEs.
1 parent fa5d0e0 commit 56e331b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tutorials/models/01-classical_physics.jmd

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ But we have numerical ODE solvers! Why not solve the *real* pendulum?
4848

4949
$$\ddot{\theta} + \frac{g}{L}{\sin(\theta)} = 0$$
5050

51+
Notice that now we have a second order ODE.
52+
In order to use the same method as above, we nee to transform it into a system
53+
of first order ODEs by employing the notation $\omega = \dot{\theta}$.
54+
55+
$$
56+
\begin{align}
57+
&\dot{\theta} = \omega \\
58+
&\dot{\omega} = - \frac{g}{L}{\sin(\theta)}
59+
\end{align}
60+
$$
61+
5162
```julia
5263
# Simple Pendulum Problem
5364
using OrdinaryDiffEq, Plots
@@ -62,9 +73,9 @@ tspan = (0.0,6.3)
6273

6374
#Define the problem
6475
function simplependulum(du,u,p,t)
65-
θ = u[1]
66-
= u[2]
67-
du[1] =
76+
θ = u[1]
77+
ω = u[2]
78+
du[1] = ω
6879
du[2] = -(g/L)*sin(θ)
6980
end
7081

0 commit comments

Comments
 (0)