Let $\Delta ABC$ be a right-angled triangle with $\angle ABC$ as the right angle. Let $P$ be the mid point of $BC$ and $Q$ be a point on $AB$. Suppose that the length of $BC$ is $2x$, $\angle ACQ=\alpha$ and $\angle APQ=\beta$. Then, what is the length of $AQ$?
I tried to use $\angle BCQ$ but ended up with a difficult equation which seems wrong. Any hint on how to approach this?

Note: notation is changed to exploit the usual: $a,\,b,\,c$ denote the side lengths, and $\alpha,\,\beta,\,\gamma$ as the angles of $\triangle ABC$.
\begin{align} \triangle AQC:\quad a-q&=b\,\tan(\alpha-\phi) = \frac{b\,(\tan\alpha-\tan\phi)}{1+\tan\phi\tan\alpha} = \frac{b\,(a\cot\phi-b)}{a+b\cot\phi} \tag{1}\label{1} ,\\ q&= \frac{a^2+b^2}{a+b\cot\phi} \tag{2}\label{2} ,\\ \triangle CPQ:\quad a-q&= \tfrac12\,b\tan(\angle CPB-\theta) = \frac{\tfrac12\,b\,(\tan\angle CPB-\tan\theta)}{1+\tan\angle CPB\tan\theta} = \frac{\tfrac12\,b\,(2a\cot\theta-b)}{2a+b\cot\theta} \tag{3}\label{3} . \end{align}
From \eqref{1} and \eqref{2} we have a quadratic equation in $a$:
\begin{align} k_2\,a^2+k_1\,a+k_0&=0 \tag{4}\label{4} , \end{align} where \begin{align} k_2&=4\cot\phi-2\cot\theta ,\quad k_1=-3b ,\quad k_0=b^2\,(\cot\phi-2\cot\theta) \tag{5}\label{5} . \end{align}
Substitution of the solution of \eqref{4} into \eqref{2} gives the result
\begin{align} q&=\frac{\tfrac32b}{2\cot\phi-\cot\theta} \tag{6}\label{6} . \end{align}