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

#Math Formula
TL;DR
The a square plus b square formula says a2+b2=(a+b)2−2aba^2 + b^2 = (a + b)^2 - 2ab or equivalently a2+b2=(a−b)2+2aba^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:

a2+b2=(a+b)2−2ab=(a−b)2+2ab.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 aa and bb:

;a2+b2=(a+b)2−2ab;\boxed{;a^2 + b^2 = (a + b)^2 - 2ab;}

Equivalently:

a2+b2=(a−b)2+2ab.a^2 + b^2 = (a - b)^2 + 2ab.

Quick facts.

  • Type: algebraic identity (true for all real a,ba, 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,ba, b are the legs of a right triangle, a2+b2=c2a^2 + b^2 = c^2 — the Pythagorean theorem.

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

Two Quick Proofs

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

Start with the binomial-square identity:

(a+b)2=a2+2ab+b2.(a + b)^2 = a^2 + 2ab + b^2.

Subtract 2ab2ab from both sides:

(a+b)2−2ab=a2+b2.(a + b)^2 - 2ab = a^2 + b^2.

Done.

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

Start with the other binomial-square identity:

(a−b)2=a2−2ab+b2.(a - b)^2 = a^2 - 2ab + b^2.

Add 2ab2ab to both sides:

(a−b)2+2ab=a2+b2.(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 32+423^2 + 4^2.

32+42=9+16=25.3^2 + 4^2 = 9 + 16 = 25.

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

Final answer: 2525. (And, not coincidentally, 52=255^2 = 25 — this is the famous 33-44-55 right triangle.)

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

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

Correct. Apply the formula directly:

a2+b2=(a+b)2−2ab=72−2⋅12=49−24=25.a^2 + b^2 = (a + b)^2 - 2ab = 7^2 - 2 \cdot 12 = 49 - 24 = 25.

Final answer: 2525.

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

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

Let the legs be 5k5k and 12k12k. By Pythagoras:

(5k)2+(12k)2=262.(5k)^2 + (12k)^2 = 26^2. 25k2+144k2=676.25k^2 + 144k^2 = 676. 169k2=676.169k^2 = 676. k2=4  ⟹  k=2.k^2 = 4 \implies k = 2.

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

Final answer: Legs are 1010 and 2424.

Cross-check: 102+242=100+576=676=26210^2 + 24^2 = 100 + 576 = 676 = 26^2. ✓ The triangle (10,24,26)(10, 24, 26) is a Pythagorean triple — 22 times the primitive (5,12,13)(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,ba, b and hypotenuse cc: a2+b2=c2a^2 + b^2 = c^2. Every distance computation in 2D Cartesian geometry collapses to this identity.

  • Complex numbers. The squared modulus of a+bia + bi is ∣a+bi∣2=a2+b2|a + bi|^2 = a^2 + b^2. Over the complex numbers the identity does factor: a2+b2=(a+bi)(a−bi)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 v⃗=(a,b)\vec{v} = (a, b) has length ∣v⃗∣=a2+b2|\vec{v}| = \sqrt{a^2 + b^2}. The formula tells you how to evaluate without knowing a,ba, b individually — only their sum and product.

  • Pythagorean triples. Triples like (3,4,5),(5,12,13),(8,15,17),(7,24,25)(3, 4, 5), (5, 12, 13), (8, 15, 17), (7, 24, 25) satisfy a2+b2=c2a^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 pp can be written as a2+b2a^2 + b^2 if and only if p=2p = 2 or p≡1(mod4)p \equiv 1 \pmod{4}. Primes like 5=12+225 = 1^2 + 2^2, 13=22+3213 = 2^2 + 3^2, 17=12+4217 = 1^2 + 4^2 qualify; 7,11,197, 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 a2+b2a^2 + b^2 with (a+b)2(a + b)^2.

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

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

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

2. Trying to factor a2+b2a^2 + b^2 over the real numbers.

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

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

The correct way: a2+b2a^2 + b^2 does not factor over the real numbers. Its only real form is the identity (a+b)2−2ab(a+b)^2 - 2ab. Over complex numbers, a2+b2=(a+bi)(a−bi)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 a2+b2a^2+b^2 as (a+b)(a−b)(a+b)(a-b) on the first attempt — the fix is to memorise sum is irreducible over the reals, difference factors.

3. Forgetting the 22 in 2ab2ab.

Where it slips in: Substitution problems given a+ba + b and abab.

Don't do this: Write a2+b2=(a+b)2−aba^2 + b^2 = (a + b)^2 - ab.

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

4. Using the formula on a2−b2a^2 - b^2 or a3+b3a^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 a2−b2a^2 - b^2 or a3+b3a^3 + b^3.

The correct way: a2−b2=(a−b)(a+b)a^2 - b^2 = (a-b)(a+b) — difference of squares, does factor. a3+b3=(a+b)(a2−ab+b2)a^3 + b^3 = (a+b)(a^2 - ab + b^2) — sum of cubes, factors. a2+b2a^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 a2+b2=c2a^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 300300 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 — a2+b2=(a+b)2−2aba^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 a2+b2=(a+b)2−2aba^2 + b^2 = (a + b)^2 - 2ab, equivalently (a−b)2+2ab(a - b)^2 + 2ab.

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

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

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

  • Over the complex numbers, a2+b2=(a+bi)(a−bi)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(a+b)^2 vs a2+b2a^2+b^2, come back to Mistake 1.

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

  2. A right triangle has legs 99 and 4040. Find the hypotenuse.

  3. Verify that 5=12+225 = 1^2 + 2^2 and find a similar two-square representation of 1313.

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.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is the a² + b² formula?
a2+b2=(a+b)2−2aba^2 + b^2 = (a + b)^2 - 2ab. Equivalently, (a−b)2+2ab(a - b)^2 + 2ab.
Can a² + b² be factored?
Not over the real numbers. Over the complex numbers, a2+b2=(a+bi)(a−bi)a^2 + b^2 = (a + bi)(a - bi).
How is a² + b² different from (a + b)²?
(a+b)2=a2+2ab+b2(a + b)^2 = a^2 + 2ab + b^2. So (a+b)2(a+b)^2 is larger than a2+b2a^2 + b^2 by exactly 2ab2ab (unless ab=0ab = 0).
Is a² + b² = c² the same as the Pythagorean theorem?
Yes, when a,ba, b are the legs and cc is the hypotenuse of a right triangle. The algebraic identity a2+b2=(a+b)2−2aba^2 + b^2 = (a+b)^2 - 2ab is a separate statement that holds for any real a,ba, b.
What is the value of a² + b² if a + b = 5 and ab = 6?
a2+b2=(a+b)2−2ab=25−12=13a^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 pp is a sum of two squares if and only if p≡1(mod4)p \equiv 1 \pmod{4}. So 5,13,17,29,37,…5, 13, 17, 29, 37, \ldots qualify; 3,7,11,19,…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 →