# HG changeset patch
# User Robert Bradshaw <robertwb@math.washington.edu>
# Date 1275212946 25200
# Node ID 1166db8627ff22da9f93c73f08c314b89a4479e2
# Parent 3b9b429abf1fe5f51400be49ae7c8101c90cf315
#9051  function fields: valuation, sqrt, is_finite, etc.
diff r 3b9b429abf1f r 1166db8627ff sage/rings/function_field/function_field.py
a

b


38  38  
39  39  """ 
40  40  
 41  from sage.structure.category_object import CategoryObject 
41  42  from sage.rings.ring import Field 
42  43  from sage.rings.integer_ring import ZZ 
43  44  from sage.structure.parent_gens import ParentWithGens 
… 
… 

88  89  """ 
89  90  return self.constant_field().characteristic() 
90  91  
 92  def is_finite(self): 
 93  """ 
 94  Return whether this function field is finite, which it is not. 
 95  
 96  EXAMPLES:: 
 97  
 98  sage: R.<t> = FunctionField(QQ) 
 99  sage: R.is_finite() 
 100  False 
 101  sage: R.<t> = FunctionField(GF(7)) 
 102  sage: R.is_finite() 
 103  False 
 104  """ 
 105  return False 
 106  
91  107  def extension(self, f, names=None): 
92  108  """ 
93  109  Create an extension L = K[y]/(f(y)) of a function field, 
… 
… 

1132  1148  sage: f(x^2) 
1133  1149  5*y^2 + (x^3 + 6*x + 4)*y + 2*x^3 + 5*x + 4 
1134  1150  """ 
 1151  if isinstance(im_gens, CategoryObject): 
 1152  return self.Hom(im_gens).natural_map() 
1135  1153  if not isinstance(im_gens, (list,tuple)): 
1136  1154  im_gens = [im_gens] 
1137  1155  if len(im_gens) != 1: 
diff r 3b9b429abf1f r 1166db8627ff sage/rings/function_field/function_field_element.pyx
a

b


36  36  x._parent = self._parent 
37  37  return x 
38  38  
 39  def _latex_(self): 
 40  """ 
 41  EXAMPLES:: 
 42  
 43  sage: K.<t> = FunctionField(QQ) 
 44  sage: latex((t+1)/t) 
 45  \frac{t + 1}{t} 
 46  sage: latex((t+1)/t^67) 
 47  \frac{t + 1}{t^{67}} 
 48  sage: latex((t+1/2)/t^67) 
 49  \frac{t + \frac{1}{2}}{t^{67}} 
 50  """ 
 51  return self._x._latex_() 
 52  
39  53  def matrix(self): 
40  54  r""" 
41  55  Return the matrix of multiplication by self. 
… 
… 

472  486  sage: K.<t> = FunctionField(QQ) 
473  487  sage: f = (t+1) / (t^2  1/3); f 
474  488  (t + 1)/(t^2  1/3) 
475   sage: f.numerator() # indirect doctest 
 489  sage: f.numerator() 
476  490  t + 1 
477  491  """ 
478  492  return self._x.numerator() 
… 
… 

484  498  sage: K.<t> = FunctionField(QQ) 
485  499  sage: f = (t+1) / (t^2  1/3); f 
486  500  (t + 1)/(t^2  1/3) 
487   sage: f.denominator() # indirect doctest 
 501  sage: f.denominator() 
488  502  t^2  1/3 
489  503  """ 
490  504  return self._x.denominator() 
 505  
 506  def valuation(self, v): 
 507  """ 
 508  EXAMPLES:: 
 509  
 510  sage: K.<t> = FunctionField(QQ) 
 511  sage: f = (t1)^2 * (t+1) / (t^2  1/3)^3 
 512  sage: f.valuation(t1) 
 513  2 
 514  sage: f.valuation(t) 
 515  0 
 516  sage: f.valuation(t^2  1/3) 
 517  3 
 518  """ 
 519  R = self._parent._ring 
 520  return self._x.valuation(R(self._parent(v)._x)) 
 521  
 522  def is_square(self): 
 523  """ 
 524  Returns whether self is a square. 
 525  
 526  EXAMPLES:: 
 527  
 528  sage: K.<t> = FunctionField(QQ) 
 529  sage: t.is_square() 
 530  False 
 531  sage: (t^2/4).is_square() 
 532  True 
 533  sage: f = 9 * (t+1)^6 / (t^2  2*t + 1); f.is_square() 
 534  True 
 535  
 536  sage: K.<t> = FunctionField(GF(5)) 
 537  sage: (t^2).is_square() 
 538  True 
 539  sage: (t^2).sqrt() 
 540  2*t 
 541  """ 
 542  return self._x.is_square() 
 543  
 544  def sqrt(self, all=False): 
 545  """ 
 546  Returns the square root of self. 
 547  
 548  EXMPLES:: 
 549  
 550  sage: K.<t> = FunctionField(QQ) 
 551  sage: f = t^2  2 + 1/t^2; f.sqrt() 
 552  (t^2  1)/t 
 553  sage: f = t^2; f.sqrt(all=True) 
 554  [t, t] 
 555  
 556  TESTS:: 
 557  
 558  sage: K(4/9).sqrt() 
 559  2/3 
 560  sage: K(0).sqrt(all=True) 
 561  [0] 
 562  """ 
 563  if all: 
 564  return [self._parent(r) for r in self._x.sqrt(all=True)] 
 565  else: 
 566  return self._parent(self._x.sqrt()) 
491  567  
492  568  def factor(self): 
493  569  """ 