Computing the Length of Sum of Squares and Pythagoras Element in a Global Field
aa r X i v : . [ m a t h . N T ] F e b Computing the Length of Sum of Squares and PythagorasElement in a Global Field
Mawunyo Kofi Darkey-Mensah, Beata Rothkegel
Institute of Mathematics, University of Silesiaul. Bankowa 14, PL-40-007 Katowice, Poland
Abstract
This paper presents algorithms for computing the length of a sum of squaresand a Pythagoras element in a global field K of characteristic different from2. In the first part of the paper, we present algorithms for computing thelength in a non-dyadic and dyadic (if K is a number field) completion of K . These two algorithms serve as subsidiary steps for computing lengthsin global fields. In the second part of the paper we present a procedure forconstructing an element whose length equals the Pythagoras number of aglobal field, termed a Pythagoras element. Keywords:
Algorithms, Quadratic forms, Global fields, Length, Sum ofsquares, Pythagoras number, Pythagoras element.
1. Introduction
In this paper, we pursue the continuation of the recent work by P. Ko-prowski and A. Czoga la in [7] on the computational aspects of the theory ofquadratic forms over global fields. In [7] the authors focused on algorithmsover number fields (i.e. finite extensions of Q ). The authors in their pa-per developed algorithms for checking the isotropy of forms, and computingsome field invariants. The aim of this article is to present algorithms forcomputing the length of a sum of squares and a Pythagoras element (seeDefinition 7) in a global field of characteristic different from 2. In this paperwe make a free use of the standard results from the theory of quadratic forms [email protected] [email protected] K is a number field whose multiplicative groupof non-zero elements is ˙ K , then O K denotes the integral closure of Z in K , while if K is a finite extension of F ( X ), where F is a finite field ofcharacteristic not 2, then O K denotes the integral closure of F [ X ] in K .We denote by Ω( K ) the set of all places of K . If p is a place of K , thenwe write K p and K ( p ) for the p -adic completion of K and the residue fieldof p , respectively. We denote by ( · , · ) p the p -adic Hilbert symbol and by h p ( q ) the p -adic Hasse invariant of a quadratic form q (for definitions andproperties see [8]). If q is a quadratic form over K (over K p , respectively),then we write D ( q ) ( D p ( q ), respectively) for the set of all elements of K ( K p ,respectively) which are represented by q . The symbol h a , . . . , a n i denotes adiagonal quadratic form over K (or K p ). Next, recall that if p is finite andnon-dyadic, then the square class group of the local field K p has the form˙ K p / ˙ K p = { ˙ K p , u p ˙ K p , π p ˙ K p , u p π p ˙ K p } where ord p u p ≡ p -adicunit, and ord p π p ≡ p -adic uniformizer (see e.g. [8, TheoremVI.2.2] for further details).The paper is organized as follows: in Section 2 we present algorithms(see Algorithms 3 and 4) for computing the length of a sum of squaresin a number and global function field respectively. These algorithms usesubsidiary procedures (Algorithms 1 and 2) for deciding the lengths in anon-dyadic and dyadic completion of K , respectively. Next, in Section 3,Algorithms 5 and 6 construct a Pythagoras element in a given number fieldand global function field, respectively.
2. Length of a sum of squares
Let K be a global field and a ∈ ˙ K . If a is not a sum of squares of elementsof K , then we say that a has length ∞ and write ℓ ( a ) = ∞ . Otherwise wedefine it’s length ℓ ( a ) to be ℓ ( a ) = min { n ∈ N : a ∈ D ( h , , . . . , i ) for h , , . . . , i of dimension n } Observation 1.
Let a ∈ ˙ K , then a ∈ D ( h , , . . . , i ) for h , , . . . , i of di-mension n if and only if the quadratic form h a, − , − , . . . , − i of dimension n + 1 is isotropic. ℓ ( a ) < ∞ , then ℓ ( a ) = min { n ∈ N | h a, − , − , . . . , − i of dimension n + 1 is isotropic } Let p ∈ Ω( K ) be a place of K . Similarly as above, we define the lengthof a in the field K p and denote it by ℓ p ( a ). Assume p is finite. Since the u -invariant of K p is 4 (see e.g. [8, Theorem VI.2.12]), the form h , , , i isuniversal over K p . Therefore a ∈ D p ( h , , , i ) and ℓ p ( a ) ≤ K . If a ∈ ˙ K and K p ∼ = R , then ℓ p ( a ) = ( if ( a, − p = 1 ∞ if ( a, − p = − K p ∼ = C then clearly ℓ p ( a ) = 1.In what follows, if p is finite then v p ( a ) denotes the p -adic valuation ofan element a in K . Proposition 2.
Let K be a global field and a ∈ ˙ K with ℓ ( a ) < ∞ , then ℓ ( a ) = max p ∈ Ω( K ) ℓ p ( a ) Proof . Suppose that a ∈ ˙ K , then a ∈ ˙ K p for every p ∈ Ω( K ) since K ⊂ K p . Consequently, ℓ ( a ) = ℓ p ( a ) = 1 for all p of K . Without lossof generality we may assume that a / ∈ ˙ K . By the Global square theorem[8, Theorem VI.3.7] there is a finite p ∈ Ω( K ) such that a / ∈ ˙ K p , p isnon-dyadic and the p -adic valuation v p ( a ) = 0. Then a ≡ u p mod ˙ K p .So ( − , a ) p = ( − , u p ) p = 1, i.e. 1 ∈ D p ( h− , a i ), which is equivalent tothe fact that a ∈ D p ( h , i ). Hence ℓ p ( a ) = 2 ≤ ℓ ( a ). This means theminimum length of a non-square element in ˙ K is 2. Now, let k , . . . , k n bethe lengths of a in K p , . . . , K p n respectively where { p , . . . , p n } is the set ofall dyadic places of K and all places of K dividing a in K , and further let k m := max { k , . . . , k n } . By the Local-global principle [8, Principle VI.3.1],the form h a, − , − , . . . , − i is isotropic over K if and only if it is isotropicover K p for all p ∈ Ω( K ). Therefore ℓ p ( a ) = min { k ≤ h a, − , − , . . . , − i of dimension k + 1is isotropic over K p } Thus, the form h a, − , − , . . . , − i of dimension k m + 1 is isotropic over K p i for all i ∈ { , . . . , n } . Hence ℓ ( a ) = max { , k m } = max p ∈ Ω( K ) ℓ p ( a ). (cid:3) a in anon-dyadic completion of K . Algorithm 1:
Length in a non-dyadic completion
Input:
A nonzero element a of a global field K and a finitenon-dyadic place p of K . Output:
Length of a in the completion K p if v p ( a ) is odd then Let q be a quadratic form h , i over K ( p ); if q is isotropic thenreturn elsereturn elseif a is a local square in K p thenreturn elsereturn Proof of correctness . Assume that v p ( a ) is even. Then either a = 1 or a = u p (modulo squares). If a is a square, then ℓ p ( a ) = 1. Otherwise,similarly as in the proof of Proposition 2, ℓ p ( a ) = 2.Now assume that v p ( a ) is odd. Then either a = π p or u p π p (modulosquares) and hence( − , a ) p = ( − , u p π p ) p = ( − , π p ) p = ( if − ∈ ˙ K p − if − / ∈ ˙ K p If − ∈ ˙ K p (which is equivalent to the fact that the form h , i is isotropicover K ( p )), then similarly as in the previous paragraph, ℓ p ( a ) = 2. If − / ∈ ˙ K p , then the level of K p is equal to 2, so the form h , , i is isotropic over K p . Hence a ∈ D p ( h , , i ) and ℓ p ( a ) = 3. (cid:3) Remark 3. (1) An algorithm for checking the isotropy of a quadratic formused in the above algorithm can be found in [7, Section 2].(2) A procedure for testing whether an element a is a square in a com-pletion K p is equivalent to testing whether x − a is irreducible in K p [ x ] .Algorithms for testing the irreducibility of polynomials are already in exis-tence and can be found for example in [11], [3] or [4]. a in a dyadiccompletion of K (if K is a number field). Algorithm 2:
Length in a dyadic completion
Input:
A nonzero element a of a number field K and a dyadicplace d of K . Output:
Length of a in the completion K d if a is a local square in K d thenreturn − , a ) d ; if ( − , a ) d = 1 thenreturn − , − d ; if ( − , − d = 1 or − a is not a square in K d thenreturn return Lemma 4.
Let a be a nonzero element of a number field K , and d a dyadicplace of K . The form h a, − , − , − i is isotropic over K d if and only ifeither ( − , − d = 1 or − a / ∈ ˙ K d . Proof . Suppose that − a ∈ ˙ K d . We have h a, − , − , − i ∼ = h− , − , − , − i over K d and h d ( h− , − , − , − i ) = ( − , − d = 1. From the assumption itfollows that h− , − , − , − i is isotropic, so by the means of [8, PropositionV.3.23] we have ( − , − d = 1.Conversely suppose that ( − , − d = 1, then the form h a, − , − , − i is isotropic. Assume − a / ∈ ˙ K d and consider a quadratic extension L D := K d ( √− a ) of K d . From [8, Example XI.2.4(7)], it follows that ( − , − D = 1since [ L D : Q ] = [ K d ( √− a ) : Q ] is even. Moreover, h a, − , − , − i ∼ = h− , − , − , − i over L D , and h D ( h− , − , − , − i ) = 1. Finally, we have h D ( h a, − , − , − i ) = ( − , − D , hence by [8, Remark V.3.24] h a, − , − , − i is isotropic over K d . (cid:3) Proof of correctness of Algorithm 2 . Let d be a dyadic place. If a ∈ ˙ K d , then of course ℓ d ( a ) = 1. Assume a / ∈ ˙ K d . We consider the d -adicHilbert symbol ( − , a ) d . If ( − , a ) d = 1, then a ∈ D d ( h , i ) and ℓ d ( a ) =2. Suppose ( − , a ) d = −
1. Then a / ∈ D d ( h , i ). By Lemma 4, if either( − , − d = 1 or − a / ∈ ˙ K d , then ℓ d ( a ) = 3. Otherwise, ℓ d ( a ) = 4. (cid:3) emark 5. An algorithm for computing the Hilbert symbol in a completionof a number field can be found in [12, Algorithm 6.6].
Remark 6.
In the next algorithms, Algorithms 3, 4, 5 and 6, we performtwo kinds of factorization in like manner as in [7]. The first one is to find alldyadic primes of a given field, i.e. to factor O K . The second one is to findall primes dividing an element in a given field. Algorithms for factorizationof ideals are well known. One may refer for example to [1, § § Now we present an algorithm for computing the length of a sum ofsquares in a number field.
Algorithm 3:
Length of a sum of squares in a number field
Input:
A nonzero element a of a number field K Output:
Length of a in K if K is formally real then Let R = { ρ , . . . , ρ r } be the list of all real embeddings of K , r ∈ N ; for ρ ∈ R doif ρ ( a ) < thenreturn ∞ if a is a square in K thenreturn else L ← [2];Let D = { d , . . . , d m } be the list of prime factors of 2 in O K ; for d ∈ D do Compute ℓ d ( a ) in K d using Algorithm 2; if ℓ d ( a ) = 4 thenreturn ℓ d ( a ) to L ;Let Q = { q , . . . , q n } be the list of prime factors of a in O K thatdo not divide 2; for q ∈ Q do Compute ℓ q ( a ) in K q using Algorithm 1; if ℓ q ( a ) = 3 thenreturn ℓ q ( a ) to L ; return max L ; 6 roof of correctness . Let ρ , . . . , ρ r be all real embeddings of K for r ≥
0. If ρ i ( a ) < i ≤ r , then a is not a sum of squares in thecorresponding completion, hence it cannot be a sum of squares in K either.Assume either r = 0 or ρ i ( a ) > i ∈ { , . . . , r } . If a ∈ ˙ K , then ℓ ( a ) = 1. Therefore suppose a / ∈ ˙ K . Let a O K = q k · · · q k n n and 2 O K = d l · · · d l m m for some places q , . . . , q n , d , . . . , d m of K , where k , . . . , k n , l , . . . , l m , m ∈ N and n ∈ N ∪{ } . Let P := { q , . . . , q n , d , . . . , d m } and fix a finite place p ∈ Ω( K ). If p / ∈ P , then v p ( a ) = 0. It implies ei-ther a = 1 or a = u p (modulo squares). If a is a square, then ℓ p ( a ) = 1.Otherwise, similarly as in the proof of Proposition 2, ℓ p ( a ) = 2. Suppose p ∈ P , if p is a non-dyadic place then we use Algorithm 1. Otherwise, weuse Algorithm 2. Finally, by Proposition 2, ℓ ( a ) = max p ∈ Ω( K ) ℓ p ( a ). (cid:3) Next, we present an algorithm for computing the length of a sum ofsquares in a global function field.
Algorithm 4:
Length of a sum of squares in a global function field
Input:
A nonzero element a of a global function field K Output:
Length of a in K if a is a square in K thenreturn else L ← [2];Let P = { q , . . . , q n } be the list of places dividing a in K ; for q ∈ P do Compute ℓ q ( a ) in K q using Algorithm 1; if ℓ q ( a ) = 3 thenreturn ℓ q ( a ) to L ; return max L ; Proof of correctness . Assume P := { q , . . . , q n } is the set of places di-viding a in K . Then the proof of correctness is similar to the proof ofcorrectness of Algorithm 3, the second paragraph. (cid:3) . Pythagoras Element In this section, we devise an algorithm that constructs an element whoselength is equal to the Pythagoras number of a global field. Recall (see e.g.[8, XI.5.5]) that the Pythagoras number of a field K , denoted P ( K ), is thesmallest positive integer n such that every sum of squares in K is a sumof n squares. If no such integer n exists, then P ( K ) := ∞ . A Pythagoraselement in a global field is defined as follows. Definition 7. A Pythagoras element of a global field K , denoted a K , isdefined to be an element whose length is equal to the Pythagoras number of K . Thus ℓ ( a K ) = P ( K ) . For example, the Pythagoras number of the rationals is P ( Q ) = 4 and7 ∈ Q is a Pythagoras element since it’s length ℓ (7) = 4 = P ( K ). ThePythagoras element is not unique, e.g. 15 is another Pythagoras element of Q . Theorem 8.
Let K be a number field, then(i) P ( K ) = 2 iff s ( K ) = 1 .(ii) P ( K ) = 3 iff s ( K ) = 1 and every dyadic place of K has even degree.(iii) P ( K ) = 4 iff there is a dyadic place of K of odd degree. Proof . ( i ) Similarly as in the proofs of correctness of Algorithms 1 and 2, P ( K ) = 2 iff the form h , i is isotropic over K ( p ) for every finite non-dyadicplace p of K , and ( − , a ) d = 1 for every dyadic place d of K and any a ∈ ˙ K .Hence P ( K ) = 2 iff − ∈ ˙ K q for every finite place q ∈ Ω( K ) which isequivalent to s ( K ) = 1.( iii ) By Lemma 4, P ( K ) = 4 iff ( − , − d = − d of K , so P ( K ) = 4 iff there is a dyadic place of K of odd degree by meansof [8, Example XI.2.4(7)].( ii ) Follows from ( i ) and ( iii ). (cid:3) Remark 9.
Observe that if K is a number field and P ( K ) = 2 , then K isa nonreal field. lgorithm 5: Pythagoras element in a number field
Input:
A number field K Output:
A Pythagoras element in K if s ( K ) = 1 thenreturn any a ∈ ˙ K \ ˙ K ; else Let D = { d , . . . , d m } be the list of prime factors of 2 in O K ; for d ∈ D doif ( − , − d = − thenreturn q ← · O K and p ← while q = 0 · O K do Let p ← smallest prime number ≥ p + 1; if p ≡ then reiterate the loop;Let P = { p , . . . , p n } be the list of prime factors of p in O K ; for p ∈ P doif v p ( p ) is odd thenreturn p Proof of correctness . Assume P ( K ) = 2 and let a ∈ ˙ K \ ˙ K . Then s ( K ) = 1 and − ∈ ˙ K , so − ∈ ˙ K q for every finite place q ∈ Ω( K ). If q isa finite place such that a ∈ ˙ K q , then ℓ q ( a ) = 1. Otherwise, similarly as inthe proofs of correctness of Algorithms 1 and 2, ℓ q ( a ) = 2 so ℓ ( a ) = 2 and a is a Pythagoras element.Next, assume P ( K ) = 3, then s ( K ) = 1 and ( − , − d = 1 for everydyadic place d of K . Since − / ∈ ˙ K , there exists a finite non-dyadic place p of K such that − / ∈ ˙ K p . If a is an element of K such that v p ( a ) is odd,then a = π p or u p π p (modulo squares) and ℓ p ( a ) = 3. If d is a dyadic placeof K , then ( − , − d = 1 so by Lemma 4, ℓ d ( a ) ≤
3. Moreover, if a is atotally positive element (in the case when K is formally real), then ℓ ( a ) = 3and a is a Pythagoras element of K . Now let p ≡ p O K = p e · · · p e n n , and let p be any of those factors such that e ( p | p ) ≡ p ≡ − / ∈ ˙ K p , and p is the soughtelement.Finally, if P ( K ) = 4, then choose a dyadic place d of K such that( − , − d = −
1. We prove that 7 is a Pythagoras element of K . Indeed,9 ∈ ˙ Q ⊂ ˙ K d . By Lemma 4, it implies that h , − , − , − i is anisotropicover K d and ℓ d (7) = 4. Therefore ℓ (7) = 4 and 7 is a Pythagoras element. (cid:3) Remark 10.
In order to compute the level s ( K ) of a number field K in thefirst step of the above algorithm, one may use [7, Algorithm 10]. Theorem 11.
Let K be a global function field with full field of constants F q of order q , then(i) P ( K ) = 2 iff q ≡ (ii) P ( K ) = 3 iff q ≡ Proof . ( i ) Similarly as in the proof of correctness of Algorithm 1, P ( K ) = 2if and only if − ∈ ˙ K p for every place p ∈ Ω( K ). Therefore P ( K ) = 2 ⇐⇒ − ∈ ˙ F q ⊂ ˙ K ⇐⇒ q ≡ ii ) Follows from ( i ). (cid:3) Algorithm 6:
Pythagoras element in a global function field
Input:
A global function field K with full field of constants F q oforder q . Output:
A Pythagoras element in K if q ≡ thenreturn any a ∈ ˙ F q \ ˙ F q ; else Set q ← · O K and m ← while q = 0 · O K do m ← m + 1;Factor ( x q m − x ) into monic irreducible polynomials in theform of a list: P = { p , . . . , p k } ; for p ∈ P do Let P = { p , . . . , p n } be the list of places dividing p in K ; for p ∈ P doif v p ( p ) is odd thenreturn p roof of correctness . The full field F q of constants is algebraically closedin K . Hence a / ∈ ˙ F q implies that a / ∈ ˙ K , therefore if P ( K ) = 2, we have ℓ ( a ) = 2 = P ( K ).Conversely, if q ≡ − / ∈ ˙ K by Theorem 11, so thereis a place p ∈ Ω( K ) such that − / ∈ ˙ K p . If a ∈ K and v p ( a ) is odd, thensimilarly as in the proof of correctness of Algorithm 5, ℓ p ( a ) = 3 which isthe maximal length in K and a is a Pythagoras element. Further, for anypositive integer n , it is well known that the polynomial x q n − x in F q [ x ]factors into a product Q d | n P ( d, q ) of monic irreducible polynomials P ofdegree d . If P is any monic irreducible polynomial factoring into a productof powers of prime ideals p e · · · p e k k in O K such that e i ( p i | P ) ≡ i ≤ k , then ( − , P ) p i = − − / ∈ ˙ K p i , and P is thesought element. (cid:3) The presented algorithms can be implemented in existing computer al-gebra systems. In fact, they have currently been implemented in CQF – afree, open-source Magma package for doing computations in quadratic formstheory (see [6]). CQF determines the length of an element and a Pythago-ras element in a global field using the functions
LengthOfSumOfSquares (or
LengthOfSOS for short) and
PythagorasElement respectively.
References [1] Cohen, H. (1993). A course in computational algebraic number theory.
Graduate texts in Math. , 138:88.[2] Cohen, H. (2012).
Advanced Topics in Computational Number Theory ,volume 193. Springer Science & Business Media.[3] Gu`ardia, J., Montes, J., and Nart, E. (2011). Higher Newton polygonsin the computation of discriminants and prime ideal decomposition innumber fields.
Journal de th´eorie des nombres de Bordeaux , 23(3):667–696.[4] Gu`ardia, J., Montes, J., and Nart, E. (2012). Newton polygons of higherorder in algebraic number theory.
Transactions of the American Mathe-matical Society , 364(1):361–416.[5] Gu`ardia, J., Montes, J., and Nart, E. (2013). A new computationalapproach to ideal theory in number fields.
Foundations of computationalmathematics , 13(5):729–762. 116] Koprowski, P. (2020). CQF Magma package.
ACM Communications inComputer Algebra , 54(2):53–56.[7] Koprowski, P. and Czoga la, A. (2018). Computing with quadratic formsover number fields.
Journal of Symbolic Computation , 89:129–145.[8] Lam, T.-Y. (2005).
Introduction to Quadratic Forms Over Fields , vol-ume 67. American Mathematical Soc.[9] Scharlau, W. (1985).
Hermitian Forms over Global Fields . Springer.[10] Szymiczek, K. (1997).
Bilinear Algebra: An Introduction to the Alge-braic theory of quadratic forms , volume 7. CRC Press.[11] Veres, O. E. (2009).
On the Complexity of Polynomial Factorizationover p-adic Fields . PhD thesis, Concordia University.[12] Voight, J. (2013).