Ramanujan's method for solving a Magic Square Ramanujan came up with a formula for solving a magic square.

Theorem 1: Let $m_1,m_2$ denote the sums of the middle row and middle column respectively for a $3\times 3$ square array of numbers. Let $c_1,c_2$ denote the sums of the main diagonal and secondary diagonal respectively. And lastly, let $S$ denote the sum of all nine elements of the square. If $x$ denotes the center element, then$$x=\frac 13\left(m_1+m_2+c_1+c_2-S\right)\tag1$$
Suppose that the sum of each row and column is equal to $r$. Then, we have$$x=\frac 13\left(c_1+c_2-r\right)\tag2$$
And note that that implies that $x=\frac r3$, so $r$ is a multiple of $3$.
And lastly, in a $3\times 3$ magic square, the elements in the middle row, middle column and diagonals are in arithmetic progression. More clearly, let $a,b$ be the first and third elements respectively. Then$$a+r/3+b=r\tag3$$Hence$$b-r/3=r/3-a\tag4\\\vdots$$


Although the formula is clear, I'm just wondering how you would go about actually solving a magic square.

Question: Using Theorem 1, how would you solve a magic square? (Example provided below)


For example:


*

*Construct a magic square with $r=15$ and all numbers are odd!



My Attempt:  Since $r=15$, we have $x=15/3=5$. Thus, the middle digit$^{[1]}$ is $5$. From $(3)$, we get a Diophantine equation, and solving we get $$(a,b)=(1,9)\\(a,b)=(3,7)\\(a,b)=(5,5)\tag5$$
After that, I'm not sure what to do. I have $3$ possible $a,b$ values and I'm not sure which two I should use. Any help would be accepted!
$\scriptsize{[1]:\text{Maybe..?}}$


You can always arrange (rotate, reflect, etc.) the numbers in a magic square so that the smallest is top-middle and the next is bottom-right. Then there are two possible arrays of ranks of the $9$ numbers.
\begin{array}{cc}
   \text{TYPE 1} & \text{TYPE 0} \\ 
      \begin{pmatrix}
         8 & 1 & 6 \\ 3 & 5 & 7 \\ 4 & 9 & 2
      \end{pmatrix} 
   &
      \begin{pmatrix}
         8 & 1 & 7 \\ 4 & 5 & 6 \\ 3 & 9 & 2
      \end{pmatrix}
\end{array}
The first is itself a magic square, the second is not. The nicest examples of a TYPE$1$ and a TYPE $0$ magic square are
$$
   M_1 = \begin{pmatrix}
         8 & 1 & 6 \\ 3 & 5 & 7 \\ 4 & 9 & 2
         \end{pmatrix}
  \qquad
   M_0 = \begin{pmatrix}
         8 & 0 & 7 \\ 4 & 5 & 6 \\ 3 & 10 & 2
         \end{pmatrix}
$$

The first $9$ odd numbers are
$$1,3,5,7,\color{red}9,11,13,15,17$$
with $9$ in the middle. So the smallest magic sum has to be $3\times 9 = 27$.
That means that $r=15$ is not possible.
The smallest TYPE$1$ magic square would be
$$2M_1 - 1 = \begin{pmatrix}
         15 & 1 & 11 \\ 5 & 9 & 13 \\ 7 & 17 & 3
         \end{pmatrix}$$
The smallest TYPE$0$ magic square would be
$$2M_0 + 1 = \begin{pmatrix}
                17 & 1 & 15 \\ 9 & 11 & 13 \\ 7 & 21 & 5
             \end{pmatrix}$$
