with a change of variable $x = \frac{\cos \theta}{a_1r}, y = \frac{\sin \theta}{a_2r}, $ the new equations for $r \text{ and } \theta$ are:

$$\frac{dr}{dt} = f(\theta), \frac{rd\theta}{dt}=g(\theta) $$ where $f$ and $g$ are functions of $\theta$ that can be explicitly computed.
the last two equations can be solves as $\ln r = \int \frac{f(\theta)}{g(\theta)}d\theta$