BrownMath.com → Algebra → Factoring A²+B²
Updated 5 Oct 2023

How to Factor the Sum of Squares

Summary: The commonest algebra mistake is probably rewriting A²+B² as (A+B)². “You can’t factor the sum of two squares on the reals!” your teacher tells you. While that’s generally true, there are some interesting exceptions.

Since Euler’s time at least, generations of students have tried to “factor” A²+B² as (A+B)². The lure of this siren song is so strong that I see even calculus students commit this blunder. Generations of teachers have sighed despairingly and tried to get students to remember that a sum of two squares can’t be factored on the reals.

When explaining How to Solve Polynomial Equations, I myself made that bare statement. But in correspondence in September 2009, Steve Schwartzman convinced me that I should say more. He proposed a sentence or two, but on the principle that a thing worth doing is worth overdoing —

It’s true that you can’t factor A²+B² on the reals — meaning, with real-number coefficients — if A and B are just simple variables. But if A and B have internal structure, the expression may be factorable after all, if you can find some other pattern. So while a sum of squares can’t be factored as such on the reals, in particular cases you can use some other pattern to factor it.

This page looks at some of those cases, where a sum of squares can be factored using other techniques.

Sophie Germain’s Identity

The counterexample that Steve Schwartzman sent me in September 2009 is, as he told me, a form of Sophie Germain’s identity:

x4 + 4y4 = (x² + 2y² + 2xy)  (x² + 2y² − 2xy)

Can you generalize this to a class of factorable sums of squares? Yes, you can.

Notice that the factors have the form of (P+Q)(PQ), which of course multiplies to P²−Q². This suggests that, for factoring A²+B², it might be fruitful to look at (A+B)² minus something. That’s all well and good, but minus what?

The key is that (A+B)² = A²+2AB+B². Comparing that to A²+B², you see that there’s an extra term of 2AB. So you have

A² + B² = (A+B)² − 2AB

That right-hand side is factorable as a difference of squares, if 2AB is a perfect square. And that’s our factorization:

A² + B² = (A + B + √(2AB)) (A + B − √(2AB))

This identity is always true, but it’s useful for factoring only when 2AB is a perfect square.

More specifically, 2AB must be a perfect square if you want your factors to have rational coefficients. If you allow non-rational factors, you can factor more sums of squares, and if you allow complex factors you can factor any sum of squares.

Example 1:  Factor 4x4 + 625y4.

Solution: Let A = 2x² and B = 25y²; then 2AB = 100x²y² is a perfect square and √(2AB) = 10xy.

4x4 + 625y4 = (2x² + 25y² + 10xy) (2x² + 25y² − 10xy)

Higher Powers

If A and B are themselves odd powers, you can use a common pattern to factor A²+B².

Example 2:  (u³)² + (v³)² = u6 + v6. Can it be factored?

The answer is yes. As you may know, An+Bn can be factored on the reals if n is an odd integer:

An+Bn = (A+B) (An−1An−2B + An−3B2 … − ABn−2 + Bn−1) for n odd

You’ve probably learned the simplest case, n = 3:

A³+B³ = (A+B) (A² − AB + B²)

So the solution is to rewrite u6+v6 as the sum of two cubes:

u6+v6 = (u²)³+(v²)³ = (u²+v²) ( (u²)² − u²v² + (v²)² ) = (u²+v²) (u4u²v² + v4)

Example 3x10+1024y10 is a sum of squares, (x5)2 + (32y5)2. But it’s also a sum of fifth powers, (x2)5 + (4y2)5. Use the above factorization for the sum of fifth powers:

A5+B5 = (A+B) (A4A3B + A2B2AB3 + B4)

x10+1024y10 = (x2)5 + (4y2)5

=(x2+4y2) ( (x2)4 − (x2)3(4y2) + (x2)2(4y2)2 − (x2)(4y2)3 + (4y2)4 )

=(x2+4y2) (x8 − 4x6y2 + 16x4y4 − 64x2y6 + 256y8)

Complex Numbers

Usually when you factor, you’re looking for real factors. But if you allow complex factors then you can always factor A²+B², like this:

A² + B² = A² − (−1·B²) = A² − (iB)² = (A+iB) (A−iB)

Example 4x²+16 = (x+4i) (x−4i)

Example 5:  25p²+49q² = (5p)² + (7q)² = (5p+7iq) (5p−7iq)

Example 6:  16x4+81y4 = (4x²)² + (9y²)² = (4x²+9iy²) (4x²−9iy²)

This one’s interesting because you can go further. (If not interested, feel free to skip this.) If only you can write i as a square—in other words, if you can find the square root of i—then the two factors become a sum of squares and a difference of squares. √i is covered in some trig classes : the principal square root is (1+i)/√2, and the other square root is minus that.

Therefore, you can rewrite 9iy² as (3 √i y)² = (3 ((1+i)/√2) y)² = ((3+3i)y/√2)², so you have a sum of squares and a difference of squares:

16x4+81y4 = [4x²+9iy²] [4x²−9iy²]

= [ (2x)² + ((3+3i)y/√2)² ] [ (2x)² − ((3+3i)y/√2)² ]

= [ 2x + i(3+3i)y/√2 ] [ 2x − i(3+3i)y/√2 ] [ 2x + (3+3i)y/√2 ] [ 2x − (3+3i)y/√2 ]

Why are there no new i’s in the second pair of factors? Because that’s good old A²−B² = (A+B)(AB). The first pair of factors can be simplified a bit:

[ 2x + i(3+3i)y/√2 ] [ 2x − i(3+3i)y/√2 ] [ 2x + (3+3i)y/√2 ] [ 2x − (3+3i)y/√2 ]

= [ 2x + (3i−3)y/√2 ] [ 2x − (3i−3)y/√2 ] [ 2x + (3+3i)y/√2 ] [ 2x − (3+3i)y/√2 ]

= [ 2x − (3−3i)y/√2 ] [ 2x + (3−3i)y/√2 ] [ 2x + (3+3i)y/√2 ] [ 2x − (3+3i)y/√2 ]

You can factor out the 1/√2 and get rid of the inner parentheses:

16x4+81y4

= (1/√2) [2√2 x − (3−3i)y] [2√2 x + (3−3i)y] [2√2 x + (3+3i)y] [2√2 x − (3+3i)y]

= (1/√2) (2√2 x − 3y + 3iy) (2√2 x + 3y − 3iy) (2√2 x + 3y + 3iy) (2√2 x − 3y − 3iy)

And finally you can reorder the four trinomials to show the combinations of plus and minus signs:

16x4+81y4

= (1/√2) (2√2 x + 3y + 3iy) (2√2 x + 3y − 3iy) (2√2 x − 3y + 3iy) (2√2 x − 3y − 3iy)

What’s New?

• 5 Oct 2023: Added a cross reference to my explanation of √i.
• 19 Oct 2020: Converted from HTML 4.01 to HTML5. Made a few small changes here and there for clarity. Italicized all the variables, and un-italicized the imaginary number i.
• 15 Sept 2016: Steve Kish questioned “on the reals”, so I added an explanation.
• 16 Aug 2015: Moved from OakRoadSystems.com to BrownMath.com.
• 20 July 2015: Pete Hepple pointed out that 2²+3² = (2+3+√12)(2+3−√12), even though 2·2·3 = 12 isn’t a perfect square. I realized I had nowhere made it explicit that by “factoring” I meant “factoring on the rationals”, so I added that.
• (intervening changes suppressed)
• 13 Sept 2009: New article, inspired by correspondence with Steve Schwartzman.