# Can $a^2+b^2+2ac$ be a perfect square if $c\neq \pm b$?

Can $a^2+b^2+2ac$ be a perfect square if $c\neq \pm b$?

$a,b,c \in \mathbb{Z}$.

Actual context of the question is:
Let say I have an quadratic equation $x^2+2xf(y)+25$ that I have to make a perfect square somehow. So can I conclude that $f(y)=\pm5$
$($i.e $x^2+2xf(y)+25$ is perfect square only if $f(y)=\pm5)$, or are there other possibilities for $f(y)$?

Note:$x$ and $y$ are not related in any other way.

-
Have you tried looking for counterexamples? – Cocopuffs Jul 9 '12 at 13:28
For example, if $a=1$ and $b$ is even, then by selecting an appropriate $c$ you can make $a^2+b^2+2ac$ any odd integer that you wish. Last time I checked there were more than 2 odd perfect squares, so the answer is YES (sorry, I misread the question the first time up). Meaning that you cannot make that conclusion. – Jyrki Lahtonen Jul 9 '12 at 14:42
Quantifiers are extremely important here! Are you saying that $a^2+b^2+2ac$ is a square for some $a$, or that $a^2+b^2+2ac$ is a square for all $a$? The former is what you ask in the title, but the context sounds like the latter. The two questions have very different outcomes, so please clarify what you mean. – Erick Wong Jul 9 '12 at 15:28

A small manipulation changes the problem into a more familiar one. We are interested in the Diophantine equation $a^2+b^2+2ac=y^2$. Complete the square. So our equation is equivalent to $(a+c)^2+b^2-c^2=y^2$. Write $x$ for $a+c$. Our equation becomes $$x^2+b^2=y^2+c^2.\tag{1}$$ In order to get rid of trivial solutions, let us assume that we are looking for solutions of the original equation in positive integers. Then $x=a+c\gt c$. The condition $b\ne c$ means that we are in essence trying to express integers as a sum of two squares in two different ways.

The smallest positive integer that is a sum of two distinct positive squares in two different ways is $65$, which is $8^2+1^2$ and also $7^2+4^2$. So we can take $x=a+c=8$, $b=1$, and $c=7$, giving the solution $a=1$, $b=1$, $c=7$. Or else we can take $c=4$, giving the solution $a=3$, $b=1$, $c=4$. Or else we can take $x=a+c=7$.

The next integer which is the sum of two distinct positive squares in two different ways is $85$. We can use the decompositions $85=9^2+2^2=7^2+6^2$ to produce solutions of our original equation.

General Theory: Suppose that we can express $m$ and $n$ as a sum of two squares, say $m=s^2+t^2$ and $n=u^2+v^2$. Then $$mn=(su\pm tv)^2+(sv\mp tu)^2.\tag{2}$$ Identity $(2)$ is a very important one, sometimes called the Brahmagupta Identity. It is connected, among other things, with the multiplication of complex numbers, and the sum identities for sine and cosine.

Identity $(2)$ can be used to produce infinitely many non-trivial solutions of Equation $(1)$, and therefore infinitely many solutions of our original equation. For example, any prime of the form $4k+1$ can be represented as a sum of two squares. By starting from two distinct primes $m$ and $n$ of this form, we can use Identity $(2)$ to get two essentially different representations of $mn$ as a sum of two squares, and hence solutions of our original equation.

-
$50=5^2+5^2=1^2+7^2$. – Marc van Leeuwen Sep 10 '12 at 15:37

You can always do $a^2=u^2+v$ for some $u,v\in\mathbb{Z}$, then $a^2+b^2+2ac=u^2+v+b^2+2ac=u^2+(2ac+v)+b^2$.

If $2ac+v = 2ub$, then its a perfect square.

The example given by Old John works cause we can write $6^2=4^2+20$, and $2\cdot 6\cdot 1 + 20= 2\cdot 4\cdot 4$. In this case, $u=4, v = 20$.

-

Just a short observation: we want

$$d^2=a^2+b^2+2ac=(a+b)^2-2ab+2ac$$

Write $d=a+b+e$ then we want

$$(a+b)^2+2ae+2be+e^2=(a+b)^2-2ab+2ac$$

or

$$c= \frac{2ae+2be+e^2+2ab}{2a}=e+b+\frac{2be+e^2}{2a}$$

This tells us that whenever $2a|2be+e^2$ we have a solution, in particular if $2a |e$ we get a solution.

If $e=2af$ then you get an infinite class of solutions by

$$a=a \,;\, b=b \,;\, c=2af+b+2bf2af^2 \,;\, a^2+b^2+2ac=(a+b+2af)^2$$

One can actually classify all the solutions in terms of $$\frac{2be+e^2}{2a} \in Z$$

-

Let $n\ge3$ be an odd integer. Then $$(n\,a+b)^2=n^2a^2+2\,n\,a\,b+b^2=a^2+b^2+2\,a\,c$$ with $$c=\frac{n^2-1}{2}\,a+n\,b\in\mathbb{Z}.$$

-

the equation: $y^2=a^2+b^2+2ac$

Has a solution:

$a=p^2-2(q+t)ps+q(q+2t)s^2$

$b=p^2+2(t-q)ps+(q^2-2t^2)s^2$

$c=p^2+2(q-t)ps-q^2s^2$

$y=2p^2-2(q+t)ps+2t^2s^2$

Has a solution:

$a=-p^2-2(q+t)ps+(8t^2-2qt-q^2)s^2$

$b=-p^2+2(5t-q)ps+(2t^2-8qt-q^2)s^2$

$c=-p^2+2(5q-t)ps+(8t^2-8qt-7q^2)s^2$

$y=2p^2-2(q+t)ps+(14t^2-8qt-4q^2)s^2$

$p,s,q,t$ - integers asked us.

-