# Magic circle (mathematics)

Magic circles were invented by the Song dynasty (960–1279) Chinese mathematician Yang Hui (c. 1238–1298). It is the arrangement of natural numbers on circles where the sum of the numbers on each circle and the sum of numbers on diameters are identical. One of his magic circles was constructed from the natural numbers from 1 to 33 arranged on four concentric circles, with 9 at the center.

## Yang Hui magic circles

Yang Hui's magic circle series was published in his Xugu Zhaiqi Suanfa《續古摘奇算法》(Sequel to Excerpts of Mathematical Wonders) of 1275. His magic circle series includes: magic 5 circles in square, 6 circles in ring, magic eight circle in square magic concentric circles, magic 9 circles in square.

### Yang Hui magic concentric circle

Yang Hui's magic concentric circle has the following properties
* The sum of the numbers on four diameters = 147,
** 28 + 5 + 11 + 25 + 9 + 7 + 19 + 31 + 12 = 147
* The sum of 8 numbers plus 9 at the center = 147;
** 28 + 27 + 20 + 33 + 12 + 4 + 6 + 8 + 9 = 147
* The sum of eight radius without 9 = magic number 69: such as 27 + 15 + 3 + 24 = 69
* The sum of all numbers on each circle (not including 9) = 2 × 69
* There exist 8 semicircles, where the sum of numbers = magic number 69; there are 16 line segments (semicircles and radii) with magic number 69, more than a 6 order magic square with only 12 magic numbers.

### Yang Hui magic eight circles in a square

64 numbers (1–64) are arranged in eight circles, each with eight numbers; each circle sums to 260. The total sum of all numbers is 2080 (=8×260). The circles are arranged in a 3×3 square grid with the center area open in a way that also makes the horizontal / vertical sum along the central columns and rows is 260, and the total sum of the numbers along both diagonals is 520.
Yang Hui magic eight circles in a square :
| 40 + 24 + 9 + 56 + 41 + 25 + 8 + 57 | =260 | 14 + 51 + 46 + 30 + 3 + 62 + 35 + 19 | =260 | 45 + 29 + 4 + 61 + 36 + 20 + 13 + 52 | =260 | | |
| 48 + 32 + 1 + 64 + 33 + 17 + 16 + 49 | =260 | | | 37 + 21 + 12 + 53 + 44 + 28 + 5 + 60 | =260 | (49 + 16 + 1 + 64) + (60 + 5 + 12 + 53) | =260 |
| 38 + 22 + 11 + 54 + 43 + 27 + 6 + 59 | =260 | 7 + 58 + 39 + 23 + 10 + 55 + 42 + 26 | =260 | 47 + 31 + 2 + 63 + 34 + 18 + 15 + 50 | =260 | | |
| | | (14 + 51 + 62 + 3) + (7 + 58 + 55 + 10) | =260 | | | (40 + 57 + 41 + 56) + (50 + 47 + 34 + 63) + (29 + 4 + 13 + 20) + (22 + 11 + 6 + 27) | =2 × 260 = 520 |

### Yang Hui magic nine circles in a square

72 numbers from 1 to 72, arranged in nine circles of eight numbers in a square; with neighbouring numbers forming four additional eight number circles: thus making a total of 13 eight number circles:
| NW | | N | | NE |
| | x1 | | x2 | |
| W | | C | | E |
| | x3 | | x4 | |
| SW | | S | | SE |
Extra circle x1 contains numbers from circles NW, N, C, and W; x2 contains numbers from N, NE, E, and C; x3 contains numbers from W, C, S, and SW; x4 contains numbers from C, E, SE, and S.
* Total sum of 72 numbers = 2628;
* sum of numbers in any eight number circle = 292;
* sums of three circles along horizontal lines = 876;
* sum of three circles along vertical lines = 876;
* sum of three circles along the diagonals = 876.

## Ding Yidong magic circles

Ding Yidong was a mathematician contemporary with Yang Hui. In his magic circle with 6 rings, the unit numbers of the 5 outer rings, combined with the unit number of the center ring, form the following magic square:
    492 357 816
Method of construction:
    Let radial group 1 =1,11,21,31,41
    Let radial group 2=2,12,22,32,42
    Let radial group 3=3,13,23,33,43
    Let radial group 4=4,14,24,34,44
    Let radial group 6=6,16,26,36,46
    Let radial group 7=7,17,27,37,47
    Let radial group 8=8,18,28,38,48
    Let radial group 9=9,19,29,39,49
    Let center group =5,15,25,35,45
Arrange group 1,2,3,4,6,7,9 radially such that
* each number occupies one position on circle
* alternate the direction such that one radial has smallest number at the outside, the adjacent radial has largest number outside.
* Each group occupies the radial position corresponding to the number on the Luoshu magic square, i.e., group 1 at 1 position, group 2 at 2 position etc.
* Finally arrange center group at the center circle, such that
    number 5 on group 1 radial
    number 10 on group 2 radial
    number 15 on group 3 radial
    number 45 on group 9 radial

## Cheng Dawei magic circles

Cheng Dawei, a mathematician in the Ming dynasty, in his book Suanfa Tongzong listed several magic circles

## Extension to higher dimensions

In 1917, W. S. Andrews published an arrangement of numbers 1, 2, 3, and 62 in eleven circles of twelve numbers each on a sphere representing the parallels and meridians of the Earth, such that each circle has 12 numbers totalling 378.

## Relationship with magic squares

A magic circle can be derived from one or more magic squares by putting a number at each intersection of a circle and a spoke. Additional spokes can be added by replicating the columns of the magic square.
In the example in the figure, the following 4 × 4 most-perfect magic square was copied into the upper part of the magic circle. Each number, with 16 added, was placed at the intersection symmetric about the centre of the circles. This results in a magic circle containing numbers 1 to 32, with each circle and diameter totalling 132.
| 6 | 15 | 4 | 9 |
| 3 | 10 | 5 | 16 |
| 13 | 8 | 11 | 2 |
| 12 | 1 | 14 | 7 |