# Finding the common integer solutions to $a + b = c \cdot d$ and $a \cdot b = c + d$

I find nice that $$1+5=2 \cdot 3 \qquad 1 \cdot 5=2 + 3 .$$

Do you know if there are other integer solutions to $$a+b=c \cdot d \quad \text{ and } \quad a \cdot b=c+d$$ besides the trivial solutions $a=b=c=d=0$ and $a=b=c=d=2$?

• One has the family $(a, b, c, d) = (-t + 1, -1, t, -1)$ parameterized by $t \in \Bbb Z$. Of course, given a solution $(a, b, c, d)$, $(b, a, c, d)$ and $(c, d, a, b)$ are also solutions, and these generate other symmetries, too. Jan 5, 2016 at 1:33
• Are there any other solutions in positive integers? We need $c^2 d^2-4(c+d)$ to be the square of a positive integer. Jan 5, 2016 at 2:02
• @user254665 A now-deleted answer essentially resolved the question for the case $a, b, c, d \geq 0$: One could conclude quickly from it that the only such solutions are the ones OP mentions and the appropriate permutations. Jan 5, 2016 at 2:05

Here's a solution when $a$, $b$, $c$, and $d$ are positive; I'm not sure how to tackle the more general problem though (although something tells me it's probably similar).

Note that substituting $b=cd-a$ into the second equation yields $$a(cd-a)=c+d\implies a^2-cad+c+d=0.$$ By the Quadratic Formula on $a$, we have $$a=\dfrac{cd\pm\sqrt{(cd)^2-4(c+d)}}2.$$ This can only be an integer when $(cd)^2-4(c+d)$ is a perfect square.

Note that since $(cd)^2-4(c+d)\equiv (cd)^2\pmod 2$, we have $$(cd)^2-4(c+d)\leq(cd-2)^2.$$ This rearranges to $$-4(c+d)\leq -4cd+4\implies 2\geq (c-1)(d-1).$$ This is great news, because it means we actually don't have many cases to check!

CASE 1: $c=1$ (or $d=1$, for that matter).

Plugging back in, we see that for some integer $K$ we have $$d^2-4(d+1)=(d-2)^2-8=K^2.$$ The only case that works here is $d=5$ (since $d=6$ fails and past that point perfect squares differ by at least $9$). By symmetry, $c=5$, $d=1$ also works.

CASE 2: $c=2$ and $d\leq 3$.

Plugging back in to the original expression, we need $$(2d)^2-4(2+d)=(2d-1)^2-9$$ to be a perfect square. Trial and error works since $d$ is small, but here $d=2$ and $d=3$ both work.

CASE 3: $c=3$ and $d=2$.

Oh look, we've already shown this works! (We don't need to check $d=1$ because that was already covered in Case 1.)

Hence the only possible pairs for $(c,d)$ are $(2,3)$, $(2,2)$, $(5,1)$, arrangements. By a similar argument, we see that the same exact possible pairs are the only possible ones for $(a,b)$ as well.

From here, it's not hard to see that $(a,b,c,d)=\boxed{(2,2,2,2),(2,3,5,1)}$ and permutations are the only possible solutions for $a,b,c,d>0$.

• The reason this solution fails for $a,b,c,d<0$ is because then we can't conclude $(cd)^2-4(c+d)\leq(cd-2)^2$. However, it seems likely that under $c+d\leq 0$ we can say $(cd)^2-4(c+d)\geq(cd+2)^2$ and go from there. Jan 5, 2016 at 2:15
• Could you explain a bit more why $(cd)^2 - 4(c+d) \leq (cd-2)^2$?
– A.P.
Jan 5, 2016 at 2:33
• We know that $(cd)^2-4(c+d)$ has to be a perfect square; the next smallest perfect square is $(cd-1)^2$, so it has to be at most that. But it can't actually be $(cd-1)^2$ for parity reasons - either the LHS is even and the RHS is odd or vice versa. Hence the largest perfect square it could possibly be is $(cd-2)^2$. Jan 5, 2016 at 3:07
• Again, this assumes $c+d>0$ - in the more general case, we have to probably work with different bounds. Jan 5, 2016 at 3:09

First, note that if $(a, b, c, d)$ is a solution, so are $(a, b, d, c)$, $(c, d, a, b)$ and the five other reorderings these permutations generate.

We can quickly dispense with the case that all of $a, b, c, d$ are positive using an argument of @dREaM: If none of the numbers is $1$, we have $ab \geq a + b = cd \geq c + d = ab$, so $ab = a + b$ and $cd = c + d$, and we may as well assume $a \geq b$ and $c \geq d$. In particular, since $a, b, c, d > 1$, we have $a b \geq 2a \geq a + b = ab$, so $a = b = 2$ and likewise $c = d = 2$, giving the solution $$(2, 2, 2, 2).$$ On the other hand, if at least one number is $1$, say, $a$, we have $b = c + d$ and $1 + b = cd$, so $1 + c + d = cd$, and we may as well assume $c \leq d$. Rearranging gives $(c - 1)(d - 1) = 2$, so the only solution is $c = 2, d = 3$, giving the solution $$(1, 5, 2, 3).$$

Now suppose that at least one of $a, b, c, d$, say, $a$ is $0$. Then, we have $0 = c + d$ and $b = cd$, so $c = -d$ and $b = -d^2$. This gives the solutions $$A_s := (0, -s^2, -s, s), \qquad s \in \Bbb Z .$$

We are left with the case for which at least one of $a, b, c, d$, say, $a$, is negative, and none is $0$. Suppose first that none of the variables is $-1$. If $b < 0$, we must have $cd = a + b < 0$, and so we may assume $c > 0 > d$. On the other hand, $c + d = ab > 0$, and so (using a variation of the argument for the positive case) we have $$ab = (-a)(-b) \geq (-a) + (-b) = -(a + b) = -cd \geq c > c + d = ab,$$ which is absurd. If $b > 0$, we have $c + d = ab < 0$, so at least one of $c, d$, say, $c$ is negative. Moreover, we have $cd = a + b$, so $d$ and $a + b$ have opposite signs. If $d < 0$, then since $c, d < 0$, we are, by exploiting the appropriate permutation, in the above case in which $a, b < 0$, so we may assume that $d > 0$, and hence that $a + b < 0$. Now, $$ab \leq a + b = cd < c + d = ab,$$ which again is absurd, so there no solutions in this case. This leaves only the case in which at least one of $a, b, c, d$ is $-1$, say, $a$. Then, we have $-b = c + d$ and $-1 + b = cd$, so $-1 + (- c - d) = cd$. Rearranging gives $(c + 1)(d + 1) = 0$, so we may assume $c = -1$ giving (up to permtuation) the $1$-parameter family of solutions $$B_t := (-1, t, -1, 1 - t), \qquad t \in \Bbb Z,$$ I mentioned in my comment (this includes two solutions, $B_0$ and $B_1$, which are equivalent by a permutation, that include a zero entry). This exhausts all of the possibilities; in summary:

Any integer solution to the system $$\left\{\begin{array}{rcl}a + b \!\!\!\!& = & \!\!\!\! cd \\ ab \!\!\!\! & = & \!\!\!\! c + d \end{array}\right.$$ is equal (up to the admissible permutations mentioned at the beginning of this answer) to exactly one of

• $(1, 5, 2, 3)$
• $(2, 2, 2, 2)$
• $A_s := (0, -s^2, -s, s)$, $s \geq 0$, and
• $B_t := (-1, t, -1, 1 - t)$, $t \geq 2$.

The restrictions on the parameters $s, t$ are consequences of the redundancy in the solutions we found: $A_{-s}$ is an admissible permutation of $A_s$, $B_{1 - t}$ an admissible permutation of $B_t$, and $B_1$ one of $A_1$.

I found that, through solving the equations, we will have following (if a>b):

$$a=\frac{cd+\sqrt{c^2d^2-4(c+d)}}{2}$$ and $$b=\frac{cd-\sqrt{c^2d^2-4(c+d)}}{2}$$ I think it will be useful for you to find all of the solutions. Only you should find the solutions for: $$c^2d^2-4(c+d)=m^2$$ where $m$ is any positive integer.