Goto Chapter: Top 1 2 3 4 Bib Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

2 The field SqrtField
 2.1 Definition of the field
 2.2 Construction of elements
 2.3 Basic operations

2 The field SqrtField

2.1 Definition of the field

The field \(\mathbb{Q}^{\sqrt{}}(\imath)\) with \(\mathbb{Q}^{\sqrt{}}=\mathbb{Q}(\{\sqrt{p}\mid p\textrm{ a prime}\})\) and \(\imath=\sqrt{-1}\in\mathbb{C}\) is realised as SqrtField. A few functions print some information on what they are doing to the info class InfoSqrtField; this can be turned off by setting SetInfoLevel( InfoSqrtField, 0 );.

2.1-1 SqrtFieldIsGaussRat
‣ SqrtFieldIsGaussRat( q )( function )

Here q is an element of SqrtField; this function returns true if and only if q is the product of One(SqrtField) and a Gaussian rational.

gap> F := SqrtField;
gap> IsField( F ); LeftActingDomain( F ); Size( F ); Characteristic( F );
gap> one := One( F );
gap> 2 in F; 2*one in F; 2*E(4)*one in F;
gap> a := 2/3*E(4)*one;; 
gap> a in SqrtField; a in GaussianRationals; SqrtFieldIsGaussRat( a );

2.2 Construction of elements

Every \(f\) in SqrtField can be uniquely written as \(f=\sum_{j=1}^m r_i \sqrt{k_j}\) for Gaussian rationals \(r_i\in\mathbb{Q}(\imath)\) and pairwise distinct squarefree positive integers \(k_1,\ldots,k_m\). Thus, \(f\) can be described efficiently by its coefficient vector \([[r_1,k_1],\ldots,[r_j,k_j]]\).

2.2-1 Sqroot
‣ Sqroot( q )( function )

Here q is a rational number and Sqroot(q) is the element \(\sqrt{q}\) as an element of SqrtField. If \(q=(-1)^\epsilon a/b\) with coprime integers \( a,b\geq 0\) and \(\epsilon\in\{0,1\}\), then Sqroot(q) is represented as the element E(4)\(^\varepsilon\)*b*Sqroot(ab) of SqrtField.

2.2-2 CoefficientsOfSqrtFieldElt
‣ CoefficientsOfSqrtFieldElt( f )( function )

If f is an element in SqrtField, then CoefficientsOfSqrtFieldElt(f) returns its coefficient vector \([[r_1,k_1],\ldots,[r_m,k_m]]\) as described above, that is, \(r_1,\ldots,r_m\in\mathbb{Q}(\imath)\) and \(k_1,\ldots,k_m\) are pairwise distinct positive squarefree integers such that \(f=\sum_{j=1}^m r_j\sqrt{k_j}\).

2.2-3 SqrtFieldEltByCoefficients
‣ SqrtFieldEltByCoefficients( l )( function )

If l is a list \([[r_1,k_1],\ldots,[r_m,k_m]]\) with Gaussian rationals \(r_j\) and rationals \(k_j\), then SqrtFieldEltByCoeffiients(l) returns the element \(\sum_{j=1}^m r_j\sqrt{k_j}\) as an element of SqrtField. Note that here \(k_1,\ldots,k_m\) need not to be positive, squarefree, or pairwise distinct.

gap> Sqroot(-(2*3*4)/(11*13)); Sqroot(245/15); Sqroot(16/9);
gap> a := 2+Sqroot(7)+Sqroot(99);
2 + Sqroot(7) + 3*Sqroot(11)
gap> CoefficientsOfSqrtFieldElt(a);
[ [ 2, 1 ], [ 1, 7 ], [ 3, 11 ] ]
gap> SqrtFieldEltByCoefficients([[2,9],[1,7],[E(4),13]]);
6 + Sqroot(7) + E(4)*Sqroot(13)

2.2-4 SqrtFieldEltToCyclotomic
‣ SqrtFieldEltToCyclotomic( f )( function )

If f lies in SqrtField with coefficient vector \([[r_1,k_1],\ldots,[r_m,k_m]]\), then SqrtFieldEltToCyclotomic(f) returns \(\sum_{j=1}^m r_j\sqrt{k_j}\) lying in a suitable cyclotomic field CF(n). The degree \(n\) can easily become too large, hence this function should be used with caution.

2.2-5 SqrtFieldEltByCyclotomic
‣ SqrtFieldEltByCyclotomic( c )( function )

If c is an element of \(\mathbb{Q}^{\sqrt{}}(\imath)\) represented as an element of a cyclotomic field CF(n), then SqrtFieldEltByCyclotomic(c) returns the corresponding element in SqrtField. Our algorithm for doing this is described in [DG13].

gap> SqrtFieldEltToCyclotomic( Sqroot(2) );
gap> SqrtFieldEltToCyclotomic( Sqroot(2)+E(4)*Sqroot(7) );
gap> SqrtFieldEltByCyclotomic( E(8)-E(8)^3 );
gap> SqrtFieldEltByCyclotomic( 3*E(4)*Sqrt(11)-2/4*Sqrt(-13/7) );
3*E(4)*Sqroot(11) + (-1/14*E(4))*Sqroot(91)

2.3 Basic operations

All basic field operations are available. The inverse of an element \(f\) in SqrtField as follows: We first compute the minimal polynomial \(p(X)\) of \(f\) over \(\mathbb{Q}(\imath)\), that is, a non-trivial linear combination \(0=p(f)=a_0+a_1 f+\ldots a_{i-1}f^{i-1}+f^i\). Then \(f^{-1}=-(a_1+a_2f+\ldots+a_{i-1}f^{i-2}+f^{i-1})/a_0\). Although the inverse of \(f\) can be computed with linear algebra methods only, the degree of the minimal polynomial of \(f\) can become rather large. For example, if \(f=\sum_{j=1}^m r_i \sqrt{k_j}\) for rational \(r_i\) and pairwise distinct positive squarefree integers \(k_1,\ldots,k_m\), then \(f\) is a primitive element of the number field \(\mathbb{Q}(\sqrt{k_1},\ldots,\sqrt{k_m})\), see for example Lemma A.5 in [DG13]. For larger degree, the progress of the computation of the inverse is printed via the InfoClass InfoSqrtField. We remark that the method Random simply returns a sum of a few terms \(a\sqrt{b}\) where \(a,b\) are random rationals constructed with Random(Rationals).

gap> a := Sqroot( 2 ) + 3 * Sqroot( 3/7 ); b := Sqroot( 21 ) - Sqroot( 2 );
Sqroot(2) + 3/7*Sqroot(21)
(-1)*Sqroot(2) + Sqroot(21)
gap> a + b; a * b; a - b;
7 + 4/7*Sqroot(42)
2*Sqroot(2) + (-4/7)*Sqroot(21)
gap> c := ( a - b )^-2;
91/8 + 7/4*Sqroot(42)
gap> a := Sum( List( [2,3,5,7], x -> Sqroot( x ) ) );
Sqroot(2) + Sqroot(3) + Sqroot(5) + Sqroot(7)
gap> b := a^-1; a*b;                                  
37/43*Sqroot(2) + (-29/43)*Sqroot(3) + (-133/215)*Sqroot(5) + 
27/43*Sqroot(7) + 62/215*Sqroot(30) + (-10/43)*Sqroot(42) + (-34/215)*Sqroot(70) 
+ 22/215*Sqroot(105)
gap> ComplexConjugate(Sqroot(17)+Sqroot(-7));
(-E(4))*Sqroot(7) + Sqroot(17)
gap> Random( SqrtField );
-1 + 1/4*Sqroot(3) + 1/9*Sqroot(6)

Most methods for list, matrices, and polynomials also work over SqrtField.

gap> m:=[[Sqroot(2),Sqroot(3)],[Sqroot(2),Sqroot(5)],[1,0]]*One(SqrootField);
[ [ Sqroot(2), Sqroot(3) ], [ Sqroot(2), Sqroot(5) ], [ 1, 0 ] ]
gap> NullspaceMat(m);
[ [ (-5/4)*Sqroot(2) + (-1/4)*Sqroot(30), 3/4*Sqroot(2) + 1/4*Sqroot(30), 1 ] ]
gap> RankMat(m);
gap> m := [[Sqroot(2),Sqroot(3)],[Sqroot(2),Sqroot(5)]];  
[ [ Sqroot(2), Sqroot(3) ], [ Sqroot(2), Sqroot(5) ] ]
gap> Determinant( m );  DefaultFieldOfMatrix( m );
(-1)*Sqroot(6) + Sqroot(10)
gap> x := Indeterminate( SqrtField, "x" );; f := x^2+x+1;

2.3-1 SqrtFieldMakeRational
‣ SqrtFieldMakeRational( m )( function )

If m is an element of SqrtField, or a list or a matrix over SqrtField, defined over the Gaussian rationals, then SqrtFieldMakeRational( m ) returns the corresponding element in \(\mathbb{Q}(\imath)\) or defined over \(\mathbb{Q}(\imath)\), respectively. This function is used internally, for example, to compute the determinant or rank of a rational matrix over SqrtField more efficiently. It is also used in the following three functions.

2.3-2 SqrtFieldPolynomialToRationalPolynomial
‣ SqrtFieldPolynomialToRationalPolynomial( f )( function )

Here f is a polynomial over SqrtField but with coefficients in the Gaussian rationals. The function returns the corresponding polynomial defined over the Gaussian rationals.

2.3-3 SqrtFieldRationalPolynomialToSqrtFieldPolynomial
‣ SqrtFieldRationalPolynomialToSqrtFieldPolynomial( f )( function )

If f is a polynomial over the Gaussian rationals, then the function returns the corresponding polynomial defined over SqrtField.

2.3-4 Factors
‣ Factors( f )( operation )

If f is a rational polynomial defined over SqrtField, then the previous two functions are used to obtain its factorisation over \(\mathbb{Q}\).

gap> F := SqrtField;; one := One( SqrtField );;                 
gap> x := Indeterminate( F, "x" );; f := x^5 + 4*x^3 + E(4)*one*x;
gap> SqrtFieldPolynomialToRationalPolynomial(f);
gap> SqrtFieldRationalPolynomialToSqrtFieldPolynomial(last);
gap> f := x^2-1;; Factors(f);
[ x-1, x+1 ]
gap> f := x^2+1;; Factors(f);
[ x^2+1 ]
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 Bib Ind

generated by GAPDoc2HTML