Problem
Given, for $\ce{H3PO4}$,
$\mathrm{pK_\mathrm{a_1}=2.2}$
$\mathrm{pK_\mathrm{a_2}=7.2}$
$\mathrm{pK_\mathrm{a_3}=12.4}$
For the salt $\ce{Mg(NH4)PO4}$, $\mathrm{pK_\mathrm{sp}=12.6}$ and the equilibrium concentration of $\ce{NH4^+}$ is $\mathrm{0.1 M}$. If the solubility of $\ce{Mg(NH4)PO4}$ in the solution, with $\mathrm{pH=10}$ is S, find the value of $\mathrm{-log(S)}$.
Answer
$\mathrm{4.6}$
Question
I assumed that the contribution of $\ce{NH4^+}$ ions from the salt is to be neglected, so $\ce{[NH4^+]=10^\mathrm{-1}}$. The solubility S is then equal to the concentration of $\ce{Mg^2+}$ ions. Also, the initial amount of $\ce{PO4^3-}$ will also be S, out of which, I took some $x$ amount to have hydrolyzed to $\ce{H3PO4}$, $\ce{H2PO4^-}$ and $\ce{HPO4^2-}$.
Then, $$\ce{K_\mathrm{sp}=\ce{[Mg^2+][NH4^+][PO4^3-]}}$$ $$\ce{K_\mathrm{sp}=\mathrm{(S)(0.1)(S-x)}}$$
And using the values of $\mathrm{pK_a}$, I can get three more equations, with two more variables for the amounts of $\ce{H2PO4^-}$ and $\ce{HPO4^2-}$. Four equations, four variables - that's fine in general, if one has a computer. But this particular exam doesn't even allow a calculator, so I don't think that is what we are supposed to do here.
Another similar, but much simpler question - one is asked to find the solubility of $\ce{AgCl}$ in an $\ce{NH3}$ solution of given molarity, with the values of $\mathrm{pK_\mathrm{sp}}$ and formation constant of complex $\ce{[Ag(NH3)2]^+}$ given. In that case we assume that all of the $\ce{Ag^+}$ initially released, turns to $\ce{[Ag(NH3)2]^+}$ and solve accordingly.
But in this case there are three different ions and products possible by hydrolysis, so I am unable to find out which of them should be considered as the dominant species.
EDIT - M.L.'s answer clarified the calculations involved. My main confusion now is regarding why $\ce{HPO4^2-}$ (and not $\ce{H2PO4^-}$ or $\ce{H3PO4}$), will be the major ionic species in the solution. Is there a way to predict this based on values of $\mathrm{pK_a}$ and the $\mathrm{pH}$ of the solution?