Eamonn, thanks for the link, I will check it. I've prepared my solution below before seeing your post so I'm posting it anyway as it reflect my findings.

## Introduction

To provide some formal content to my 15C program submitted

above, here is a complete demonstration showing that if

**M** is a 3x3 magic square having

**K** as its constant, then

**M**^{3} is also a magic square with

**K**^{3} as its constant.

I suppose there are some smarter and nicer demonstrations as mine is a bit on the "brute force" side, being based on the direct calculation of each term of

**M**^{3}.

## The trick

After several tries, I've come to the conclusion that I needed to take advantage of the magic square properties to reduce the number of variables to a minimum.

As I was manipulating 3x3 magic squares I've found an interesting property:

( r, s, t )

M = ( u, v, w )

( x, y, z )

being a magic square with K as it's constant, we can write using the rows properties:

3K = (r+s+t) + (u+v+w) + (x+y+z)

Rearranging the terms to use also the diagonals properties we have:

3K = (r+v+z) + (x+v+t) + (s+u+w+y) -v

3K = (r+v+z) + (x+v+t) + (s+v+y -v + u+v+w -v) -v

3K = (r+v+z) + (x+v+t) + (s+v+y) + (u+v+w) -3v

3K = 4K -3v

3v = K

So:

**v = K/3**
This tell us one thing about 3x3 magic squares: their constant is always a multiple of 3.

Having a direct relation between the magic square constant **K** and the center value, we can now write **M** differently:

let's name **a** the central value and use it as a reference, expressing each value as **a** + or - something:

( a+b a-b-c a+c )

M = ( a-b+c a a+b-c )

( a-c a+b+c a-b )

Now we have an expression of

**M** using only the central value

**a** (which is equal to one third of the constant

**K**) plus 2 others parameters

**b** &

**c** that can be positive or negative and are sufficient to completely define the magic square.

## Calculating M^{2}

If we calculate

**M*M**, for the first element (top left) we have:

(a+b)(a+b) a^{2} + ab + ab + b^{2}

+ (a-b-c)(a-b+c) = + a^{2} - ab + ac - ab + b^{2} - bc - ac + bc -c^{2}

+ (a+c)(a-c) + a^{2} - ac + ac - c^{2}
= 3a^{2} + 2b^{2} - 2c^{2}

after calculating all terms we get the following matrix:

( 3a^{2}+2b^{2}-2c^{2} 3a^{2}-b^{2}+c^{2} 3a^{2}-b^{2}+c^{2} )

M*M = ( 3a^{2}-b^{2}+c^{2} 3a^{2}+2b^{2}-2c^{2} 3a^{2}-b^{2}+c^{2} )

( 3a^{2}-b^{2}+c^{2} 3a^{2}-b^{2}+c^{2} 3a^{2}+2b^{2}-2c^{2})

We can see that for **M**^{2} each row and column as well as the diagonal bottom left to top right has the same sum which is **9a**^{2} = **K**^{2} (remember: **a = K/3**) , but the remaining diagonal (top left to bottom right) has a different sum so **M**^{2} is not a magic square.

## Calculating M^{3}

Now let's calculate

**M**^{2}*M.

First, what's the center value of **M**^{3}:

(3a^{2}-b^{2}+c^{2})(a-b-c) 3a^{3} - ab^{2} + ac^{2} - 3a^{2}b + b^{3} + bc^{2} - 3a^{2}c + b^{2}c - c^{3}

+ (3a^{2}+2b^{2}-2c^{2})a = + 3a^{3} + 2ab^{2} - 2ac^{2}

+ (3a^{2}-b^{2}+c^{2})(a+b+c) + 3a^{3} - ab^{2} + ac^{2} + 3a^{2}b - b^{3} - bc^{2} + 3a^{2}c - b^{2}c + c^{3}
= 9a^{3} (we can simplify a lot of terms above)

= 9(K/3)^{3}

= **K**^{3}/3

That starts to look interesting as we want to prove that

**M**^{3} is a magic square with

**K**^{3} as constant...

Let's continue with all terms (it took me some time to get it right ...) and we have:

( 9a^{3}+3b^{3}-3bc^{2} 9a^{3}-3b^{3}+3c^{3}+3bc^{2}-3b^{2}c 9a^{3}-3c^{3}+3b^{2}c )

M^{3} = ( 9a^{3}-3b^{3}-3c^{3}+3bc^{2}+3b^{2}c 9a^{3} 9a^{3}+3b^{3}+3c^{3}-3bc^{2}-3b^{2}c )

( 9a^{3}+3c^{3}-3b^{2}c 9a^{3}+3b^{3}-3c^{3}-3bc^{2}+3b^{2}c 9a^{3}-3b^{3}+3bc^{2} )

If we add up each row, column or diagonal we can see now that

**M**^{3} is a magic square with a constant of: 27a

^{3} = 27(K/3)

^{3} =

**K**^{3}, so we are done !!!

## Conclusion

As a conclusion, many thanks to Valentin for crafting the Mini-challenges. This one has been for me both challenging and rewarding as I've been able to solve it practically with the requested 15C program based on my intuitions and theoretically with a formal demonstration. Overall this was an excellent brain exercise !

*Edited to fix a few typos.*

*Edited: 12 June 2009, 7:00 p.m. *