# Integer solutions to $x^2-y^2=33$

I'm currently trying to solve a programming question that requires me to calculate all the integer solutions of the following equation:

$x^2-y^2 = 33$

I've been looking for a solution on the internet already but I couldn't find anything for this kind of equation. Is there any way to calculate and list the integer solutions to this equation?

-
Your title asks a different question than the body of your question; you might want to fix that. –  Niel de Beaudrap Sep 14 '12 at 21:27
Sigh. In the title you say $x^2 - y^2,$ which has integer solutions. With a plus sign there are no integer solutions. –  Will Jagy Sep 14 '12 at 21:27
Done, it's x^2-y^2, sorry for that ;) –  Devos50 Sep 14 '12 at 21:28
$x^2 - y^2 = (x-y)(x+y).$ So both factors are chosen from $\pm 1, \pm 3, \pm 11, \pm 33.$ Then you solve for $x,y.$ –  Will Jagy Sep 14 '12 at 21:30

Suppose that $x=y+n$; then $x^2-y^2=y^2+2ny+n^2-y^2=2ny+n^2=n(2y+n)$. Thus, $n$ and $2y+n$ must be complementary factors of $33$: $1$ and $33$, or $3$ and $11$. The first pair gives you $2y+1=33$, so $y=16$ and $x=y+1=17$. The second gives you $2y+3=11$, so $y=4$ and $x=y+3=7$. As a check, $17^2-16^2=289-256=33=49-16=7^2-4^2$.

If you want negative integer solutions as well, you have also the pairs $-1$ and $-33$, and $-3$ and $-11$.

-

We have $x^2-y^2=33$ iff $(x-y)(x+y)=33$. So to solve our equation we find all ordered pairs $(u,v)$ such that $uv=33$. Then we set $x-y=u$ and $x+y=v$, and solve.

We get $x=\dfrac{v+u}{2}$ and $y=\dfrac{v-u}{2}$. Since $u$ and $v$ will be both odd, $u+v$ and $v-u$ will be even, so $x$ and $y$ will be integers.

The possibilities for $u$ are $-33,-11,-3,-1,1,3,11,33$. The corresponding possibilities for $v$ are $-1,-3,-11,-33,33,11,3,1$. There are $8$ solutions, but only two "really different" ones.

For example, let $u=3$ and $v=11$. Then $x=\dfrac{11+3}{2}=7$ and $y=\dfrac{11-3}{2}=4$.

Generalization: If $n$ is of the form $4k+2$, then $n$ is not the difference of two squares. If $n$ is odd, the representations of $n$ as a difference of two squares are found exactly like the $n=33$ case discussed above. If $n$ is of the form $4k$, we do much the same thing, but find all pairs $(u,v)$ such that $uv=n$ and $u$ and $v$ are even.

-

Note that this is equivalent to solving $(x+n)^2-x^2=33$, and that $(x+n)^2-x^2=(2x+n)n$. Since $33=3\cdot 11$, we see that the solutions are $n=3,x=4$ and $n=11,x=-4$ with $n>0$ and both of thee times $-1$.

-
Thank you for your answer. Could you please explain why this is equal to solving (x+n)^2 - x^2? I don't get that part ;) –  Devos50 Sep 14 '12 at 21:43
@Devos50 Let $y=x+n$. –  Alex Becker Sep 14 '12 at 21:45

Hint $\rm\ \ \ \begin{eqnarray} 3\, &=&\, \color{#0A0}2^2-\color{#C00}1^2\\ 11\, &=&\, \color{blue}6^2-5^2\end{eqnarray}$ $\,\ \Rightarrow\,\$ $\begin{eqnarray} 3\cdot 11\, &=&\, (\color{#0A0}2\cdot\color{blue}6+\color{#C00}1\cdot 5)^2-(\color{#0A0}2\cdot 5+\color{#C00}1\cdot\color{blue}6)^2\, =\, 17^2 - 16^2\\ &=&\, (\color{#0A0}2\cdot\color{blue}6-\color{#C00}1\cdot 5)^2-(\color{#0A0}2\cdot 5-\color{#C00}1\cdot\color{blue}6)^2\, =\, \ 7^2\ -\ 4^2 \end{eqnarray}$

-
Oh, the colors! image –  The Chaz 2.0 Sep 14 '12 at 23:56