MatMod logo

The 6-Magic Star (mstar)

Run LPL Code  ,  PDF Document

Problem

A 6-pointed magic star is a star polygon in which numbers are placed at each of the 6 vertices and 6 intersections, such that the four numbers on each line sum to the same magic constant (see Figure 1).


PIC

Figure 1: The 6-Magic Star


The 6-magic star contains the consecutive integers 1 to 12 without repetition. The magic constant of a 6-pointed normal magic star is S = 26. Write a mathematical model that solves the problem (See: planetseed).

Modeling Steps

Let the order of the star by N, for the 6-star, we have N = 6. The set of all points is i = {12N} (there are 12 points for the 6-star). The star has N lines containing 4 points each. We model this by a set of lines (j = {1N}) and the number of points on a line as (k = {14}). We order the points in such a way – clockwise starting at noon – that it is easy to specify the 6 lines. The data table aj,k identifies the k-th point on the j-th line. For example, the third point on line 6 is point number 2 (since a6,3 = 2). The table is assigned as follows:

aj,k = (2j - 1 + if(k < 3,k - 2,k -  1))  mod  12 + 1

  1. We introduce an alldiff variable xi – integer variable where the values of all 12 variables are different (from 1 to 12) (a permutation). An additional variable S is the sum on the lines.

  2. On each line, the 4 corresponding variables are summed up and must be equal to S:

    ∑  xa   = S   forall j    j,k  k
  3. There is only a feasible solution needed.

Listing 1: The Complete Model implemented in LPL [2]

model mstar "The 6-Magic Star"; 
  parameter N:=6; 
  set j:=1..N; k:=1..4; 
      i:=1..2*N; 
  parameter a{j,k}:=(2*j-1+if(k<3,k-2,k-1))%#i+1; 
  alldiff variable x{i} [1..#i+if(N=5,2)]; 
  integer variable S; 
  constraint A{j}: sum{k} x[a] = S; 
  solve; 
  parameter PI:=3.14159; r:=10; g:=PI/N; f:=2*g; 
    s:=(Sin(f)*Cos(f)) / (Sin(f)*Cos(g)); 
  parameter X{i}:=if(i%2=0,s*r,r)*Cos((i-1)*g-PI/2); 
  parameter Y{i}:=if(i%2=0,s*r,r)*Sin((i-1)*g-PI/2); 
  string SS{i}:=['A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L']; 
  Draw.Scale(20,20); 
  {j} Draw.Line(X[a[j,1]],Y[a[j,1]],X[a[j,4]],Y[a[j,4]]); 
  {i} Draw.Circle(x&'',X,Y,1,1,0); 
  --{i} Draw.Circle(SS,X,Y,1,1,0); 
  Draw.Text('sum='&S,-r,-r); 
end

To draw the solution – and the star – the positions of the circles are calculated and stored in the two vectors Xi and Y i (Hint: a point (x,y) on a circle with center (0, 0) is calculated as follows, see Figure 2):

x = rcos(α )  ,  y = r sin (α )

PIC

Figure 2: Position (x,y) on a circle


The outer radius on the star is r, and the inner radius ris s r, (s being the factor) hence:

 ′   sin(2π∕N-)-⋅ cos(2π∕N-) r  =  sin (2 π∕N ) ⋅ cos(π ∕N ) ⋅ r

Solution

The solution is given in Figure 3. The number on each line sums up to 26 (4N + 2).


PIC

Figure 3: Solution of the 6-Magic Star


Further Comments

No star polygons with less than 5 points exist, and the construction of a normal 5-pointed magic star turns out to be impossible, except we accept numbers in the interval [112]. The smallest examples of normal magic stars are therefore 6-pointed. Notice that for specific values of N, the N-pointed magic stars are also known as magic hexagram. With N 7, there are several “configurations”

(see http://www.magic-squares.net/magic_stars_index.htm).

Questions

  1. Find the value s for calculating the inner radius r= s r.

  2. Run the model with N = 7 then N = 8

Answers

  1. One can use vector geometry to calculate s. Refer to Figure 4 for the following explanation.


    PIC

    Figure 4: A Part of a Magic Star


    Let N be the order of the magic star, then we define α = 2π∕N. We have (see Figure): |OP| = s ⋅|OC|. Furthermore we have:

     ⃗    ⃗  ⃗ s ⋅OC   =  OA  + β ⋅AX

    Hence we get:

       (r cos(3α ∕2))   (r cos(2α ))   [(r  cos(0 )) (r cos(2α)) ] s ⋅      =     + β ⋅    -   rsin(3α∕2 )   r sin(2α )    r sin(0)    rsin(2α)

    From the two equations we can easily derive β and s, and hence the formula above for s.

  2. The only change is the definition of N. The whole graph will be drawn correctly. Verify! The solution graph with N = 7 and n = 8 is shown in Figure 5.


    PIC PIC

    Figure 5: a Magic Star with N = 7 and N = 8


References

[1]   MatMod. Homepage for Learning Mathematical Modeling :  https://matmod.ch.

[2]   Hürlimann T. Reference Manual for the LPL Modeling Language, most recent version. https://matmod.ch/lpl/doc/manual.pdf.