Binomial Squared: the geometric proof of (a+b)² = a² + 2ab + b²

Understand why (a + b)² = a² + 2ab + b² with interactive geometric gadgets, algebraic proof, Vieta's formulas, factoring and 12 worked examples.

Almost everyone memorizes $(a + b)^2 = a^2 + 2ab + b^2$ in school — and, in a hurry, writes $(a + b)^2 = a^2 + b^2$, dropping the $2ab$ term. Once you see this identity as the area of a square split into four pieces, that mistake practically vanishes: you cannot overlook the two rectangles that complete the figure.

In this post, we walk through the geometric proof (which already appears in Euclid’s Elements, Book II, Proposition 4) with interactive gadgets, the algebraic proof valid for all real numbers, the classic problem of finding $a^3 + b^3$ from $a + b$ and $a^2 + b^2$, the link between special products, factoring, and Vieta’s formulas (Girard’s relations), 12 step-by-step worked examples, checks in Julia, R, and Python, and formal Lean proofs (provas/Provas/ProdutosNotaveis.lean).


1. The geometric idea (for $a > 0$ and $b > 0$)

Imagine two positive lengths $a > 0$ and $b > 0$, laid end to end to form a segment of length $a + b$. Building a square of side $a + b$ gives a total area of $(a + b)^2$.

Split that square into four regions with one vertical cut and one horizontal cut at the boundary between $a$ and $b$:

  • one square of side $a$, with area $a^2$;
  • one square of side $b$, with area $b^2$;
  • two rectangles of sides $a$ and $b$, each with area $ab$.

Because the four pieces cover the whole square without overlap, the total area is the sum of the four areas:

\[(a + b)^2 = a^2 + ab + ab + b^2 = a^2 + 2ab + b^2.\]

Interactive gadget

Move the sliders below to change $a$ and $b$ and watch the total area and all four pieces update together:

$(a + b)^2 = a^2 + 2ab + b^2$
square of side (a + b)

2. Algebraic proof (for all real numbers)

The geometric proof assumes $a > 0$ and $b > 0$ because lengths and areas are positive. The algebraic identity, however, holds for any real numbers $a$ and $b$ — positive, negative, or zero (in fact, in any commutative ring; proved in Lean in provas/Provas/ProdutosNotaveis.lean).

By the definition of squaring and the distributive law:

\[\begin{aligned} (a + b)^2 &= (a + b)(a + b) \\ &= a(a + b) + b(a + b) \\ &= a^2 + ab + ba + b^2. \end{aligned}\]

Because multiplication of real numbers is commutative ($ab = ba$), the two middle terms combine: $ab + ba = ab + ab = 2ab$. Therefore:

\[(a + b)^2 = a^2 + 2ab + b^2.\]

3. Where the identity appears in Calculus

The square of a binomial shows up constantly when simplifying expressions, computing derivatives from the definition, and setting up integrals (the algebraic identities below are proved in Lean):

Situation Application
Completing the square $x^2 + 6x = (x + 3)^2 - 9$
Factoring $x^2 + 2x + 1 = (x + 1)^2$
Limits and difference quotient $\lim_{h \to 0}\dfrac{(x + h)^2 - x^2}{h} = \lim_{h \to 0}(2x + h) = 2x$
Integrals $\int (x + 1)^2\,dx = \int (x^2 + 2x + 1)\,dx = \dfrac{x^3}{3} + x^2 + x + C$

4. Worked exercise (step by step)

Problem: given $a + b = 1$ and $a^2 + b^2 = 2$ (with $a, b \in \mathbb{R}$), compute $a^3 + b^3$.

Notice that we do not need to find $a$ and $b$ individually. Combining two special products — the square of a sum and the cube of a sum — is enough (the complete result is proved in Lean).

Step 1: find the product $ab$

Start from $(a + b)^2 = a^2 + b^2 + 2ab$.

  • Given: $a + b = 1$ and $a^2 + b^2 = 2$.
  • Substitution:
\[\begin{aligned} (1)^2 &= 2 + 2ab \\ 1 &= 2 + 2ab. \end{aligned}\]
  • Solving for $ab$: subtract $2$ from both sides and divide by $2$:
\[\begin{aligned} 1 - 2 &= 2ab \\ -1 &= 2ab \\ ab &= -\frac{1}{2}. \end{aligned}\]

Step 2: write $a^3 + b^3$ in terms of $a + b$ and $ab$

Expand the cube of a sum $(a + b)^3 = (a + b)(a + b)^2$ (proved in Lean):

\[\begin{aligned} (a + b)^3 &= (a + b)(a^2 + 2ab + b^2) \\ &= a(a^2 + 2ab + b^2) + b(a^2 + 2ab + b^2) \\ &= (a^3 + 2a^2b + ab^2) + (a^2b + 2ab^2 + b^3) \\ &= a^3 + 3a^2b + 3ab^2 + b^3. \end{aligned}\]

Factor $3ab$ out of the two middle terms: $3a^2b + 3ab^2 = 3ab(a + b)$, so:

\[(a + b)^3 = a^3 + b^3 + 3ab(a + b).\]

Subtract $3ab(a + b)$ from both sides:

\[a^3 + b^3 = (a + b)^3 - 3ab(a + b).\]

Step 3: substitute the known values

Using $a + b = 1$ (given) and $ab = -\dfrac{1}{2}$ (from Step 1):

\[\begin{aligned} a^3 + b^3 &= (1)^3 - 3\!\left(-\frac{1}{2}\right)(1) \\ &= 1 + \frac{3}{2} \\ &= \frac{2}{2} + \frac{3}{2} = \frac{5}{2} = 2.5. \end{aligned}\]

Step 4: checking with Vieta’s formulas (Girard’s relations)

If $a$ and $b$ are the roots of a monic polynomial of degree $2$ (leading coefficient $1$), it factors as:

\[(x - a)(x - b) = x^2 - (a + b)x + ab = 0.\]

Comparing with $x^2 + px + q = 0$ yields Vieta’s formulas (also known as Girard’s relations; proved in Lean):

\[a + b = -p \quad \text{(sum of roots)}, \qquad ab = q \quad \text{(product of roots)}.\]

Substituting $a + b = 1$ and $ab = -\dfrac{1}{2}$, the polynomial whose roots are $a$ and $b$ is:

\[x^2 - x - \frac{1}{2} = 0.\]

(Note that its discriminant is $\Delta = (-1)^2 - 4(1)(-1/2) = 1 + 2 = 3 > 0$, confirming that two real numbers $a = \frac{1 + \sqrt{3}}{2}$ and $b = \frac{1 - \sqrt{3}}{2}$ indeed satisfy the problem.)

Isolate $x^2$ in the equation and multiply both sides by $x$:

\[x^2 = x + \frac{1}{2} \implies x^3 = x^2 + \frac{x}{2}.\]

Since this holds for both $x = a$ and $x = b$, add the two equations:

\[a^3 + b^3 = \left(a^2 + \frac{a}{2}\right) + \left(b^2 + \frac{b}{2}\right) = (a^2 + b^2) + \frac{a + b}{2} = 2 + \frac{1}{2} = \frac{5}{2}.\]

Both methods agree on $\dfrac{5}{2}$.


5. Special products, factoring, and Vieta’s formulas: the cycle

These three tools form a single cycle: special products expand, factoring reverses the expansion, and Vieta’s formulas show how the roots sit inside the coefficients.

  1. Special products (factored to expanded form): fixed-pattern products, proved in Lean for all real numbers:
\[\begin{aligned} (a + b)^2 &= a^2 + 2ab + b^2, \\ (a - b)^2 &= a^2 - 2ab + b^2, \\ (a + b)(a - b) &= a^2 - b^2. \end{aligned}\]
  1. Factoring (the reverse direction): given an expanded polynomial, find factors whose product reproduces it — for instance, $x^2 - 5x + 6 = (x - 2)(x - 3)$.
  2. Vieta’s formulas (the bridge): in a monic quadratic $x^2 + px + q$, the coefficients directly encode the sum and product of the roots ($r_1 + r_2 = -p$ and $r_1 r_2 = q$). Factoring as $(x - r_1)(x - r_2)$ and expanding by distribution brings back $x^2 - (r_1 + r_2)x + r_1 r_2 = x^2 + px + q$.

6. Worked examples: special products

Example 1 — Square of a sum: $(x + 3)^2$

Apply $(a + b)^2 = a^2 + 2ab + b^2$ with $a = x$ and $b = 3$:

\[(x + 3)^2 = x^2 + 2 \cdot x \cdot 3 + 3^2 = x^2 + 6x + 9.\]
$(x + 3)^2 = x^2 + 6x + 9$
square of side (x + 3)

Example 2 — Square of a difference: $(2x - 5)^2$

Apply $(a - b)^2 = a^2 - 2ab + b^2$ with $a = 2x$ and $b = 5$:

\[(2x - 5)^2 = (2x)^2 - 2 \cdot (2x) \cdot 5 + 5^2 = 4x^2 - 20x + 25.\]

For the area visualization below, we use $x \geq 3$ so the remaining side $2x - 5$ stays positive (the algebraic identity holds for every $x \in \mathbb{R}$):

$(2x - 5)^2 = 4x^2 - 20x + 25$
outer square of side 2x (for x ≥ 3)

Example 3 — Product of sum and difference: $(x + 7)(x - 7)$

Apply $(a + b)(a - b) = a^2 - b^2$ with $a = x$ and $b = 7$:

\[(x + 7)(x - 7) = x^2 - 7^2 = x^2 - 49.\]

To visualize the difference of areas below, we use $x \geq 8$ so the $7 \times 7$ corner fits inside the $x \times x$ square:

$(x + 7)(x - 7) = x^2 - 49$
square x² minus 7² corner (red)

Example 4 — Cube of a sum: $(x + 2)^3$

Expand using $(a + b)^3 = a^3 + 3a^2b + 3ab^2 + b^3$ with $a = x$ and $b = 2$:

\[(x + 2)^3 = x^3 + 3 \cdot x^2 \cdot 2 + 3 \cdot x \cdot 2^2 + 2^3 = x^3 + 6x^2 + 12x + 8.\]
$(x + 2)^3 = x^3 + 6x^2 + 12x + 8$

Example 5 — Difference of conjugate squares: $(3x + 1)^2 - (3x - 1)^2$

Expand each square separately:

\[\begin{aligned} (3x + 1)^2 &= 9x^2 + 6x + 1, \\ (3x - 1)^2 &= 9x^2 - 6x + 1. \end{aligned}\]

Subtract carefully, distributing the minus sign across the entire second parenthesis:

\[\begin{aligned} (3x + 1)^2 - (3x - 1)^2 &= (9x^2 + 6x + 1) - (9x^2 - 6x + 1) \\ &= 9x^2 + 6x + 1 - 9x^2 + 6x - 1 \\ &= 12x. \end{aligned}\]

(This is a special case of $(a + b)^2 - (a - b)^2 = 4ab$, proved in Lean, with $a = 3x$ and $b = 1$: $4 \cdot 3x \cdot 1 = 12x$.)

$(3x + 1)^2 - (3x - 1)^2 = 12x$
−
=
= 12x

7. Worked examples: algebraic factoring

All seven factorizations below are proved in Lean (provas/Provas/ProdutosNotaveis.lean).

Example 6 — Greatest common factor: $6x^2 + 9x$

The greatest common factor of $6x^2 = 3x \cdot 2x$ and $9x = 3x \cdot 3$ is $3x$:

\[6x^2 + 9x = 3x \cdot 2x + 3x \cdot 3 = 3x(2x + 3).\]

Check: $3x \cdot 2x + 3x \cdot 3 = 6x^2 + 9x$.

Example 7 — Perfect square trinomial: $x^2 + 10x + 25$

Match the pattern $a^2 + 2ab + b^2$ with $a = x$ and $b = 5$, checking the middle term ($2ab = 2 \cdot x \cdot 5 = 10x$) and the constant ($b^2 = 5^2 = 25$):

\[x^2 + 10x + 25 = (x + 5)^2.\]

Example 8 — Difference of squares: $4x^2 - 49$

Match $a^2 - b^2$ with $a = 2x$ (since $(2x)^2 = 4x^2$) and $b = 7$ (since $7^2 = 49$):

\[4x^2 - 49 = (2x + 7)(2x - 7).\]

Example 9 — General monic trinomial: $x^2 - 7x + 12$

By Vieta’s formulas, look for $r_1$ and $r_2$ with $r_1 + r_2 = 7$ and $r_1 \cdot r_2 = 12$:

Pair $(r_1, r_2)$ Sum $r_1 + r_2$ Product $r_1 \cdot r_2$
$1$ and $12$ $13$ $12$
$2$ and $6$ $8$ $12$
$3$ and $4$ $7$ $12$

So $r_1 = 3$ and $r_2 = 4$, giving:

\[x^2 - 7x + 12 = (x - 3)(x - 4).\]

Check: $(x - 3)(x - 4) = x^2 - 4x - 3x + 12 = x^2 - 7x + 12$.

Example 10 — Non-monic trinomial ($a \neq 1$): $2x^2 + 7x + 3$

Use the $ac$-method: $a \cdot c = 2 \cdot 3 = 6$. Look for two numbers with sum $7$ (the $x$-coefficient) and product $6$: they are $1$ and $6$. Split $7x = x + 6x$ and factor by grouping:

\[\begin{aligned} 2x^2 + 7x + 3 &= 2x^2 + x + 6x + 3 \\ &= x(2x + 1) + 3(2x + 1) \\ &= (2x + 1)(x + 3). \end{aligned}\]

Check: $(2x + 1)(x + 3) = 2x^2 + 6x + x + 3 = 2x^2 + 7x + 3$.

Example 11 — Sum of cubes: $x^3 + 8$

Apply the sum-of-cubes identity $a^3 + b^3 = (a + b)(a^2 - ab + b^2)$ (proved in Lean) with $a = x$ and $b = 2$ ($2^3 = 8$):

\[x^3 + 8 = x^3 + 2^3 = (x + 2)(x^2 - 2x + 4).\]

Check: $(x + 2)(x^2 - 2x + 4) = x^3 - 2x^2 + 4x + 2x^2 - 4x + 8 = x^3 + 8$.

Example 12 — Two-step factoring: $3x^3 - 12x$

  1. Common factor: pull out $3x$: $3x^3 - 12x = 3x(x^2 - 4)$.
  2. Difference of squares: $x^2 - 4 = (x + 2)(x - 2)$.
\[3x^3 - 12x = 3x(x + 2)(x - 2).\]

8. Checking on a computer (Julia, R, and Python)

The block below tests $(a + b)^2 = a^2 + 2ab + b^2$ on negative numbers too (where the area diagram no longer applies), measures the error of dropping $2ab$, and verifies the Section 4 exercise directly on the exact roots $a = \frac{1 + \sqrt{3}}{2}$ and $b = \frac{1 - \sqrt{3}}{2}$.

Julia
using Printf

# 1) (a + b)² = a² + 2ab + b² holds for all reals (including negatives)
println("1) Identity (a + b)² vs. a² + 2ab + b² and the error without 2ab:")
for (a, b) in ((5.0, 3.0), (1.5, 1.5), (-4.0, 2.5))
    lhs  = (a + b)^2
    rhs  = a^2 + 2a*b + b^2
    miss = a^2 + b^2
    @printf("   a = %4.1f, b = %3.1f -> (a+b)² = %6.2f,  a²+2ab+b² = %6.2f,  only a²+b² = %6.2f (missing 2ab = %6.2f)\n",
            a, b, lhs, rhs, miss, 2a*b)
end

# 2) Direct check of the worked exercise: roots of x² - x - 1/2 = 0
a = (1 + sqrt(3)) / 2
b = (1 - sqrt(3)) / 2
println("\n2) Exact roots of x² - x - 1/2 = 0:")
@printf("   a = %.6f,  b = %.6f\n", a, b)
@printf("   a + b   = %.4f  (given: 1)\n", a + b)
@printf("   a² + b² = %.4f  (given: 2)\n", a^2 + b^2)
@printf("   a * b   = %.4f  (found: -1/2 = -0.5)\n", a * b)
@printf("   a³ + b³ = %.4f  (found:  5/2 =  2.5)\n", a^3 + b^3)
# Output
1) Identity (a + b)² vs. a² + 2ab + b² and the error without 2ab:
   a =  5.0, b = 3.0 -> (a+b)² =  64.00,  a²+2ab+b² =  64.00,  only a²+b² =  34.00 (missing 2ab =  30.00)
   a =  1.5, b = 1.5 -> (a+b)² =   9.00,  a²+2ab+b² =   9.00,  only a²+b² =   4.50 (missing 2ab =   4.50)
   a = -4.0, b = 2.5 -> (a+b)² =   2.25,  a²+2ab+b² =   2.25,  only a²+b² =  22.25 (missing 2ab = -20.00)

2) Exact roots of x² - x - 1/2 = 0:
   a = 1.366025,  b = -0.366025
   a + b   = 1.0000  (given: 1)
   a² + b² = 2.0000  (given: 2)
   a * b   = -0.5000  (found: -1/2 = -0.5)
   a³ + b³ = 2.5000  (found:  5/2 =  2.5)
R
# 1) (a + b)² = a² + 2ab + b² holds for all reals (including negatives)
pairs <- list(c(5.0, 3.0), c(1.5, 1.5), c(-4.0, 2.5))
cat("1) Identity (a + b)² vs. a² + 2ab + b² and the error without 2ab:\n")
for (p in pairs) {
  a <- p[1]; b <- p[2]
  lhs  <- (a + b)^2
  rhs  <- a^2 + 2 * a * b + b^2
  miss <- a^2 + b^2
  cat(sprintf("   a = %4.1f, b = %3.1f -> (a+b)² = %6.2f,  a²+2ab+b² = %6.2f,  only a²+b² = %6.2f (missing 2ab = %6.2f)\n",
              a, b, lhs, rhs, miss, 2 * a * b))
}

# 2) Direct check of the worked exercise: roots of x² - x - 1/2 = 0
a <- (1 + sqrt(3)) / 2
b <- (1 - sqrt(3)) / 2
cat("\n2) Exact roots of x² - x - 1/2 = 0:\n")
cat(sprintf("   a = %.6f,  b = %.6f\n", a, b))
cat(sprintf("   a + b   = %.4f  (given: 1)\n", a + b))
cat(sprintf("   a² + b² = %.4f  (given: 2)\n", a^2 + b^2))
cat(sprintf("   a * b   = %.4f  (found: -1/2 = -0.5)\n", a * b))
cat(sprintf("   a³ + b³ = %.4f  (found:  5/2 =  2.5)\n", a^3 + b^3))
# Output
1) Identity (a + b)² vs. a² + 2ab + b² and the error without 2ab:
   a =  5.0, b = 3.0 -> (a+b)² =  64.00,  a²+2ab+b² =  64.00,  only a²+b² =  34.00 (missing 2ab =  30.00)
   a =  1.5, b = 1.5 -> (a+b)² =   9.00,  a²+2ab+b² =   9.00,  only a²+b² =   4.50 (missing 2ab =   4.50)
   a = -4.0, b = 2.5 -> (a+b)² =   2.25,  a²+2ab+b² =   2.25,  only a²+b² =  22.25 (missing 2ab = -20.00)

2) Exact roots of x² - x - 1/2 = 0:
   a = 1.366025,  b = -0.366025
   a + b   = 1.0000  (given: 1)
   a² + b² = 2.0000  (given: 2)
   a * b   = -0.5000  (found: -1/2 = -0.5)
   a³ + b³ = 2.5000  (found:  5/2 =  2.5)
Python
import math

# 1) (a + b)² = a² + 2ab + b² holds for all reals (including negatives)
print("1) Identity (a + b)² vs. a² + 2ab + b² and the error without 2ab:")
for a, b in ((5.0, 3.0), (1.5, 1.5), (-4.0, 2.5)):
    lhs  = (a + b) ** 2
    rhs  = a**2 + 2 * a * b + b**2
    miss = a**2 + b**2
    print(f"   a = {a:4.1f}, b = {b:3.1f} -> (a+b)² = {lhs:6.2f},  a²+2ab+b² = {rhs:6.2f},  only a²+b² = {miss:6.2f} (missing 2ab = {2*a*b:6.2f})")

# 2) Direct check of the worked exercise: roots of x² - x - 1/2 = 0
a = (1 + math.sqrt(3)) / 2
b = (1 - math.sqrt(3)) / 2
print("\n2) Exact roots of x² - x - 1/2 = 0:")
print(f"   a = {a:.6f},  b = {b:.6f}")
print(f"   a + b   = {a + b:.4f}  (given: 1)")
print(f"   a² + b² = {a**2 + b**2:.4f}  (given: 2)")
print(f"   a * b   = {a * b:.4f}  (found: -1/2 = -0.5)")
print(f"   a³ + b³ = {a**3 + b**3:.4f}  (found:  5/2 =  2.5)")
# Output
1) Identity (a + b)² vs. a² + 2ab + b² and the error without 2ab:
   a =  5.0, b = 3.0 -> (a+b)² =  64.00,  a²+2ab+b² =  64.00,  only a²+b² =  34.00 (missing 2ab =  30.00)
   a =  1.5, b = 1.5 -> (a+b)² =   9.00,  a²+2ab+b² =   9.00,  only a²+b² =   4.50 (missing 2ab =   4.50)
   a = -4.0, b = 2.5 -> (a+b)² =   2.25,  a²+2ab+b² =   2.25,  only a²+b² =  22.25 (missing 2ab = -20.00)

2) Exact roots of x² - x - 1/2 = 0:
   a = 1.366025,  b = -0.366025
   a + b   = 1.0000  (given: 1)
   a² + b² = 2.0000  (given: 2)
   a * b   = -0.5000  (found: -1/2 = -0.5)
   a³ + b³ = 2.5000  (found:  5/2 =  2.5)

9. What goes wrong in practice (common pitfalls)

  1. Dropping the $2ab$ term: for real numbers $a$ and $b$, $(a + b)^2 = a^2 + b^2$ holds if and only if $a = 0$ or $b = 0$ (proved in Lean). Whenever both are non-zero, omitting $2ab$ misses the true answer by exactly $2ab$: for instance, $(3 + 4)^2 = 49$, whereas $3^2 + 4^2 = 25$ (off by $2 \cdot 3 \cdot 4 = 24$).
  2. Flipping the sign of $b^2$ in $(a - b)^2$: the final term is $+b^2$, never $-b^2$, because $(-b)^2 = +b^2$. Thus $(x - 3)^2 = x^2 - 6x + 9$, not $x^2 - 6x - 9$.
  3. Forgetting to square the coefficient: in $(2x - 5)^2$, the leading term is $(2x)^2 = 4x^2$, not $2x^2$.
  4. Distributing a leading minus sign only halfway: in $(3x + 1)^2 - (3x - 1)^2$, the minus sign before the second parenthesis flips the sign of every term inside ($-9x^2 + 6x - 1$).
  5. Trying to factor a sum of squares over the reals: $x^2 - 49 = (x + 7)(x - 7)$ factors cleanly, but $x^2 + 49$ does not factor into degree-$1$ real polynomials (since $x^2 + 49 \geq 49 > 0$ for every $x \in \mathbb{R}$).

10. Summary

  • Square of a sum: $(a + b)^2 = a^2 + 2ab + b^2$. For $a, b > 0$, it is the sum of four areas inside a square of side $a + b$; by distribution, it holds for all $a, b \in \mathbb{R}$.
  • Companion identities: $(a - b)^2 = a^2 - 2ab + b^2$, $(a + b)(a - b) = a^2 - b^2$, and $(a + b)^3 = a^3 + 3a^2b + 3ab^2 + b^3$.
  • The algebra cycle: special products expand, factoring reverses, and Vieta’s formulas ($r_1 + r_2 = -p$, $r_1 r_2 = q$ for $x^2 + px + q$) link coefficients and roots.
  • Classic trap: $(a + b)^2 = a^2 + b^2$ happens only when $a = 0$ or $b = 0$.

11. References

  • Euclid. The Thirteen Books of Euclid’s Elements, Vol. 1 (trans. and commentary by T. L. Heath). 2nd ed., Dover Publications, 1956. (Book II, Proposition 4: geometric version of $(a + b)^2 = a^2 + 2ab + b^2$.)
  • Girard, A. (1629). Invention nouvelle en l’algèbre. Willem Blaeu, Amsterdam. (Relations between polynomial roots and coefficients, and power sums of roots.)
  • Lima, E. L., Carvalho, P. C. P., Wagner, E., & Morgado, A. C. (2016). A Matemática do Ensino Médio, Vol. 1. 11th ed. Sociedade Brasileira de Matemática (SBM). (In Portuguese.)
  • Stewart, J. (2016). Calculus: Early Transcendentals. 8th ed. Cengage Learning.

Comments