home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / GAMES / MAGIC28.ZIP / MAGIC.DOC next >
Text File  |  1994-01-22  |  3KB  |  63 lines

  1. MAGIC - Magic Squares, Version 2.8 (1/22/94), Copyright (c) 1988-1994 by
  2. Gordon C. Everstine, 15803 Lautrec Court, Gaithersburg, MD 20878
  3. Telephone: 301-977-0936
  4.  
  5. One mathematical amusement which has fascinated people for centuries is the
  6. magic square, a square array (or matrix) of numbers having the property that
  7. the sum of the entries in any row, column, or main diagonal is always the same.
  8. For example, a magic square of order 6 is
  9.  
  10.                            31  2  3 34  5 36
  11.                            30 26  9 10 29  7
  12.                            24 23 16 15 14 19
  13.                            13 17 22 21 20 18
  14.                            12  8 28 27 11 25
  15.                             1 35 33  4 32  6
  16.  
  17. For this array, the sum of any row, column, or main diagonal is 111.  Although
  18. magic squares are mathematical curies, their fascination has perhaps resulted
  19. from the symmetry and order which they possess.
  20.  
  21. Normally, interest in magic squares is restricted to those formed from the
  22. first N*N positive integers, where N is the order (or size) of the square.  The
  23. reason for this seemingly restricted interest is that squares having negative
  24. or fractional numbers offer no additional generality, because such squares can
  25. always be transformed into positive integer squares by adding or multiplying
  26. every entry by a suitable constant.
  27.  
  28. The IBM PC program which accompanies this text file computes magic squares for
  29. any order square between 3 and 170.  The upper limit of 170 is not a limitation
  30. of the algorithms, which are fully general, but of the memory available in
  31. Basic, because the program stores the entire square in an array.  Squares of
  32. order 2 do not exist; order 1 is trivial.
  33.  
  34. Odd and even order squares must be constructed by different approaches.  For
  35. odd orders, the program uses a recursive scheme devised by de la Loubere about
  36. 300 years ago.  For even orders, the program uses the Devedec algorithm.  Even
  37. orders not divisible by 4 are formed slightly differently from those which are
  38. divisible by 4 (doubly even).
  39.  
  40. The program displays magic squares of order up to 20 in the same way that the
  41. example of order six was displayed above.  For larger squares, a row will not
  42. fit on one line of the (80-column) screen, so that each row of the square is
  43. displayed on several lines of the screen.  Squares may also be printed; for
  44. larger squares, fan-fold paper is required, since the program prints the square
  45. in several long blocks which can be arranged side-by-side.  Squares may also be
  46. written to a file (MAGIC.OUT); each request to write to file appends the
  47. current square to the end of the file.
  48.  
  49. The correctness of a square may be optionally checked.  This check is primarily
  50. to verify that the program has not been corrupted during copying or
  51. downloading.
  52.  
  53. The time required to calculate a magic square is roughly proportional to N*N,
  54. the square of the order.  However, this implementation is efficient enough that
  55. most squares are computed essentially instantaneously.  The square of order 170
  56. requires about four seconds on an IBM XT.  The checking of a square takes
  57. longer than the calculation, since sums must be accumulated in double
  58. precision.
  59.  
  60. For more information about magic squares, see, for example, "Magic Squares and
  61. Cubes" by W.S. Andrews (The Open Court Publishing Co., Chicago, 1908) and
  62. "Mathematical Recreations" by M. Kraitchik (Dover, 1953).
  63.