Pendulum
To model a pendulum, we have to solve the following nonlinear ordinary differential equation (ODE):
$$ \frac{d^2\theta}{dt^2} + \frac{g}{L} \sin{\theta} = 0 $$
where \(\theta(t)\) is the angle as a function of time, \(g\) is the gravitational constant, \(L\) is the length of the massless rod.
This equation can not be solved exactly in terms of elementary functions, we can simplify it by assuming \(\theta\) is small
$$ \frac{d^2\theta}{dt^2} + \frac{g}{L} \theta = 0 $$
This linear ODE can be solved exactly. If this assumption is not valid, we have to use numerical methods.
The nonlinear equation above is being integrated with a simple numerical algorithm. The motion starts with a zero initial velocity near the top equilibrium position.
Note that this position is not stable and a small disturbance will grow to large displacements.