# Ticket #9054: trac_9054-part12.patch

File trac_9054-part12.patch, 4.7 KB (added by robertwb, 12 years ago)

Various methods needed for #9095 (doctesets depend on #9094)

• ## sage/rings/function_field/function_field.py

# 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 """ from sage.structure.category_object import CategoryObject from sage.rings.ring import Field from sage.rings.integer_ring import ZZ from sage.structure.parent_gens import ParentWithGens """ return self.constant_field().characteristic() def is_finite(self): """ Return whether this function field is finite, which it is not. EXAMPLES:: sage: R. = FunctionField(QQ) sage: R.is_finite() False sage: R. = FunctionField(GF(7)) sage: R.is_finite() False """ return False def extension(self, f, names=None): """ Create an extension L = K[y]/(f(y)) of a function field, sage: f(x^2) 5*y^2 + (x^3 + 6*x + 4)*y + 2*x^3 + 5*x + 4 """ if isinstance(im_gens, CategoryObject): return self.Hom(im_gens).natural_map() if not isinstance(im_gens, (list,tuple)): im_gens = [im_gens] if len(im_gens) != 1:
• ## sage/rings/function_field/function_field_element.pyx

diff -r 3b9b429abf1f -r 1166db8627ff sage/rings/function_field/function_field_element.pyx
 a x._parent = self._parent return x def _latex_(self): """ EXAMPLES:: sage: K. = FunctionField(QQ) sage: latex((t+1)/t) \frac{t + 1}{t} sage: latex((t+1)/t^67) \frac{t + 1}{t^{67}} sage: latex((t+1/2)/t^67) \frac{t + \frac{1}{2}}{t^{67}} """ return self._x._latex_() def matrix(self): r""" Return the matrix of multiplication by self. sage: K. = FunctionField(QQ) sage: f = (t+1) / (t^2 - 1/3); f (t + 1)/(t^2 - 1/3) sage: f.numerator()                    # indirect doctest sage: f.numerator() t + 1 """ return self._x.numerator() sage: K. = FunctionField(QQ) sage: f = (t+1) / (t^2 - 1/3); f (t + 1)/(t^2 - 1/3) sage: f.denominator()                  # indirect doctest sage: f.denominator() t^2 - 1/3 """ return self._x.denominator() def valuation(self, v): """ EXAMPLES:: sage: K. = FunctionField(QQ) sage: f = (t-1)^2 * (t+1) / (t^2 - 1/3)^3 sage: f.valuation(t-1) 2 sage: f.valuation(t) 0 sage: f.valuation(t^2 - 1/3) -3 """ R = self._parent._ring return self._x.valuation(R(self._parent(v)._x)) def is_square(self): """ Returns whether self is a square. EXAMPLES:: sage: K. = FunctionField(QQ) sage: t.is_square() False sage: (t^2/4).is_square() True sage: f = 9 * (t+1)^6 / (t^2 - 2*t + 1); f.is_square() True sage: K. = FunctionField(GF(5)) sage: (-t^2).is_square() True sage: (-t^2).sqrt() 2*t """ return self._x.is_square() def sqrt(self, all=False): """ Returns the square root of self. EXMPLES:: sage: K. = FunctionField(QQ) sage: f = t^2 - 2 + 1/t^2; f.sqrt() (t^2 - 1)/t sage: f = t^2; f.sqrt(all=True) [t, -t] TESTS:: sage: K(4/9).sqrt() 2/3 sage: K(0).sqrt(all=True) [0] """ if all: return [self._parent(r) for r in self._x.sqrt(all=True)] else: return self._parent(self._x.sqrt()) def factor(self): """