# Shortcuts - lazy or efficient?

Updated: Nov 22, 2020

We often hear there are no shortcuts to success. If you take shortcuts, you get cut short is one common view. Tolkien said that shortcuts create long delays. But there are other perspectives - and generalisation is one of them.

When writing, we often start with a general topic, key theme or main idea. We then add specific examples that support or expand on our initial statement. Mathematics often moves in the opposite direction from specific examples to a general conjecture.

Generalisation is an important and useful skill and lies at the heart of mathematics. Its a way of asking yourself - will this always work? It's the same with __machine learning__. Will your model adapt properly to data you have not yet looked at?

Generalisation provides a shortcut for calculating results and predicting outcomes. Let's dig a little further with a couple of examples.

## Mental arithmetic with squares

Imagine we want to find the difference between an integer squared and the next lowest integer squared. For example, 4 squared (4*4) - 3 squared (3*3) = 16 - 9 = 7 or maybe 6 squared (6*6) - 5 squared (5*5) = 36 - 25 = 11. For lower numbers, we can easily derive the answer mentally or with pencil and paper. Things get a little harder as the numbers get higher.

What if we want to work out 222222222222 squared minus 222222222221 squared? We can approach this from a fresh perspective. You could grab a calculator, but it probably won’t have sufficient accuracy to get you the exact answer.

The three blue squares on the left of the diagram below represent the number 3 squared, the number 4 squared and the number 5 squared. I've created three areas in each square to the right , let’s see if we can find a pattern.

Looking at each pair of squares in the diagram, we can see that:

So the difference between an integer squared and the next lowest integer squared is simply 2n -1. Let's try it out:

For 8 squared (8*8) minus 7 squared (7*7), we get 2*8 - 1 = 15

For 12 squared (12*12) minus 11 squared (11*11), we get 2*12 - 1 = 23

And for 222222222222 squared minus 222222222221, we have 444444444443

You may have to take my word for it if you're looking for a way to validate the last example above. Python can handle large integer arithmetic if you have access to a development environment. Incidentally, each answer is correct so our conjecture seems be true.

## Mental arithmetic with cubes

Let's look at a similar challenge using cubed numbers. The diagram below shows a 3x3 cube and then the same cube broken up into 4 parts. Our aim is to find a way to quickly calculate an integer n cubed minus (n-1) cubed. I have not included images for the number 4 cubed or the number 5 cubed but the same principle applies.

Looking at this cube, and also considering 4 cubed and 5 cubed we can see that:

So this is a little tougher but still much easier than actually cubing the numbers and then subtracting them from each other. As we did before, let's try it out:

For 4 cubed (4*4*4) - 3 cubed (3*3*3), we get 48 - 12 + 1 = 37

For 5 cubed (5*5*5) - 4 cubed (4*4*4), we get 75 - 15 + 1 = 61

For 20 cubed (20*20*20) minus 19 cubed (19*19*19), we get 60x19 + 1 = 1141

I'll leave the reader to test out higher numbers.

Thinking about problems in this way can often lead to insights that help us to solve challenging problems. Do you need to inject a little creative thinking into your business? Please click below to find out more.