magic                 package:magic                 R Documentation

_C_r_e_a_t_e_s _m_a_g_i_c _s_q_u_a_r_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Creates normal magic squares of any order >2.  Uses the
     appropriate method depending on n modulo 4.

_U_s_a_g_e:

     magic(n)

_A_r_g_u_m_e_n_t_s:

       n: Order of magic square

_D_e_t_a_i_l_s:

     Calls either 'magic.2np1()', 'magic.4n()', or 'magic.4np2()'
     depending on the value of 'n'.  Returns a magic square in standard
     format (compare the 'magic.2np1()' et seq, which return the square
     as generated by the direct algorithm).

_A_u_t_h_o_r(_s):

     Robin K. S. Hankin

_R_e_f_e_r_e_n_c_e_s:

     William H. Benson and Oswald Jacoby.  New recreations with magic
     squares, Dover 1976.

_S_e_e _A_l_s_o:

     'magic.2np1', 'magic.prime', 'magic.4np2', 'magic.4n','lozenge',
     'as.standard', 'force.integer'

_E_x_a_m_p_l_e_s:

     magic(6)
     all(sapply(3:10,function(n){is.magic(magic(n))}))

     ## The first eigenvalue of a magic square is equal to the magic constant:
     eigen(magic(10),FALSE,TRUE)$values[1] - magic.constant(10)

     ## The sum of the eigenvalues of a magic square after the first is zero:
     sum(eigen(magic(10),FALSE,TRUE)$values[2:10])

