# Modify a magic square

This is a 3x3 magic square of summation,
in which sums of each row, column, and diagonal are equal.

$$\begin{array}{c|c|c} 4&9&2\\\hline 3&5&7\\\hline 8&1&6 \end{array}$$

Now modify the magic square by defining a simple function $f(x)$,
so it becomes a new magic square of multiplication,
i.e. in which products of each row, column, and diagonal are equal.

$$\begin{array}{c|c|c} f(4)&f(9)&f(2)\\\hline f(3)&f(5)&f(7)\\\hline f(8)&f(1)&f(6) \end{array}$$

Note: Create the function as simple as possible.

• Obviously f(x) = 0 X x will work but I guess that's not what we are after. – rhsquared Aug 22 '16 at 7:59
• You don't mention that all nine entries should be unique both before and after the transformation. That's usually part of the definition of a magic square. – Wildcard Aug 23 '16 at 4:07
• @Wildcard, Elias's 1st answer produce unique numbers after the transformation. – Jamal Senjaya Aug 23 '16 at 4:13
• @JamalSenjaya, yes, I know. And that is actually the only answer (I believe but cannot prove); all others are special cases of that one. – Wildcard Aug 23 '16 at 4:46
• Ugh, why does everybody think a function must be of the form $f(x)=$stuff, where x appears in stuff? $f(x)=0$ is a perfectly valid function, rather than $f(x)=0x$ or even $f(x)=x^0-1$ – Wen1now Sep 9 '17 at 3:09

$f(x)=c_1\times({c_2}^x)$ with any $c_1$ and $c_2$.

Check:

$f(x)\times f(y)\times f(z)=(c_1\times({c_2}^x))\times(c_1\times({c_2}^y))\times(c_1\times({c_2}^z))={c_1}^3\times{c_2}^{x+y+z}$
As previously $x+y+z$ was equal in the desired columns, rows and diagonals, these products will be as well.

An answer which is not of this form is:

$f(x)=(x+1)\mod2$
As each row, column and diagonal has an odd number, this product will always give 0, although $f$ is $1$ for the even numbers.

• Very elegant solution. – rhsquared Aug 22 '16 at 7:58

My Shot:

$f(x) = e^x$.

Reasoning.

$e^x \times e^y \times e^z = e^{x+y+z}$
Since the sums match in the magic square, the products will match in this case. They will all be $e^{15}$.

Second try.

$f(x) = x^0$.
all the products will be 1.

And maybe the simplest function

$f(x) = c$ where c is any number, real, complex, integer, rational, irational.

• Nice, though $x^0$ is just a fancy way to say $1$. Constant $1$ and $e^x$ are both special cases of my generic answer. – elias Aug 22 '16 at 8:01
• @elias. True. That's why +1'd your answer. I'm a simple man, I think in simple terms. – Marius Aug 22 '16 at 8:01
• Cool. Your answer of $c$ even beats mine in simplicity, which was asked for in the question. – elias Aug 22 '16 at 8:09
• I would like to point out that at least in most magic squares, all the numbers need to be unique, so I don't think that c or (x+1) mod 2 are valid. +1 for creativity, though! – ash4fun Aug 22 '16 at 18:36
• This answer should get the golden checkmark. – COTO Aug 22 '16 at 18:38

$f(x) = 1^x$

Since

$1^x = 1$ for every $x$ ($\in \mathbb{R}$)

of course.

Maybe a bit trivial, but it works. :)

• Also a special case $$c_1 = 1$$ $$c_2 = 1$$ of elias's earlier answer. – Ben Voigt Aug 22 '16 at 22:00
• True, the question said "Create the function as simple as possible." (Although technically $f(x) = 0$ is simpler. [As Brian Risk and Marius pointed out.]) – Kevin Aug 23 '16 at 10:58

LOL not in spirit, but technically an answer:

$f(x) = 0x$.

• why not directly 0? It makes the function even shorter. – Marius Aug 22 '16 at 14:34
• Also a special case $$c_1 = 0$$ of elias's earlier answer. – Ben Voigt Aug 22 '16 at 22:00

Below is the way to easily construct multiplicative 3x3 magic squares with nonnegative integer values. Let $x, y, z$ be nonnegative integers so that $xy$ is a square number. Then

$\sqrt{xy}z^2 \qquad x^2y \qquad yz\sqrt{xy}$

$xy^2 \qquad\quad xyz \qquad xz^2$

$xz\sqrt{xy} \qquad yz^2 \qquad xy\sqrt{xy}$

is a magic square of (not necessarily distinct) nonnegative integers where the product of the rows, columns, and diagonals are all equal to $(xyz)^3$. It is left as an exercise to see that a magic square with the listed properties is necessarily in this form.

To see a slightly less abstract (and working!) example, set $x:=1$, $y:=4$, and $z:=3$, obtaining a magic square with distinct elements, and with the magic product $1728=(1\cdot 4\cdot 3)^3$.

$18 \quad 4\quad 24$

$16 \quad 12\quad 9$

$6 \quad 36 \quad 8$

Here we see that the elements are not pure integer powers, and, in addition, it is quite easy to see that, e.g., the numbers in the first row cannot be represented by the function proposed by elias.

Finally, to answer the OP's question, we remark that the obvious bijection between the two squares serves as an "as simple as possible" function $f$. (So in particular, $f(4)=18$, $f(9)=4$, ..., $f(6)=8$, and undefined otherwise.)