# Thread: System of two equations with three integer unknowns

1. ## System of two equations with three integer unknowns

Hi all,
here is my problem. I have the following system :

$\displaystyle S \left\{\begin{array}{cc}a^2 - ab + n = 0 \\a^2 - ac - n = 0\end{array}\right.$

Where $\displaystyle a$, $\displaystyle b$ and $\displaystyle c$ are integer unknowns and $\displaystyle n$ is any integer value (known)

Is there any general way to solve such equations quickly (for all three unknowns) ? Thanks a lot !

2. Originally Posted by Bacterius
Hi all,
here is my problem. I have the following system :

$\displaystyle S \left\{\begin{array}{cc}a^2 - ab + n = 0 \\a^2 - ac - n = 0\end{array}\right.$

Where $\displaystyle a$, $\displaystyle b$ and $\displaystyle c$ are integer unknowns and $\displaystyle n$ is any integer value (known)

Is there any general way to solve such equations quickly (for all three unknowns) ? Thanks a lot !
The first thing I notice is that adding the two equations gives $\displaystyle 2a^2- a(b+c)= 0$. One obvious solution to that is a= 0. But that gives $\displaystyle a^2- ab+ n= n= 0$ and [tex]a^2- ac- n= n= 0[/itex]. If n= 0, then a= 0 , b, c any integers satisfy the equations.

If a is not 0, we can divide through by it and get a- (b+c)= 0 so a= b+c. Putting that into the first equation we get $\displaystyle (b+c)^2- (b+c)b+ n= b^2+ 2bc+ c^2- b^2- bc+ n$$\displaystyle = bc+ c^2+ n= 0$ so $\displaystyle c^2= bc- n$.

Putting a= b+ c into the last eqaution gives $\displaystyle (b+c)^2- (b+c)c- n= 0$ or $\displaystyle b^2+ 2bc+ c^2- bc- c^2- n= b^2+ bc- n= 0$ and, now, $\displaystyle c^2= bc-n$. That means we must have $\displaystyle b^2= c^2$ and so $\displaystyle c= \pm b$.

If c= -b, we have, from a-(b+c)= a= 0 again.

If c= b, a-(b+c)= 0 becomes a- 2b= 0 so a= 2b. Given any integer, k, take a= 2k, b= c= k. The equation $\displaystyle a^2- ab+ n= 0$ becomes $\displaystyle 4k^2- k^2+ n= 3k^2+ n= 0$.

If n> 0, that is impossible. The only solution is a=0, b, c any integers.

If n= 0, that gives k= 0. That is a= b= c= 0, which is included in "a= 0, b, c any integers above".

If n< 0, $\displaystyle k^2= -n/3$ so that $\displaystyle k= \sqrt{-n/3}$ which is integer only if n is -3 times a square: [tex]n= -3m^2[tex], in which case $\displaystyle k= m$.

That is:
If $\displaystyle n\ge 0$ or n< 0 is not of the form $\displaystyle n= -3m^2$ for some integer m, then a=0, b, c any numbers is the only solution.

If $\displaystyle m= -3m^2$, then a= 2m, b= c= m.

3. Well $\displaystyle n > 3$, and I know that (maybe it could help) $\displaystyle n = ad$ (with new unknown $\displaystyle d$ of course)
And, $\displaystyle a > 0$, $\displaystyle b > 0$, $\displaystyle c > 0$ (and $\displaystyle d > 1$).

But it looks like I'm screwed, perhaps I need more information ?

4. ## Brute Force Approach - General

Solve for a using the quadratic formula: $\displaystyle 2a=b\pm\sqrt{b^2-4n}=c\pm\sqrt{c^2+4n}$

Now isolate b in terms of c: $\displaystyle b^2-4n=(c-b\pm\sqrt{c^2+4n})^2$

Solution: $\displaystyle b=\frac{c^2\pm c\sqrt{c^2+4n}+4n}{c\pm\sqrt{c^2+4n}}$

Simplify by multiplying by the conjugate: $\displaystyle b=\pm\sqrt{c^2+4n}$, or equivalently, $\displaystyle c=\pm\sqrt{b^2-4n}$

Substituting, $\displaystyle 2a=b+c$

A better way of expressing the solution is by finding b,c such that $\displaystyle b^2-c^2=4n$, and let $\displaystyle a=\frac12(b+c)$

For a to be an integer, $\displaystyle b+c$ must be even, so b,c must have the same parity (both even or both odd), so $\displaystyle b-c$ is even also.

An all-integer answer can thus be gotten: Given n, factor n, and find b,c satisfying $\displaystyle b^2-c^2=4n$, or $\displaystyle \frac{b+c}{2}\frac{b-c}{2}=n$. Define a as above.

This solution has the advantage of working for all $\displaystyle n\in\mathbb{Z}$ -- there are no restraints on n. Given a random n, the number of a,b,c solutions is equivalent to the number of unique ways to factor $\displaystyle n=xy$, WLOG $\displaystyle x\geq y$

Interestingly, a|n necessarily, so dividing through both equations by a, we arrive at the solution:

Given any integer n, choose a factor of n, a|n, and define b=a+n/a, c=a-n/a. We might have guessed at this solution from the start, but the preceding serves as a formal proof that it is the whole and only solution (aside from the trivial a=b=c=0, which works iff n=0).

5. Just wanted to point out what may be an error in HallsofIvy's post .... if you divide $\displaystyle 2a^2- a(b+c)= 0$ by $\displaystyle 2$, you get that $\displaystyle 2a- (b+c)= 0$, and NOT $\displaystyle a- (b+c)= 0$

6. Originally Posted by Bingk
Just wanted to point out what may be an error in HallsofIvy's post .... if you divide $\displaystyle 2a^2- a(b+c)= 0$ by $\displaystyle 2$, you get that $\displaystyle 2a- (b+c)= 0$, and NOT $\displaystyle a- (b+c)= 0$
You mean divide by $\displaystyle a$ surely ?

7. hahahaha ... yeah, by a