Sum of Squares

Here is an interesting problem I have been playing around with. We all remember square numbers from grade school:  22 = 4 or 62 = 36. Now consider the lowly number 5. While it can be squared, it, by itself, is not a square number. That makes 5 sad. However, maybe 5 could be the next best thing. Could we find a way to write 5 as the sum of two squares?

Well, we could try 5 = 2 + 3. But neither 2 or 3 is a square. What about 5 = 4 + 1? Bingo! 4 = 22 and 1 = 12. The interesting thing, is that if you try to do this with 6, you find that is simply doesn’t work. It won’t work with 7 either, but it does with 8. Can you find the two squares that add up to 8?

Of course you can; 8 = 22 + 22.

Now for the fun part. I guarantee you that it will work for 40. Why 40 you might ask? Well, if it worked for 5 and it worked for 8, then it will work for 5 × 8, or 40.

Sure enough, 40 = 36 + 4 = 62 + 22.

Using this insight, we could go even higher. 40 × 8 = 320. Assuming I am correct, it should work for 320. Now I don’t know about you, but I have a hard time spotting two squares that add up to 320. Wouldn’t it be nice if there was a formula that would use what I already know about 8 and 40 to tell us which squares add up to 320?

As I was working through this problem, I stumbled upon just such a formula. It’s called the “sum of squares” because it sums two squares.  The nice thing is that it tells us how to arrive at the two squares that we are going to add together.

Let’s first return to the case with 5 and 8. The base numbers that produced the squares for 5 were 2 and 1. Let’s call these a and b. For 8, the numbers are 2 and 2. Let’s call these c and d. I’m going to give you the formula and then explain at the end how we obtained it.  For now, just trust me.  At first glance, the formula may not feel intuitive.  But if you hang in there and do the example yourself a couple of times, you’ll get comfortable with it pretty quickly.

First square = a × c + b × d

Second square = a × db × c

Not what you would expect hey? Those are some complicated formulas for such a simple puzzle. However, if we plug in our values, we get:

First square = 2 × 2 + 1 × 2 = 6

Second square = 2 × 21 × 2 = 2

Thus: 40 = 62 + 22

Pretty cool hey! Let’s see if it works for 8 and 40:

8 = 22 + 22

40 = 62 + 22.

First square = 2 × 6 + 2 × 2 = 16

Second square = 2 × 22 × 6 = -8

So, we get: 320 = 162 + (-8)2

 

Ok, one more fun example.

13 = 22 + 32

17 = 12 + 42

First square = 2 × 1 + 3 × 4 = 14

Second square = 2 × 43 × 1 = 5

And we get: 221 = 142 + 52

That’s all there is to it. A fun exercise is to find out which numbers between 1 and 100 can be written as the sum of two squares. For example, of the three numbers 71, 72, 73, only 2 can be written as the sum of two squares. Can you tell which ones?

 

Aside:

For those of you wondering why the formula works, a bit of algebra does the trick.

Let n1 and n2 be two positive integers where n1 = a2 + b2 and n2 = c2 + d2. To show that the product, n1n2, can be written as the sum of two squares of integers, observe the following:

n1n2 = (a2 + b2)(c2 + d2)

= a2c2 + a2d2 + b2c2 + b2d2

= (a2c2 + b2d2) + (a2d2 + b2c2)

= (a2c2 + 2abcd + b2d2) + (a2d2 – 2abcd + b2c2)

=(ac + bd)2 + (ad – bc)2

 

Advertisements

5 Comments

Filed under Uncategorized

5 responses to “Sum of Squares

  1. Gennadij

    One can also derive this formula from multiplying two complex numbers and calculating the square of the absolute value of the product. That makes the calculation a little bit shorter, but of course it is essentially the same.

  2. This is very interesting, You’re a very skilled blogger. I have joined your rss feed and look forward to in quest of extra of your magnificent post. Additionally, I’ve shared your website in my social networks!

  3. You definitely put a new spin on a topic thats been written about for years. Great stuff, just great!

  4. Feng Beiye

    How to represent an integer as sums of three squares?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s