Finding non-zero rational numbers to fit $a^2+b^2=C$

This is a question on my homework. Specifically, find non-zero rationals $a,b$ such that $a^2+b^2=9$. I think that this is related to work that Diophantus did, but I'm not really sure and I just don't understand how to solve these styles of problems in general.

Hint: $3^2 + 4^2 = 5^2$. Scale...

• This works, but I dont really feel like I understand that I should be getting here. – David Grinberg Dec 20 '13 at 18:17

For any rational number $b$ we want to find $a^2+b^2=C \rightarrow a^2=C-b^2\rightarrow |a|=\sqrt{C-b^2}$

For what values of $b$ is $\sqrt{C-b^2}$ rational ? Let $b=\frac{p}q$ where $p$ and $q$ are relatively prime.

$|a|=\sqrt{C-b^2}=\sqrt{\dfrac{Cq^2}{q^2}-\dfrac{p^2}{q^2}}=\dfrac{\sqrt{Cq^2-p^2}}{|q|}\in\mathbb{Q}$

Therefore $Cq^2-p^2$ must be a perfect square.

• This seems strange though. Choose $q=1, p=5$. They are relatively prime. $Cq-p=4$ in my example, and $4$ and $1$ are relatively prime and perfect squares. So $b=5/1=5$. But $5^2=25>9$, so there is no $a$ we can pick such that $a^2+25=9$. – David Grinberg Dec 20 '13 at 18:15

Let $a = m/n$ and $b = p/q$ where $(m,n) = 1 = (p,q)$. The equation translates to: $(mq)^2 + (np)^2 = (3nq)^2$. So these are Pythagorean triples and the general solution can be found ( H.Stark book ) to be: $mq = x^2 - y^2$, $np = 2xy$, and $3nq = x^2 + y^2$ where $x > y > 0$ and $x, y$ are naturals. So this gives: $p/q = 6xy/(x^2 + y^2)$, and $m/n = 3(x^2 - y^2)/(x^2 + y^2)$. So this substituting these back into the equation we have: $9 = 36x^2y^2/(x^2 +y^2)^2 + 9(x^4 - 2x^2y^2 + y^4)/(x^4 + 2x^2y^2 + y^2)$. Now let $t = x^2/y^2$, we can reduce this to a polynomial equation in t with coefficients in $N$, and using rational root test we can find all the rational roots t's and we can find $x, y$ and then $m, n, p, q$.