Solution (source code)

= Solution

As $\omega$ approaches $\omega_0=\sqrt{g/l}$, the driving motion couples resonantly to the pendulum. The particular-solution amplitude has denominator $\omega_0^2-\omega^2$, so a steady harmonic-response formula alone is singular. For a specified finite initial state, the near-resonant motion instead develops <beats>, and its exact resonant limit has a growing envelope.

For example, with the vertical zero-angular-velocity initial condition above, taking the limit gives
$$
\boxed{\theta_{\mathrm{res}}(t)=\frac{A\omega_0}{2l}\,t\sin\omega_0t.}
$$
The ideal undamped linear theory predicts amplitude growing linearly with <time>, not an infinite displacement at the first instant. In reality the motion leaves the small-angle regime, and <damping> and nonlinear changes of the pendulum's <oscillation period> alter the response. Below and above resonance, the sign of the harmonic response coefficient changes, corresponding to a phase reversal.