# [seqfan] Re: A bijection involving 3x3 magic squares

Fred Lunnon fred.lunnon at gmail.com
Mon Apr 13 15:55:05 CEST 2020

```  Worth commenting in the sequence entry, I should think!    WFL

> Sequence A059329 is described as the number of 3 X 3 matrices, with
> elements from {0,...,n}, having the property that the middle element of
> each of the eight 3-element horizontal, vertical and diagonal lines equals
> the average of the two end elements.
>
> I found this sequence while attempting to solve a different problem: What
> is the number of 3 X 3 magic squares with elements from {0, ..., n}, with
> repetitions allowed?
>
> I was surprised that these questions seem to have the same answer. After a
> bit of thought, I found that there is a bijection between the two types of
> arrays. If
> A B C
> D E F
> G H I
> is a 3 X 3 matrix satisfying the definition of A059329, then
> H A F
> C E G
> D I B
> is a 3 X 3 magic square, and conversely.
>
> For example,
> 0 1 2
> 3 4 5
> 6 7 8
> is a 3 X 3 matrix satisfying the condition of A059329, and the
> corresponding 3 X 3 magic square is
> 7 0 5
> 2 4 6
> 3 8 1
>