Distance of point $P$ from an ellipse If $ \frac {x^2}{a^2} + \frac {y^2}{b^2} = r^2$ is an ellipse, with the parameterization $x(θ)≔r(a \cos ⁡θ,b \sin⁡ θ ),$ I have to find the value of $θ$ giving the minimum distance from $P(p,q)$ (not on the ellipse) to the ellipse is given by a quartic in $t= \tan⁡( \frac {θ}{2}).$
A necessary condition for $x$ to be the closest point to $P$ is that $P-x$ is perpendicular to the tangent vector in $x ,$ i.e. $(P-x(θ) ). x' (θ)=0$
I can't handle the above condition to make an fuction (e.g. $f(θ)$) to find the minimum value by calculating the rerivative $f'(θ)=0$ for example. Then I have to prove that rational, non-zero values of $a, b, p, q$ can be found such that the quartic factorises as the product of two quadratics with rational coefficients. Any help? Thank you

One can normalize the length to $r=1$. The distance from $P$ to a point of the ellipse can be written as
\begin{equation}
 d(\theta)=\sqrt{(p-a\cos \theta)^2+(q-b\sin\theta)^2}
\end{equation} 
It is minimal if
\begin{equation}
 a(p-a\cos\theta)\sin\theta-b(q-b\sin\theta)\cos\theta=0
\end{equation} 
with $u=\tan\theta/2$, the condition reads
\begin{equation}
 u^{4}bq+ \left( 2a^{2}+2ap-2b^{2} \right) u^{3}+
 \left( -2a^{2}+2ap+2b^{2} \right) u-bq=0
\end{equation} 
To find rational values for the parameters $a,b,p,q$ which allow a factorization of the quartic, one may choose them to verify
\begin{equation}
 \frac{bq}{ -2a^{2}+2ap+2b^{2}}=\frac{ 2a^{2}+2ap-2b^{2}}{-bq}
\end{equation}
or
\begin{equation}
 b^2q^2=4\left[ \left( a^2-b^2\right)^2-a^2p^2 \right]
\end{equation} 
which can be written as
\begin{equation}
 b^2q^2+4a^2p^2=4\left( a^2-b^2\right)^2
\end{equation} 
By comparison to the pythagorean triples
\begin{equation}
 (3n)^2+(4n)^2=(5n)^2
\end{equation} 
$a^2-b^2=5n$ is verified by $a=4,b=1,n=6$, for example, and thus $q=18,p=3$. The condition reads
\begin{equation}
6 (u+3)(3u^3-1)=0
\end{equation} 
which has 2 real roots $u=-3$ and $u=3^{-1/3}$.
