home *** CD-ROM | disk | FTP | other *** search
/ Math Solutions 1995 October / Math_Solutions_CD-ROM_Walnut_Creek_October_1995.iso / pc / mac / discrete / doc / gaussian.tex < prev    next >
Encoding:
Text File  |  1993-05-05  |  13.9 KB  |  370 lines

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %%
  3. %A  gaussian.tex                GAP documentation            Martin Schoenert
  4. %%
  5. %A  @(#)$Id: gaussian.tex,v 3.5 1993/02/01 13:25:57 felsch Exp $
  6. %%
  7. %Y  Copyright 1990-1992,  Lehrstuhl D fuer Mathematik,  RWTH Aachen,  Germany
  8. %%
  9. %%  This file describes Gaussian integers and rationals and their  functions.
  10. %%
  11. %H  $Log: gaussian.tex,v $
  12. %H  Revision 3.5  1993/02/01  13:25:57  felsch
  13. %H  example fixed
  14. %H
  15. %H  Revision 3.4  1992/04/06  16:54:53  martin
  16. %H  fixed some more typos
  17. %H
  18. %H  Revision 3.3  1992/04/02  21:06:23  martin
  19. %H  changed *domain functions* to *set theoretic functions*
  20. %H
  21. %H  Revision 3.2  1992/03/11  15:51:46  sam
  22. %H  renamed chapter "Number Fields" to "Subfields of Cyclotomic Fields"
  23. %H
  24. %H  Revision 3.1  1992/01/08  11:41:10  martin
  25. %H  initial revision under RCS
  26. %H
  27. %%
  28. \Chapter{Gaussians}%
  29. \index{type!gaussian rationals}
  30. \index{type!gaussian integers}
  31.  
  32. If we adjoin a square root of -1, usually denoted by $i$, to the field of
  33. rationals we obtain a field that is an extension of degree 2.  This field
  34. is called the *Gaussian rationals* and its ring of integers is called the
  35. *Gaussian integers*, because C.F. Gauss was the first to study them.
  36.  
  37. In {\GAP} Gaussian rationals are written in the  form '<a>  + <b>\*E(4)',
  38. where <a> and  <b> are rationals,  because 'E(4)'  is {\GAP}\'s name  for
  39. $i$.  Because 1 and $i$ form an integral base  the Gaussian  integers are
  40. written in the form '<a> + <b>\*E(4)', where <a> and <b> are integers.
  41.  
  42. The first sections in this  chapter describe the operations applicable to
  43. Gaussian rationals (see "Comparisons  of  Gaussians" and "Operations  for
  44. Gaussians").
  45.  
  46. The next sections describe the functions that test whether an object is a
  47. Gaussian rational or integer (see "IsGaussRat" and "IsGaussInt").
  48.  
  49. The {\GAP} object 'GaussianRationals' is the field domain of all Gaussian
  50. rationals,  and the object 'GaussianIntegers'  is the ring domain of  all
  51. Gaussian  integers.  All  set theoretic functions are applicable to those
  52. two domains (see chapter "Domains" and "Set Functions for Gaussians").
  53.  
  54. The Gaussian rationals form a field so all field functions, e.g., 'Norm',
  55. are  applicable to the domain  'GaussianRationals'  and its elements (see
  56. chapter "Fields" and "Field Functions for Gaussian Rationals").
  57.  
  58. The Gaussian integers  form a Euclidean ring so all ring functions, e.g.,
  59. 'Factors', are applicable to  'GaussianIntegers'  and its  elements  (see
  60. chapter   "Rings",   "Ring   Functions  for   Gaussian   Integers",   and
  61. "TwoSquares").
  62.  
  63. The field of Gaussian  rationals is  just a  special  case of  cyclotomic
  64. fields,  so everything that applies to  those fields also  applies  to it
  65. (see chapters "Cyclotomics" and "Subfields of Cyclotomic Fields").
  66.  
  67. All functions are in the library file 'LIBNAME/\"gaussian.g\"'.
  68.  
  69. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  70. \Section{Comparisons of Gaussians}%
  71. \index{equality!of gaussians}%
  72. \index{ordering!of gaussians}
  73.  
  74. '<x> = <y>' \\
  75. '<x> \<> <y>'
  76.  
  77. The  equality operator evaluates  to 'true' if  the two Gaussians <x> and
  78. <y> are  equal, and to 'false' otherwise.   The inequality operator '\<>'
  79. evaluates to 'true' if the  two Gaussians <x> and <y>  are not equal, and
  80. to 'false' otherwise.  It is also possible  to compare a Gaussian with an
  81. object of another type, of course they are never equal.
  82.  
  83. Two Gaussians '<a>  +  <b>\*E(4)' and  '<c> + <d>\*E(4)'   are considered
  84. equal if '<a> = <c>' and '<b> = <d>'.
  85.  
  86. |    gap> 1 + E(4) = 2 / (1 - E(4));
  87.     true
  88.     gap> 1 + E(4) = 1 - E(4);
  89.     false
  90.     gap> 1 + E(4) = E(6);
  91.     false |
  92.  
  93. '<x> \< <y>' \\
  94. '<x> \<= <y>' \\
  95. '<x> > <y>' \\
  96. '<x> >= <y>'
  97.  
  98. The operators  '\<',  '\<=', '>',  and  '>='  evaluate to  'true' if  the
  99. Gaussian  <x> is  less  than, less  than or equal   to, greater than, and
  100. greater  than or equal to  the  Gaussian <y>,  and  to 'false' otherwise.
  101. Gaussians can   also be compared  to objects   of other types,  they  are
  102. smaller than anything else, except other cyclotomics (see "Comparisons of
  103. Cyclotomics").
  104.  
  105. A Gaussian '<a>  +  <b>\*E(4)' is considered  less  than another Gaussian
  106. '<c> + <d>\*E(4)' if <a> is less than <c>, or if <a> is  equal to <c> and
  107. <b> is less than <d>.
  108.  
  109. |    gap> 1 + E(4) < 2 + E(4);
  110.     true
  111.     gap> 1 + E(4) < 1 - E(4);
  112.     false
  113.     gap> 1 + E(4) < 1/2;
  114.     false |
  115.  
  116. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  117. \Section{Operations for Gaussians}%
  118. \index{sum!of gaussians}\index{difference!of gaussians}%
  119. \index{product!of gaussians}\index{quotient!of gaussians}%
  120. \index{power!of gaussians}
  121.  
  122. '<x>  +  <y>' \\
  123. '<x>  -  <y>' \\
  124. '<x> \*\ <y>' \\
  125. '<x>  /  <y>'
  126.  
  127. The  operators '+', '-', '\*', and  '/' evaluate  to the sum, difference,
  128. product, and quotient of the two Gaussians <x> and <y>.  Of course either
  129. operand  may also be an  ordinary rational (see "Rationals"), because the
  130. rationals are embedded  into the Gaussian rationals.   On  the other hand
  131. the Gaussian  rationals  are embedded  into other   cyclotomic fields, so
  132. either operand may also be a cyclotomic (see "Cyclotomics").  Division by
  133. 0 is as usual an error.
  134.  
  135. '<x> \^\ <n>'
  136.  
  137. The operator '\^' evaluates to the  <n>-th power of the Gaussian rational
  138. <x>.  If  <n> is positive, the power  is defined as  the <n>-fold product
  139. '<x>\*<x>\*...<x>';   if <n> is    negative,   the power is  defined   as
  140. '(1/<x>)\^(-<n>)'; and if <n> is zero, the power is 1, even if <x> is 0.
  141.  
  142. |    gap> (1 + E(4)) * (E(4) - 1);
  143.     -2 |
  144.  
  145. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  146. \Section{IsGaussRat}%
  147. \index{test!for gaussian rational}
  148.  
  149. 'IsGaussRat( <obj> )'
  150.  
  151. 'IsGaussRat' returns 'true' if <obj>, which may be an object of arbitrary
  152. type, is a Gaussian rational and 'false' otherwise.  Will signal an error
  153. if <obj> is an unbound variable.
  154.  
  155. |    gap> IsGaussRat( 1/2 );
  156.     true
  157.     gap> IsGaussRat( E(4) );
  158.     true
  159.     gap> IsGaussRat( E(6) );
  160.     false
  161.     gap> IsGaussRat( true );
  162.     false |
  163.  
  164. 'IsGaussInt' can be used to test whether an object is a  Gaussian integer
  165. (see "IsGaussInt").
  166.  
  167. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  168. \Section{IsGaussInt}%
  169. \index{test!for gaussian integer}
  170.  
  171. 'IsGaussInt( <obj> )'
  172.  
  173. 'IsGaussInt' returns 'true' if <obj>, which may be an object of arbitrary
  174. type, is  a Gaussian integer, and  false otherwise.  Will signal an error
  175. if <obj> is an unbound variable.
  176.  
  177. |    gap> IsGaussInt( 1 );
  178.     true
  179.     gap> IsGaussInt( E(4) );
  180.     true
  181.     gap> IsGaussInt( 1/2 + 1/2*E(4) );
  182.     false
  183.     gap> IsGaussInt( E(6) );
  184.     false |
  185.  
  186. 'IsGaussRat' can be used to test whether an object is a Gaussian rational
  187. (see "IsGaussRat").
  188.  
  189. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  190. \Section{Set Functions for Gaussians}%
  191. \index{membership test!for gaussians}\index{in!for gaussians}%
  192. \index{Random!for gaussians}%
  193.  
  194. As  already mentioned in the  introduction of  this  chapter the  objects
  195. 'GaussianRationals'  and 'GaussianIntegers' are the  domains of  Gaussian
  196. rationals and integers respectively.  All  set theoretic functions, i.e.,
  197. 'Size' and 'Intersection',  are applicable to  these  domains  and  their
  198. elements (see chapter "Domains").  There does not seem to be an important
  199. use of  this however.  All functions not  mentioned here are  not treated
  200. specially, i.e., they are implemented by the  default function  mentioned
  201. in the respective section.
  202.  
  203. \vspace{5mm}
  204. 'in'
  205.  
  206. The  membership test   for     Gaussian rationals  is  implemented    via
  207. 'IsGaussRat' ("IsGaussRat").  The  membership test for  Gaussian integers
  208. is implemented via 'IsGaussInt' (see "IsGaussInt").
  209.  
  210. \vspace{5mm}
  211. 'Random'
  212.  
  213. A random Gaussian rational '<a> + <b>\*E(4)' is computed by combining two
  214. random  rationals  <a>  and  <b>  (see  "Set  Functions  for Rationals").
  215. Likewise  a  random  Gaussian  integer '<a> +  <b>\*E(4)' is  computed by
  216. combining  two random  integers  <a>  and  <b> (see  "Set  Functions  for
  217. Integers").
  218.  
  219. |    gap> Size( GaussianRationals );
  220.     "infinity"
  221.     gap> Intersection( GaussianIntegers, [1,1/2,E(4),-E(6),E(4)/3] );
  222.     [ 1, E(4) ] |
  223.  
  224. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  225. \Section{Field Functions for Gaussian Rationals}%
  226. \index{Conjugates!for gaussians}%
  227. \index{Norm!for gaussians}%
  228. \index{Trace!for gaussians}
  229.  
  230. As already mentioned  in the introduction of this chapter,  the domain of
  231. Gaussian  rationals  is a  field.   Therefore  all  field  functions  are
  232. applicable to this domain and  its elements (see chapter "Fields").  This
  233. section gives  further comments on the definitions and implementations of
  234. those  functions  for  the the  Gaussian  rationals.   All  functions not
  235. mentioned here are not  treated specially, i.e., they are implemented  by
  236. the default function mentioned in the respective section.
  237.  
  238. \vspace{5mm}
  239. 'Conjugates'
  240.  
  241. The  field  of Gaussian  rationals  is  an  extension of degree 2 of  the
  242. rationals,  its prime field.  Therefore there is one further conjugate of
  243. every element '<a> + <b>\*E(4)', namely '<a> - <b>\*E(4)'.
  244.  
  245. \vspace{5mm}
  246. 'Norm', 'Trace'
  247.  
  248. According to the definition  of conjugates above, the  norm of a Gaussian
  249. rational    '<a> + <b>\*E(4)'  is  '<a>\^2  + <b>\^2'   and  the trace is
  250. '2\*<a>'.
  251.  
  252. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  253. \Section{Ring Functions for Gaussian Integers}%
  254. \index{IsUnit!for gaussians}\index{Units!for gaussians}%
  255. \index{IsAssociated!for gaussians}\index{Associates!for gaussians}%
  256. \index{StandardAssociate!for gaussians}%
  257. \index{mod!for gaussians}%
  258. \index{IsPrime!for gaussians}\index{IsIrreducible!for gaussians}%
  259. \index{Factors!for gaussians}
  260.  
  261. As already mentioned in  the introduction to  this chapter,  the  ring of
  262. Gaussian integers  is a Euclidean ring.  Therefore all ring functions are
  263. applicable to this  ring and  its  elements (see chapter "Rings").   This
  264. section gives further comments on  the definitions and implementations of
  265. those functions for the Gaussian integers.   All functions  not mentioned
  266. here are not treated specially, i.e., they are implemented by the default
  267. function mentioned in the respective section.
  268.  
  269. \vspace{5mm}
  270. 'IsUnit', 'Units', 'IsAssociated', 'Associates'
  271.  
  272. The units of 'GaussianIntegers' are '[ 1, E(4), -1, -E(4) ]'.
  273.  
  274. \vspace{5mm}
  275. 'StandardAssociate'
  276.  
  277. The standard associate  of  a  Gaussian  integer  <x> is the   associated
  278. element <y> of <x> that lies in the first  quadrant of the complex plane.
  279. That  is <y>  is  that element  from '<x> \*\ [1,-1,E(4),-E(4)]' that has
  280. positive real part and nonnegative imaginary part.
  281.  
  282. \vspace{5mm}
  283. 'Mod'
  284.  
  285. Define the integer part <i>  of the quotient of  <x> and <y> as the point
  286. of the  lattice spanned by 1 and  'E(4)' that lies next  to  the rational
  287. quotient of <x> and <y>, rounding towards the origin if there are several
  288. such  points.  Then 'Mod( <x>, <y> )'  is defined as '<x> - <i> \*\ <y>'.
  289. With  this definition the ordinary Euclidean  algorithm for  the greatest
  290. common divisor  works,  whereas  it  does  not work  if you  always round
  291. towards the origin.
  292.  
  293. \vspace{5mm}
  294. 'IsPrime', 'IsIrreducible'
  295.  
  296. Since the Gaussian integers are a Euclidean ring, primes and irreducibles
  297. are equivalent.  The primes are the elements '1 + E(4)' and '1 - E(4)' of
  298. norm 2, the elements  '<a> + <b>\*E(4)'  and  '<a> - <b>\*E(4)'  of  norm
  299. '<p> = <a>\^2 + <b>\^2' with <p> a  rational prime congruent  to 1 mod 4,
  300. and the elements <p> of norm '<p>\^2' with <p> a rational prime congruent
  301. to 3 mod 4.
  302.  
  303. \vspace{5mm}
  304. 'Factors'
  305.  
  306. The list returned by 'Factors'  is sorted according to  the norms of  the
  307. primes, and among those of equal norm with respect to '\<'.  All elements
  308. in  the  list  are  standard  associates,  except  the  first,  which  is
  309. multiplied by a unit as necessary.
  310.  
  311. The  above characterization already shows  how one  can factor a Gaussian
  312. integer.  First  compute the norm of the  element, factor this  norm over
  313. the rational integers and then split 2 and the  primes congruent to 1 mod
  314. 4 with 'TwoSquares' (see "TwoSquares").
  315.  
  316. |    gap> Factors( GaussianIntegers, 30 );
  317.     [ -1-E(4), 1+E(4), 3, 1+2*E(4), 2+E(4) ] |
  318.  
  319. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  320. \Section{TwoSquares}%
  321. \index{representation!as a sum of two squares}
  322.  
  323. 'TwoSquares( <n> )'
  324.  
  325. 'TwoSquares' returns a list of two integers $x\<=y$  such that the sum of
  326. the squares of $x$ and $y$ is equal to the nonnegative integer <n>, i.e.,
  327. $n = x^2+y^2$.  If no such representation exists 'TwoSquares' will return
  328. 'false'.  'TwoSquares' will return a representation  for which the gcd of
  329. $x$ and  $y$  is  as small  as  possible.    If there are    several such
  330. representations, it is not specified which one 'TwoSquares' returns.
  331.  
  332. Let $a$ be the product of all maximal powers of primes of the form $4k+3$
  333. dividing  $n$.  A representation of $n$ as a sum of two squares exists if
  334. and only if $a$ is a perfect square.  Let $b$ be the maximal power of $2$
  335. dividing  $n$, or  its  half, whichever is a  perfect  square.   Then the
  336. minimal possible gcd of $x$ and $y$ is the square root $c$ of $a b$.  The
  337. number  of  different minimal representations with $x\<=y$  is $2^{l-1}$,
  338. where $l$ is the number of different prime factors  of the form $4k+1$ of
  339. $n$.
  340.  
  341. |    gap> TwoSquares( 5 );
  342.     [ 1, 2 ]
  343.     gap> TwoSquares( 11 );
  344.     false        # no representation exists
  345.     gap> TwoSquares( 16 );
  346.     [ 0, 4 ]
  347.     gap> TwoSquares( 45 );
  348.     [ 3, 6 ]        # 3 is the minimal possible gcd because 9 divides 45
  349.     gap> TwoSquares( 125 );
  350.     [ 2, 11 ]        # not [ 5, 10 ] because this has not minimal gcd
  351.     gap> TwoSquares( 13*17 );
  352.     [ 5, 14 ]        # [10,11] would be the other possible representation
  353.     gap> TwoSquares( 848654483879497562821 );
  354.     [ 6305894639, 28440994650 ]        # 848654483879497562821 is prime |
  355.  
  356. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  357. %%
  358. %E  Emacs . . . . . . . . . . . . . . . . . . . . . local Emacs variables
  359. %%
  360. %%  Local Variables:
  361. %%  mode:               outline
  362. %%  outline-regexp:     "\\\\Chapter\\|\\\\Section"
  363. %%  fill-column:        73
  364. %%  eval:               (hide-body)
  365. %%  End:
  366. %%
  367.  
  368.  
  369.  
  370.