a² + b² Formula — Proof, Expansion, Examples

#Math Formula
TL;DR
The a square plus b square formula says $a^2 + b^2 = (a + b)^2 - 2ab$ or equivalently $a^2 + b^2 = (a - b)^2 + 2ab$. This article gives the formula, both proofs, three worked examples spanning Quick to Stretch, the direct link to the Pythagorean theorem, and the common mistakes students make when handling sums of two squares.
BT
Bhanzu TeamLast updated on June 1, 20268 min read

A Formula That Shows Up Wherever Distances Do

Every time you measure the diagonal of a rectangle, the hypotenuse of a right triangle, or the magnitude of a 2D vector, this identity is doing the work.

The a square plus b square formula rewrites a sum of two squares in two equivalent ways:

$$a^2 + b^2 = (a + b)^2 - 2ab = (a - b)^2 + 2ab.$$

Both forms are useful — pick whichever matches the data you have.

The Formula

For any real numbers $a$ and $b$:

$$\boxed{;a^2 + b^2 = (a + b)^2 - 2ab;}$$

Equivalently:

$$a^2 + b^2 = (a - b)^2 + 2ab.$$

Quick facts.

  • Type: algebraic identity (true for all real $a, b$).

  • Reads as: "sum of squares equals the square of the sum minus twice the product."

  • Grade introduced: CCSS-M HSA-SSE.A.2; NCERT Class 8 Chapter 9 — Algebraic Expressions and Identities.

  • Geometric meaning: when $a, b$ are the legs of a right triangle, $a^2 + b^2 = c^2$ — the Pythagorean theorem.

  • Does not factor over the reals. Unlike $a^2 - b^2$, the sum of two real squares has no real factoring (over the complex numbers, $a^2 + b^2 = (a + bi)(a - bi)$).

Two Quick Proofs

Proof 1 — Subtract from $(a+b)^2$.

Start with the binomial-square identity:

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

Subtract $2ab$ from both sides:

$$(a + b)^2 - 2ab = a^2 + b^2.$$

Done.

Proof 2 — Add to $(a-b)^2$.

Start with the other binomial-square identity:

$$(a - b)^2 = a^2 - 2ab + b^2.$$

Add $2ab$ to both sides:

$$(a - b)^2 + 2ab = a^2 + b^2.$$

The two proofs give the two equivalent forms.

Three Worked Examples, From Quick to Stretch

Quick. Find $3^2 + 4^2$.

$$3^2 + 4^2 = 9 + 16 = 25.$$

Cross-check using the formula: $(3 + 4)^2 - 2 \cdot 3 \cdot 4 = 49 - 24 = 25$. ✓

Final answer: $25$. (And, not coincidentally, $5^2 = 25$ — this is the famous $3$-$4$-$5$ right triangle.)

Standard (Wrong-Path-First). If $a + b = 7$ and $ab = 12$, find $a^2 + b^2$.

Wrong path. A student in our McKinney TX Grade 8 cohort once wrote: "$a + b = 7$ so $a = 3$ and $b = 4$; then $a^2 + b^2 = 9 + 16 = 25$." That works by luck — the values happen to fit — but the method generalises badly. If $a + b = 7$ and $ab = 10$, $a$ and $b$ are no longer integers; guessing fails.

Correct. Apply the formula directly:

$$a^2 + b^2 = (a + b)^2 - 2ab = 7^2 - 2 \cdot 12 = 49 - 24 = 25.$$

Final answer: $25$.

The method works for any $a + b$ and $ab$, integer or not. That's the value of using the formula instead of solving for $a$ and $b$ individually.

Stretch. A right triangle has legs in the ratio $5:12$ and hypotenuse $26$. Find the legs.

Let the legs be $5k$ and $12k$. By Pythagoras:

$$(5k)^2 + (12k)^2 = 26^2.$$ $$25k^2 + 144k^2 = 676.$$ $$169k^2 = 676.$$ $$k^2 = 4 \implies k = 2.$$

So the legs are $5k = 10$ and $12k = 24$.

Final answer: Legs are $10$ and $24$.

Cross-check: $10^2 + 24^2 = 100 + 576 = 676 = 26^2$. ✓ The triangle $(10, 24, 26)$ is a Pythagorean triple — $2$ times the primitive $(5, 12, 13)$.

Where the Formula Lives — From Right Triangles to Complex Numbers

The sum-of-two-squares identity is the algebraic shadow of distance in the plane.

  • Pythagorean theorem. For a right triangle with legs $a, b$ and hypotenuse $c$: $a^2 + b^2 = c^2$. Every distance computation in 2D Cartesian geometry collapses to this identity.

  • Complex numbers. The squared modulus of $a + bi$ is $|a + bi|^2 = a^2 + b^2$. Over the complex numbers the identity does factor: $a^2 + b^2 = (a + bi)(a - bi)$. This is the gateway to factoring quadratics whose discriminant is negative.

  • Vector magnitude in 2D. A vector $\vec{v} = (a, b)$ has length $|\vec{v}| = \sqrt{a^2 + b^2}$. The formula tells you how to evaluate without knowing $a, b$ individually — only their sum and product.

  • Pythagorean triples. Triples like $(3, 4, 5), (5, 12, 13), (8, 15, 17), (7, 24, 25)$ satisfy $a^2 + b^2 = c^2$ with all three integers. Number theorists generated these systematically — there are infinitely many primitive ones.

  • Sum-of-two-squares theorem (Fermat). A prime $p$ can be written as $a^2 + b^2$ if and only if $p = 2$ or $p \equiv 1 \pmod{4}$. Primes like $5 = 1^2 + 2^2$, $13 = 2^2 + 3^2$, $17 = 1^2 + 4^2$ qualify; $7, 11, 19$ do not.

The identity is small. Its mathematical descendants span four centuries of number theory.

Three Habits That Lose Marks on a² + b²

1. Confusing $a^2 + b^2$ with $(a + b)^2$.

Where it slips in: Problems where the parentheses look similar.

Don't do this: Write $a^2 + b^2 = (a + b)^2$.

The correct way: $(a + b)^2 = a^2 + 2ab + b^2$ — bigger than $a^2 + b^2$ by the cross-term $2ab$. The sum-of-squares does not equal the square-of-sum unless $ab = 0$.

2. Trying to factor $a^2 + b^2$ over the real numbers.

Where it slips in: Polynomial factorization problems on test paper.

Don't do this: Write $a^2 + b^2 = (a + b)(a - b)$ — which is the difference-of-squares formula, not the sum.

The correct way: $a^2 + b^2$ does not factor over the real numbers. Its only real form is the identity $(a+b)^2 - 2ab$. Over complex numbers, $a^2 + b^2 = (a + bi)(a - bi)$. Don't force a real factorization that doesn't exist. Roughly five out of every ten Grade 8 students in our Bhanzu cohorts try to factor $a^2+b^2$ as $(a+b)(a-b)$ on the first attempt — the fix is to memorise sum is irreducible over the reals, difference factors.

3. Forgetting the $2$ in $2ab$.

Where it slips in: Substitution problems given $a + b$ and $ab$.

Don't do this: Write $a^2 + b^2 = (a + b)^2 - ab$.

The correct way: $a^2 + b^2 = (a + b)^2 - 2ab$. The factor of $2$ comes from the binomial-square expansion's cross-term $2ab$. Forgetting it is the same error class as forgetting the $2$ in $a^2 + b^2 + c^2 = (a+b+c)^2 - 2(ab+bc+ca)$.

4. Using the formula on $a^2 - b^2$ or $a^3 + b^3$.

Where it slips in: Problems that look similar but involve different operations or powers.

Don't do this: Apply the sum-of-squares formula to factor $a^2 - b^2$ or $a^3 + b^3$.

The correct way: $a^2 - b^2 = (a-b)(a+b)$ — difference of squares, does factor. $a^3 + b^3 = (a+b)(a^2 - ab + b^2)$ — sum of cubes, factors. $a^2 + b^2$ — sum of squares, does not factor over the reals. Each identity is its own object. A real-world version of this error class: the 1996 Ariane 5 rocket failed because reused software applied a formula valid for one rocket (Ariane 4) to a different one with different parameters. The math worked — but for a system the formula was no longer modeling.

The Mathematician Behind a² + b²

The Pythagorean theorem — the geometric face of the $a^2 + b^2 = c^2$ identity — is named for Pythagoras of Samos (c. 570–c. 495 BCE, Greece), the philosopher-mathematician whose school taught geometry as a path to spiritual purification.

The historical record is messier than the school version. Babylonian clay tablets (notably Plimpton 322, c. 1800 BCE) list Pythagorean triples a millennium before Pythagoras was born — the result was known to surveyors and astronomers across Mesopotamia, India, and Egypt. The Indian mathematician Baudhāyana (c. 800 BCE) stated the theorem in Baudhāyana Śulbasūtra roughly $300$ years before Pythagoras. What Pythagoras's school may have contributed is the first systematic proof — though even that is uncertain, since the school's texts were oral and were destroyed.

The sum-of-two-squares identity in algebraic form — $a^2 + b^2 = (a+b)^2 - 2ab$ — is too elementary to attribute to a single discoverer. It was implicit in Euclid's Elements (Book II, Propositions 4 and 7, c. 300 BCE) as a geometric identity about square areas, and was used as a symbolic identity by every algebraist from al-Khwarizmi onward.

Conclusion

  • The a square plus b square formula is $a^2 + b^2 = (a + b)^2 - 2ab$, equivalently $(a - b)^2 + 2ab$.

  • It does not factor over the real numbers — unlike its cousin $a^2 - b^2 = (a-b)(a+b)$.

  • It is the algebraic form of the Pythagorean theorem when $a, b$ are the legs of a right triangle.

  • The most common mistake is treating $a^2 + b^2$ as equal to $(a+b)^2$ — it's smaller by $2ab$.

  • Over the complex numbers, $a^2 + b^2 = (a + bi)(a - bi)$ — the gateway to factoring negative-discriminant quadratics.

Practice These Three Before Moving On

Try these before continuing. If you slip on $(a+b)^2$ vs $a^2+b^2$, come back to Mistake 1.

  1. Given $a + b = 10$ and $ab = 21$, find $a^2 + b^2$.

  2. A right triangle has legs $9$ and $40$. Find the hypotenuse.

  3. Verify that $5 = 1^2 + 2^2$ and find a similar two-square representation of $13$.

Want a live Bhanzu trainer to walk through more a square plus b square formula problems with your child? Book a free demo class — online globally.

Book a Free Demo

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is the a² + b² formula?
$a^2 + b^2 = (a + b)^2 - 2ab$. Equivalently, $(a - b)^2 + 2ab$.
Can a² + b² be factored?
Not over the real numbers. Over the complex numbers, $a^2 + b^2 = (a + bi)(a - bi)$.
How is a² + b² different from (a + b)²?
$(a + b)^2 = a^2 + 2ab + b^2$. So $(a+b)^2$ is larger than $a^2 + b^2$ by exactly $2ab$ (unless $ab = 0$).
Is a² + b² = c² the same as the Pythagorean theorem?
Yes, when $a, b$ are the legs and $c$ is the hypotenuse of a right triangle. The algebraic identity $a^2 + b^2 = (a+b)^2 - 2ab$ is a separate statement that holds for any real $a, b$.
What is the value of a² + b² if a + b = 5 and ab = 6?
$a^2 + b^2 = (a+b)^2 - 2ab = 25 - 12 = 13$.
Are all primes expressible as a sum of two squares?
No. By Fermat's two-squares theorem, an odd prime $p$ is a sum of two squares if and only if $p \equiv 1 \pmod{4}$. So $5, 13, 17, 29, 37, \ldots$ qualify; $3, 7, 11, 19, \ldots$ do not.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →