As you may already know, differences between consecutive perfect squares grow after an arithmetic ratio ( with increment of 2 ).

For example , first 10 perfect squares < 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 > have the differences between them equal to < 3, 5, 7, 9, 11, 13, 15, 17, 19 > .

This result is by no means surprising if we look at the cause : sqr(x+1) – sqr(x) = 2x + 1 .

for example, lets randomly compute sqr(1001) …

1001 x 1001 = 1000 x 1000 + 2 x 1000 + 1 = 1002001. Way easier to do ( even in your own head ) than the way you usually compute 4 digit multiplications .. 🙂

the real power of this comes from the next point of view. If you have to compute , for say ( sqr(1743), and the next 100 perfect squares) , you can much easier

compute (expensivelly ) only sqr(1743) and for every number left you need only 2 additions and 1 multiplications with 2….

Next, lets inspect the higher dimension => perfect cubes …

First ten are : l0 = < 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000 >with the differences l1= < 7, 19, 37, 61, 91, 127, 169, 217, 271 >. Well what do you know, nothing arithmetic about this sequence. But , taking a closer look, if we compute ** again** the differences between consecutive numbers in this new sequence , we obtain :

l2 = <12, 18, 24, 30, 36, 42, 48, 54 >( which grows linear , of course ).

This result comes from : (cube(x+2) – cube(x+1)) – (cube(x+1) – cube(x)) = 6 * x + 6.

now this may seem odd, but if you have to compute ( for any reason possibly imaginable ) ten consecutive perfect cubes , do compute only the first two , and then with all the following do :

– in the low level, compute the first number : l21 = 6 x nr + 6. For every element in l2 that succeeds , just add 6.

– in l1, add the number obtained in l2 to the first number in l1 to obtain l12. l1 already contained one element as the difference between the 2 hard coded elements in l0. ( computated expensivelly)

– in l0, add the number l12 to l02, and so you get the next perfect cube.

instead of doing 2 multiplications which can be very tricky, you can do : 1 addition with 6, and 2 more additions. Which , by all means, sounds so much easier to do. 🙂

this wicked thing does still hold in even higher dimensions, with a catch ( which you probably kinda start to guess ) : **you need more intermediate lists. **

for perfect hypecubes , we obtain 3 sublists , the bottom which is < 60, 84, 108, 132 … > which grows after 24x + 36.

If you want to see it , do check that : {[ hype(x+3) – hype(x+2)] – [ hype(x+2) – hype(x+1)]} – {[ hype(x+2) – hype(x+1)] – [ hype(x+1) – hype(x)]} = 24x +36.

To compute the next perfect hypercube ( first 3 are given ) , you need 4 aditions , 1 of which is trivial. Instead of 3 REALLY HARD multiplications….