GBB Logo         
GBB Services
GBB Services : Resources : Mathematics : a2-b2=(a-b)(a+b)

Note: (written November 6 2016) I'm glad you found this essay I wrote long ago. It's archived here on my website, together with my other essays from a decade ago. If you want to see my more recent content, my blog is the place to find it.

Exploring the identity a2-b2 = (a-b)(a+b)

by Walter Vannini

Introduction
Rectangles and Squares
Money
Hyperbolas
Wave Equation
Inner Products
Multiplication Table
Odd Numbers
Cracking RSA
Continued Fractions
Infinite Product
Feedback

Introduction

There are many possible approaches to understanding this identity. Recently Peter Hendrickson asked me who my target audience is, and I told him it was me, assuming that for some reason I was ignorant about the item under discussion. For this identity, I would be sure to tell myself that there are various algebraic rewritings of the identity. There are three broad classifications:

  • An identity that rewrites a difference of squares as a product, and its special cases:
    • a2-b2 = (a-b)(a+b)
    • 1-x2 = (1-x)(1+x)
    • x2-1 = (x-1)(x+1)
    • (x)2-(x-1)2 = 2x-1
  • An identity that rewrites a product as a difference of squares, and its special cases:
    • uv = ((u+v)/2)2 - ((u-v)/2)2
    • u = ((u+1)/2)2 - ((u-1)/2)2
    • 1 = ((w+1/w)/2)2 - ((w-1/w)/2)2
  • "Others", such as
    • a-b = (a2-b2)/(a+b)
    • a+b = (a2-b2)/(a-b)
    • ((x+h)2-x2)/h = 2x+h
    • C = (√(x+C)-√x)(√(x+C)+√x)

Throughout the discussion I would tell myself that the above identities hold in more general settings: the elements don't need to be real numbers, and the operations don't need to be multiplication and addition of reals. Also, with any algebraic result, I always want to know about geometric interpretations or consequences, so I'd be sure to mention something about that. Ditto for any physical interpretation. And, I'd mention something about generalizations and related identies: e.g. What about the difference of cubes, what about the product of three elements, what about the sum of squares, etc.

Okay, that's the broad overview and plan of attack. Now let's dig in.

Rectangles and Squares

The square of a positive real s, as in "s raised to the power 2", i.e. s2, is the area of a square with side length s. The product of two positive reals a and b is the area of a rectangle with sides of length a and b.

Using these geometric interpretations, it's clear that the identity is saying something about areas of squares and rectangles.

euclid

The above diagram gives some insight, via geometric dissection, about why the identity is true.

At this point, I'd like to make a little digression into symmetry considerations. In the above geometric sequence, an arbitrary choice was made, and the initial symmetry of the picture was broken. We could just as easily have gone the other way:

euclid2

Strangely enough, this actually leads to a result. Considering both diagrams together, and forming a "superposition", we should expect that a2-b2 is some kind of weighted average of (a-b)(a+b) and (a+b)(a-b). Since the two items are the same, this doesn't produce anything new. But, what if they weren't the same? What if multiplication were not commutative (i.e. xy was not the same as yx). This would be the case if a and b were n by n square matrices, or if they were quaternions. In that case, the identity would not be true. Using quaternions for example: i2-j2 is 0, but (i-j)(i+j) is not.

Going back to algebra, this is because (a-b)(a+b) = a2+ab-ba-b2, and ab and ba don't cancel each other out to give a final result of a2-b2, unless ab=ba.

But, combining the two versions:
(a-b)(a+b) = a2+ab-ba-b2
(a+b)(a-b) = a2+ba-ab-b2
we do get that
(a-b)(a+b) + (a+b)(a-b) = 2(a2-b2).

Assuming it makes sense to divide by two, we get a weighted average identity
a2-b2 = (1/2)(a-b)(a+b)+(1/2)(a+b)(a-b)
which is still true even when multiplication is not commutative.

I must admit at this stage that I don't know of any use for this, but I couldn't resist mentioning it.

Money

After that digression into abstract generality, it's time to go back to the concrete and specific.

Consider the special case of the identity where a is 1:
1-x2 = (1-x)(1+x)

There is a nice financial interpretation of this. If an item has a 10% sales tax (corresponding to x=0.1), and has a 10% discount, then the final price is not the same as the initial price, but is instead reduced by 1% (since x2=0.12=0.01 ie 1%). Also, since (1-x)(1+x) and (1+x)(1-x) are the same, it doesn't matter whether the discount is done first or last.

Two Formulas for Hyperbolas

When I first learned about the hyperbola, back in high school, it was via the equation y = 1/x

hyperbola1

The instructor told us that the curve was called the hyperbola, and went on to talk about asymptotic behaviour, the two asymptotes (x=0 and y=0) and all the usual things. No problem! We then moved on to other topics.

A few weeks later, we tackled second order equations in the plane: ie Ax2 + By2 + Cxy + Ex + Dy + F = 0. We then got to the equation x2-y2=1, and we were told that it was a hyperbola, and the two asymptotes were x=y and x=-y.

hyperbola2

It seems I was the only one who noticed and was disturbed by the fact that a "hyperbola" had been defined twice, and in two different ways that seemed unrelated. The instructor didn't talk about this. Our textbook, which was geared towards preparing for an exam, had nothing to say on the topic. I somehow convinced myself that the equations were defining the same kind of curve. I forget just how I did it, but I certainly didn't "understand". I probably manipulated some symbols, and magically everything worked out. It was years later that I finally realized that the two equations were easily reconciled via the a2-b2=(a-b)(a+b) identity. It's a little more obvious if y=1/x is rewritten as xy=1. Somehow, I don't think that would have been enough of a clue for me when I was in high school. Some things take time.

Just to say a little more about this, we have that the co-ordinate transform
u=x-y
v=x+y
changes the equation uv=1 to (x-y)(x+y)=1, which is x2-y2=1.

The transform described here is a 45° rotation followed by a scaling (with the scaling factor being √2). If we stick to rotations, the transformation to consider is
u=(x-y)/√2
v=(x+y)/√2
uv=1 now becomes x2-y2=2, not x2-y2=1. If you had looked carefully at the above diagrams, you might have noticed that the x2-y2=1 hyperbola approached its asymptotes faster than the xy=1 hyperbola. Now you know why.

Wave Equation

A solution U(x,t) to the one dimensional wave equation in two variables x and t is a solution to the partial differential equation:
d2U/dx - d2U/dt = 0
which, in differential operator form, is just
[ (d/dx)2 - (d/dt)2 ] U = 0

As we saw earlier, the a2-b2 identity applies as long as ab=ba. In the case where a and b are the differential operators d/dx and d/dt, we have that ab=ba, ie (d/dx)(d/dt) = (d/dt)(d/dx) since d2f/dxdt = d2f/dtdx. So, the wave equation becomes (d/dx - d/dt) (d/dx + d/dt) U = 0

Writing
x = u+v
t = u-v
we have
d/du = (dx/du)(d/dx) + (dt/du)(d/dt) = (d/dx)+(d/dt)
d/dv = (dx/dv)(d/dx) + (dt/dv)(d/dt) = (d/dx)-(d/dt)
These are precisely the terms in the factorization of (d/dx)2 - (d/dt)2 and so the wave equation becomes (d/dv)(d/du)U=0

The solution to this is "trivial": U = f(u) + g(v) = f((x+t)/2) + g((x-t)/2), i.e.
U(x,t) = F(x+t) + G(x-t)

The factorization given by the a2-b2 identity ends up telling us that any solution to the wave equation is the superposition of a wave moving to the left at speed 1, and a wave moving to the right at speed 1.

Inner Products and Length Squared

For two vectors u=(u1,u2,u3) and v=(v1,v2,v3), the inner product u•v is given by
u1v1+u2v2+u3v3

For a vector v=(v1,v2,v3), the length squared |v|2 is
v1v1+v2v2+v3v3

It's pretty clear that they're related:
|v|2 = v•v
ie, the length squared function s(v)=|v|2 is derivable from the inner product function p(u,v) = u•v, via
s(v)=p(v,v)

The a2-b2 identity applies in this situation, where multiplication is the dot product, and squaring is length squared:

|u|2-|v|2 = (u-v)•(u+v)

This is mildly interesting, but the equivalent form of the identity, which relates a product to a difference of squares is really interesting:

u•v = |(u+v)/2|2-|(u-v)/2|2

This tells us that the inner product function is derivable from the length squared function:
p(u,v)=s((u+v)/2)-s((u-v)/2)

And, of course, there's nothing special about R3 with the standard inner product. Everything generalizes to semidefinite products and to Hilbert spaces.

Patterns in the Multiplication Table

When I was in elementary school, we memorized our multiplication table all the way up to the 12 by 12 case. We were tested over and over, year after year. We got to know that multiplication table!

* 1 2 3 4 5 6 7 8 9 10 11 12
1 1 2 3 4 5 6 7 8 9 10 11 12
2 2 4 6 8 10 12 14 16 18 20 22 24
3 3 6 9 12 15 18 21 24 27 30 33 36
4 4 8 12 16 20 24 28 32 36 40 44 48
5 5 10 15 20 25 30 35 40 45 50 55 60
6 6 12 18 24 30 36 42 48 54 60 66 72
7 7 14 21 28 35 42 49 56 63 70 77 84
8 8 16 24 32 40 48 56 64 72 80 88 96
9 9 18 27 36 45 54 63 72 81 90 99 108
10 10 20 30 40 50 60 70 80 90 100 110 120
11 11 22 33 44 55 66 77 88 99 110 121 132
12 12 24 36 48 60 72 84 96 108 120 132 144

In high school, my good friend Jack Robin told me that he'd discovered a pattern in the multiplication table, and he started describing it to me. If you moved off the main diagonal, consisting of squares, via the other diagonal direction, the values went down by one. At first I didn't understand what he was talking about, but he showed it to me, and he was right. I'd never noticed that before.

* 1 2 3 4 5 6 7 8 9 10 11 12
1 1 2 3 4 5 6 7 8 9 10 11 12
2 2 4 6 8 10 12 14 16 18 20 22 24
3 3 6 9 12 15 18 21 24 27 30 33 36
4 4 8 12 16 20 24 28 32 36 40 44 48
5 5 10 15 20 25 30 35 40 45 50 55 60
6 6 12 18 24 30 36 42 48 54 60 66 72
7 7 14 21 28 35 42 49 56 63 70 77 84
8 8 16 24 32 40 48 56 64 72 80 88 96
9 9 18 27 36 45 54 63 72 81 90 99 108
10 10 20 30 40 50 60 70 80 90 100 110 120
11 11 22 33 44 55 66 77 88 99 110 121 132
12 12 24 36 48 60 72 84 96 108 120 132 144

The next question was: why? As it turned out, we'd just been learning algebra, and I was able to make the connection! It was just an application of the a2-b2 identity:
(n-1)(n+1) = n2-1

Sums of Consecutive Odd Numbers

One of the special cases of the identity is:
x2-(x-1)2 = 2x-1

After years of having my mind deformed by programming, it seems really natural to start at a positive integer n, and iterate down to 1. Doing that, we get:

n2-(n-1)2 = 2n-1
(n-1)2-(n-2)2 = 2n-3
(n-2)2-(n-3)2 = 2n-5
32-22 = 5
22-12 = 3
12-02 = 1

Adding up the columns, we get
n2 = 1+3+…+(2n-3)+(2n-1)

It's also true that if we hadn't gone all the way to one, but only went down to m+1, we would get:
n2 = m2 + (2m+1) + (2m+3) + … + (2n-1)

Cracking RSA

RSA encryption (named after Rivest Shamir and Adleman) wouldn't provide much protection if we knew how to factor large numbers quickly. In particular, given two large primes p and q, if we could factorize the product, N=pq quickly, RSA encryption would be broken.

The a2-b2 identity gives us a way of factorizing quickly, if p and q aren't chosen properly.

Before going into details, I'd like to digress a little and say a little bit more about RSA encryption.

If you study the subject, something that you'll quickly learn is that what we really want to get is φ(N), where φ is Euler's phi function. Since φ(N)=(p-1)(q-1), factorizing N will certainly allow you to get φ(N). It's also true that knowing φ(N) will allow you to get the factorization. This is because knowing N=pq and φ(N)=(p-1)(q-1) will give you p+q, via N+1-φ(N). Well, once you have pq and p+q, the identity gives us p-q via pq = ((p+q)/2)2 - ((p-q)/2)2. And, once we have both p+q and p-q we have p and q.

Okay, that's the end of the digression.

Although factorizing N=pq is hard in general, if p and q are chosen badly, then the factorization is easy. The obvious case, that takes little mathematical sophistication to realize, is that if p is small, say smaller that 1010, then simply testing p=2, then p=3, then p=4, etc, will quickly give the game away. Gigahertz machines can check a mere 1010 cases pretty quickly. So, don't pick p and q to be to close to the extremes. i.e. if pq is a 200 digit number, don't pick p and q so that p has a mere 10 digits, and q has 190 digits.

As it turns out, you don't want to be too close to the middle either, by which I mean don't pick p and q so that p has 100 digits, q has 100 digits, and p and q differ only in the least significant 55 digits. The reason is because of the identity!

Suppose K2 is a perfect square greater that N. If K2-N is a perfect square J2, then N=K2-J2 instantly gives us the factorization (K-J)(K+J).

So, instead of iterating p starting from 2 and counting up, we can start from M=K2-N, where K2 is the smallest square greater than N, and increment by 2K+1, then 2K+3, then 2K+5 etc to get M=(K+1)2-N, M=(K+2)2-N, M=(K+3)2-N, and at each stage test to see if M is a square. In the 200 digit example above, it would take a mere 1010 steps to find p and q.

By the way, currently there isn't any well-known proof establishing that factorizing N=pq is difficult in general.

Recursion and Continued Fractions

There's a recursive formula hiding in the identity, and it leads to continued fraction expressions. Here are the details:

The identity can be written as
x-y = (x2-y2)/(x+y)

This can be viewed as a way of writing x-y in terms of x+y. But x+y can be written in terms of x-y via simple addition, ie x+y=2y+(x-y).

So, we have a formula for x+y in terms of x+y! Here it is:
x+y = 2y + (x2-y2)/(x+y)

Well, once we have something like that, it's hard to resist recursing infinitely to get:
x+y = 2y + (x2-y2)/ ( 2y + (x2-y2)/ ( 2y + (x2-y2)/ … ) )

Choosing x and y so that x2-y2 is something simple, like 1, we get that x must be √(1+y2). Using this, the formula becomes: y+√(1+y2) = 2y + 1/(2y+1/(2y+1/…)). In the well known continued fraction notation. This is saying y+√(1+y2) = [2y,2y,2y,…]

Some immediate consequences are:

for y=1/2, we get that φ, the golden ratio (1+√5)/2 satisfies φ = [1,1,1,…] leading to approximations via ratios of Fibonacci numbers
1/1, 2/1, 3/2, 5/3, ….

Writing y=n, we get that
n + √(1+n2) = [2n, 2n, 2n, …]
This tells us that
√(n2+1) = [n, 2n, 2n, …]

For example, taking n=1, we get that
√2 = [1, 2, 2, …]
leading to the approximations 1/1, 2/1, 3/2, 7/5, 17/12, …

Recursion and an Infinite Product

There's another recursive formula hiding in the identity, and it leads to an infinite product, which in turn leads to an infinite series. Here are the details:

Consider the special case
1-x2= (1-x)(1+x)
This can be viewed as a formula for 1/(1-x), namely
1/(1-x) = (1+x)/(1-x2)

Well, viewing x2 as a single variable u, this is saying
1/(1-x) = (1+x) (1/(1-u))

Now apply the 1/(1-x) formula to 1/(1-u), and we're well on our way to infinite recursion:
1/(1-x) = (1+x)(1+u)(1/(1-u2))

This process leads to the infinite product
1/(1-x) = (1+x)(1+x2)(1+x4)(1+x8)…

Multiplying out, this gives the well-known series 1/(1-x) = 1 + x +x2 + x3 + x4 + …

Feedback

If you have corrections, additions, modifications, etc please let me know mailto:walterv@gbbservices.com

April 11 2003 Posted
April 24 2003 Last Updated

Back to top of page