Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

$a,b,c \in \mathbb{Z}$.
I have tried some manipulations but still came up with nothing. Please help.

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.

share|cite|improve this question
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
up vote 12 down vote accepted

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.

share|cite|improve this answer
$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$.

share|cite|improve this answer

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



$$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$$

share|cite|improve this answer

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}. $$

share|cite|improve this answer

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

Has a solution:





Has a solution:





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

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.