Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trim code and docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Apr 2, 2017
1 parent 4bb538e commit 2847da0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 45 deletions.
5 changes: 2 additions & 3 deletions src/sage/rings/function_field/function_field.py
Expand Up @@ -358,14 +358,13 @@ def _coerce_map_from_(self, R):
return False

def _test_derivation(self, **options):
r"""
Test the correctness of the derivations of this function field.
"""
Test the correctness of the derivations of the function field.
EXAMPLES::
sage: K.<x> = FunctionField(QQ)
sage: TestSuite(K).run() # indirect doctest
"""
tester = self._tester(**options)
S = tester.some_elements()
Expand Down
74 changes: 32 additions & 42 deletions src/sage/rings/function_field/maps.py
Expand Up @@ -111,47 +111,41 @@ def is_injective(self):
return False

class FunctionFieldDerivation_rational(FunctionFieldDerivation):
r"""
"""
A derivation on a rational function field.
INPUT:
- ``K`` -- a rational function field
- ``u`` -- an element of ``K``, the image of the generator of ``K`` under
the derivation.
EXAMPLES::
sage: K.<x> = FunctionField(QQ)
sage: d = K.derivation()
sage: isinstance(d, sage.rings.function_field.maps.FunctionFieldDerivation_rational)
True
"""
def __init__(self, K, u):
r"""
"""
Initialize a derivation of ``K`` which sends the generator of ``K`` to
``u``.
INPUT:
- ``K`` -- a rational function field
- ``u`` -- an element of ``K``, the image of the generator of ``K`` under
the derivation
EXAMPLES::
sage: K.<x> = FunctionField(QQ)
sage: d = K.derivation() # indirect doctest
sage: type(d)
<class 'sage.rings.function_field.maps.FunctionFieldDerivation_rational'>
"""
from .function_field import is_RationalFunctionField
if not is_RationalFunctionField(K):
raise ValueError("K must be a rational function field")
if u.parent() is not K:
raise ValueError("u must be an element in K")
FunctionFieldDerivation.__init__(self, K)

self._u = u

def _call_(self, x):
r"""
"""
Compute the derivation of ``x``.
INPUT:
Expand All @@ -168,42 +162,38 @@ def _call_(self, x):
3*x^2
sage: d(1/x)
-1/x^2
"""
f,g = x.numerator(),x.denominator()

if not f.gcd(g).is_one():
raise NotImplementedError("derivations only implemented for rational functions with coprime numerator and denominator.")
f = x.numerator()
g = x.denominator()

numerator = f.derivative()*g - f*g.derivative()
numerator = f.derivative() * g - f * g.derivative()
if numerator.is_zero():
return self.codomain().zero()
else:
return self._u * self.codomain()( numerator / g**2 )
return self._u * self.codomain()(numerator / g**2)

class FunctionFieldDerivation_separable(FunctionFieldDerivation):
r"""
"""
The unique extension of the derivation ``d`` to ``L``.
INPUT:
- ``L`` -- a function field which is a separable extension of the domain of
``d``
- ``d`` -- a derivation on the base function field of ``L``
EXAMPLES::
sage: K.<x> = FunctionField(QQ)
sage: R.<y> = K[]
sage: L.<y> = K.extension(y^2 - x)
sage: d = L.derivation()
"""
def __init__(self, L, d):
r"""
"""
Initialization.
INPUT:
- ``L`` -- a function field which is a separable extension of the domain of
``d``
- ``d`` -- a derivation on the base function field of ``L``
EXAMPLES::
sage: K.<x> = FunctionField(GF(3))
Expand All @@ -212,7 +202,6 @@ def __init__(self, L, d):
sage: d = L.derivation() # indirect doctest
sage: type(d)
<class 'sage.rings.function_field.maps.FunctionFieldDerivation_separable'>
"""
FunctionFieldDerivation.__init__(self, L)

Expand Down Expand Up @@ -245,19 +234,20 @@ def _call_(self, x):
(-1/2/-x)*y
sage: d(y^2)
1
"""
if x.is_zero():
return self.codomain().zero()

return x._x.map_coefficients(self._d) \
+ x._x.derivative()(self.domain().gen()) * self._gen_image
x = x._x
y = self.domain().gen()

return x.map_coefficients(self._d) + x.derivative()(y) * self._gen_image

def _repr_defn(self):
r"""
Helper method to print this map.
"""
Return the string representation of the map.
TESTS::
EXAMPLES::
sage: K.<x> = FunctionField(QQ)
sage: R.<y> = K[]
Expand All @@ -267,6 +257,7 @@ def _repr_defn(self):
From: Function field in y defined by y^2 - x
To: Function field in y defined by y^2 - x
Defn: y |--> (-1/2/-x)*y
sage: R.<z> = L[]
sage: M.<z> = L.extension(z^2 - y)
sage: M.derivation()
Expand All @@ -275,7 +266,6 @@ def _repr_defn(self):
To: Function field in z defined by z^2 - y
Defn: y |--> (-1/2/-x)*y
z |--> 1/4/x*z
"""
base = self._d._repr_defn()
ret = '{} |--> {}'.format(self.domain().gen(), self._gen_image)
Expand Down

0 comments on commit 2847da0

Please sign in to comment.