Determining the angle degree of an arc in ellipse?

Parameterization of an ellipse by angle from the center is $$ \gamma(\phi)=(\cos(\phi),\sin(\phi))\frac{ab}{\sqrt{a^2\sin^2(\phi)+b^2\cos^2(\phi)}} $$ and $$ \left|\gamma'(\phi)\right|=ab\sqrt{\frac{a^4\sin^2(\phi)+b^4\cos^2(\phi)}{\left(a^2\sin^2(\phi)+b^2\cos^2(\phi)\right)^3}} $$ and integrating $\left|\gamma'(\phi)\right|$ gets extremely messy.

So instead, we use $\theta$, where $$ b\tan(\theta)=a\tan(\phi) $$ Then $$ \gamma(\theta)=(a\cos(\theta),b\sin(\theta)) $$ and $$ \left|\gamma'(\theta)\right|=\sqrt{a^2\sin^2(\theta)+b^2\cos^2(\theta)} $$ Now, integrating $\left|\gamma'(\theta)\right|$ is a lot simpler. $$ \int\left|\gamma'(\theta)\right|\,\mathrm{d}\theta =b\,\mathrm{EllipticE}\left(\theta,\frac{b^2-a^2}{b^2}\right) $$ However, to go from from arc length to angle, we still need to invert the Elliptic integral.


Solution of the problem given using Mathematica

Here we get the solution to 30 places.

In[]=  Phi[a_,b_,s_,opts:OptionsPattern[]] := Block[ {t}, t+ArcTan[(b-a)Tan[t]/(a+b Tan[t]^2)] /. FindRoot[b EllipticE[t,(b^2-a^2)/b^2] == s, {t, 0}, opts]]

In[]=  Phi[4, 2.9`32, 3.31`32, WorkingPrecision->30]

Out[]= 0.87052028743193111752524449959

Thus, $\phi\doteq0.87052028743193111752524449959\text{ radians}$.

Let me describe the algorithm a bit.

FindRoot[b EllipticE[t,(b^2-a^2)/b^2] == s, {t, 0}, opts]

inverts the elliptic integral to get $\theta$ from $a$, $b$, and $s$.

Now, we want to find $\phi$ so that $b\tan(\theta)=a\tan(\phi)$. However, simply using $\tan^{-1}\left(\frac ba\tan(\theta)\right)$ will only return a result in $\left(-\frac\pi2,\frac\pi2\right)$. To get the correct value, we use the relation $$ \begin{align} \tan(\phi-\theta) &=\frac{\tan(\phi)-\tan(\theta)}{1+\tan(\phi)\tan(\theta)}\\ &=\frac{\frac ba\tan(\theta)-\tan(\theta)}{1+\frac ba\tan(\theta)\tan(\theta)}\\ &=\frac{b\tan(\theta)-a\tan(\theta)}{a+b\tan(\theta)\tan(\theta)}\\ \phi &=\theta+\tan^{-1}\left(\frac{(b-a)\tan(\theta)}{a+b\tan^2(\theta)}\right) \end{align} $$ This is why we have

t+ArcTan[(b-a)Tan[t]/(a+b Tan[t]^2)]