Applications of the identity $ab + \left(\frac{a+b}{2} - b\right)^2 = \left(\frac{a+b}{2}\right)^2$ I am reading Euclid's elements
I found the algebraic identity
$ab + \left(\frac{a+b}{2} - b\right)^2 = \left(\frac{a+b}{2}\right)^2$
I ponder on usage of this identity for $2$ hours.
but I can't click anything.
$a^2 + b^2 = c^2$ can be used when you want to know the direction between $2$ coordinates.
Any example involving this identity?
 A: $\sqrt{ab}$ is the geometric mean of $a$ and $b$, and $\frac{a+b}{2}$ is the arithmetic mean. One thing your identity shows is that the arithmetic mean is always greater than or equal to the geometric mean:
$$(\text{geometric mean of $a$ and $b$})^2+\left(\frac{a-b}{2}\right)^2=(\text{arithmetic mean of $a$ and $b$})^2$$
You can see an important geometric application of this identity at the first bullet point here:

Your identity is just the Pythagorean theorem applied to the right triangle in the picture.
A: If I understand properly $$ab + \left(\frac{a+b}{2} - b\right)^2 =ab+\left(\frac{a-b}{2} \right)^2=\frac{1}{4} \Big(4ab+(a-b)^2\Big)=\frac{1}{4} (a+b)^2=\left(\frac{a+b}{2}\right)^2$$
A: You can use it to find all ways of writing $c=a^2-b^2$ with $a$ and $b$ positive natural numbers (or any two real numbers) for fixed $c$. To see this, your identity says:
$$ab=\left ( \frac{a+b}{2} \right )^{2} - \left ( \frac{a-b}{2} \right )^{2}$$
Now pick a number, $c=16$. Then we can factorize $c=2*8$
, so that $a=2$, $b=8$, giving $16=5^{2}-3^{2}$. This should be familiar as $3^{2}+4^{2}=5^{2}$.
We can find all solutions for fixed $c$. This trick relies on unique factorization and the fact that $(1,1)$ and $(1,-1)$ form a basis of $\mathbb{R}^{2}$. With a simple counting argument we give a formula for the number of solutions. If the prime factorization of $c$ is $2^{n_1}p_2^{n_2}...p_k^{n_k}$
$$N=\frac{1}{2}\left ( f(n_1)(n_2+1)(n_3+1)...(n_k+1)-g(c) \right )$$
Where $f(n_1)=n_1-1$ if $n_1>1$, and $1$ if $n_1=0$ and $g(c)=1$ if $c$ is a square, $0$ otherwise.
A: Since you found the identity in Euclid's Elements, the obvious thing to ask perhaps is what did Euclid use it for? The identity appears early in Book II (5th proposition) as part of the development of a theory of areas of plane figures that began in Book I. In this theory of areas, the area of the square is taken as axiomatic. To find the area of a non-square figure in Euclidean geometry, one must construct the square of equal area. For example, to find the sum of the areas of two squares with areas $a^2$ and $b^2$, you must construct the single square of area $c^2=a^2+b^2$. The Pythagorean theorem, which is the culmination of Book I, tells you how to construct that square.
Likewise, the purpose of Proposition 5 in Book II is aimed at the problem of "squaring the rectangle". Specifically, given a rectangle it constructs equi-areal difference of squares:
$$ab = \left(\frac{a+b}{2}\right)^2 - \left(\frac{a+b}{2} - b\right)^2.$$
The Pythagorean theorem completes the job by telling you how to write a difference of squares as a single square. This is the jist of the proof of Proposition 14, which is the culmination of Book II.
A: This is a very clumsy form of the most useful identity $$(a+b)^2-(a-b)^2=4ab,$$ which relates the three most elementary binary operations.
It is very useful in many guises. One is to solve quadratic equations. One important application is to solve generally the Diophantine equation $x^2+y^2=z^2$ for integers $x,y,z.$
It comes up most other times than I can list here. But the most important thing is that it links sums, differences and products -- nothing could be more amazing!
A: This identity can be rewritten as $$(a-b)^2=(a+b)^2-4ab$$ and, is the secret behind the discriminant of a quadratic equation. Let me explain it. Suppose $Ax^2+Bx+C=0$ is a quadratic equation with real coefficients, then its roots must occur as complex conjugate pairs. If we have two complex roots $a, b$ for this equation, then there are real $\alpha, \beta$ such that $a,b=\alpha\pm i\beta.$  Clearly, $$a-b=2i\beta,\qquad a+b=2\alpha=-\dfrac{B}{A},\qquad ab=\alpha^2+\beta^2=\dfrac{C}{A}.$$ Hence we have $$(a-b)^2=-4\beta^2=\dfrac{B^2-4AC}{A^2}.$$ Since $\beta^2\gt 0$ we have $$\Delta=A^2(a-b)^2=B^2-4AC\lt0.$$ Other two cases follows similarly. 
A: This equation can be rewritten as $$ab=\frac{(a+b)^2}4-\frac{(a-b)^2}4.$$ This is the basis of tables of quarter-squares. Such a table tabulated $\left\lfloor \frac{n^2}4\right\rfloor$ for various integer values $n$. It was used as an aid to multiplying integers. To find $ab$, look up the quarter-squares of $a+b$ and $a-b$, then subtract.
If $a$ and $b$ have different parities, $a+b$ and $a-b$ are both odd, so the tabulated quarter-squares are too low by a quarter, but those quarters cancel.
