# Nonlinear differential equation with singularity: numerical solution?

I want to numerically solve the following problem over some interval of time: \begin{eqnarray*} \dot{\theta}_1 & = & \theta_2\\ \dot{\theta}_2 & = & \frac{g - l\theta_2^2\cos\theta_1}{l\sin\theta_1} \end{eqnarray*} from initial condition $(\theta_1(0),\theta_2(0)) = (0,\sqrt{\frac{g}{l}})$. The constant are $l = 1$, $g = 10$.

My problem is that right hand side is infinity for the initial condition, so I cannot use an Euler scheme, for example.

Is there a general way to deal with problems like this one? Can anyone recommend a good textbook that deals with it? Thanks!

• Are you sure that this is correct system of equations? How did you derive it? – Evgeny Sep 29 '15 at 14:07
• These are half of the equations of a pendulum on a cart utilising a very specific control, (the control is the force applied to the cart). It is a 4th order system, but I am only interested in the equations involving the angle the rod makes with the vertical, as well as its derivative. The reason for this is that the cart's dynamics do not appear on the rhs of the above two equations, and so I can ignore them... – MathsStudent Sep 29 '15 at 14:35

In this particular case, the system is equivalent to the second order ODE $$\ddot{\theta} \sin \theta + \dot{\theta}^2 \cos \theta = \frac{g}{l},$$ with $\theta = \theta_1$. We can recognise the left hand side as the second derivative of $-\cos \theta$, so that we obtain $$\frac{\text{d}^2}{\text{d} t^2} \cos \theta = - \frac{g}{l}.$$ If I were to guess, this is probably where your system came from in the first place. Integrating twice with respect to $t$ and using the initial condition $\theta(0) = 0$ yields then $$\cos \theta = 1 - \frac{1}{2}\frac{g}{l} t^2.$$ When you try to draw $\theta(t)$, you'll see that there is a problem at $t=0$: there are two solution branches to choose from. However, the initial condition on the derivative at $0$, $\theta'(0) = \sqrt{\frac{g}{l}}>0$ allows you to select the correct branch. Note that every branch only exists up to $t_* = 2 \sqrt{\frac{l}{g}}$.
From the dynamical systems point of view, the limit $(\theta_1,\theta_2) \to (0,\sqrt{\frac{g}{l}})$ in the equation for $\dot{\theta_2}$ is not unique: write $\theta_1 = \varepsilon$ and $\theta_2 = \sqrt{\frac{g}{l}} + s \varepsilon$, then $$\lim_{\varepsilon \to 0} \left.\frac{g - l \theta_2^2 \cos \theta_1}{\sin \theta_1}\right|_{\theta_1=\varepsilon,\theta_2 = \sqrt{\frac{g}{l}} + s \varepsilon} = -2 \sqrt{\frac{g}{l}} s,$$ which therefore depends on the direction $(1,s)$ of the limit.
• Hello, thanks for your reply.... To check... when you say that there are two solution branches, you mean that there is one defined on $[-2\sqrt{\frac{g}{l}},0]$ and one defined on $[0,2\sqrt{\frac{g}{l}}]$ and that one should only consider the solution defined on $[0,2\sqrt{\frac{g}{l}}]$ because of $\theta ' (0) > 0$? – MathsStudent Sep 29 '15 at 17:27
• No, by two branches I mean two possible solutions $\theta(t)$ on the open interval $(0,2\sqrt{\frac{l}{g}})$ (look carefully at the fraction, you made a mistake in your comment) for which $\theta(0) = 0$: they are distinguished by their derivative at $t=0$, and by using the initial condition $\theta'(0) = \sqrt{\frac{g}{l}}$ you automatically select one of those two branches. If you want to extend the solution for $t<0$, you're faced with the same two-branch problem on the interval $(-2\sqrt{\frac{l}{g}},0)$, but demanding continuity of the derivative automatically selects the proper branch. – Frits Veerman Sep 30 '15 at 10:17
• Ah ok, thanks a lot! So the non-uniqueness comes from the symmetry of $\cos(\theta)$. – MathsStudent Oct 1 '15 at 11:14