Пример #1
0
 def Deltoid(cls, par_type='rational'):
     r"""
     Return a deltoid motion.
     """
     if par_type == 'rational':
         FF = FunctionField(QQ, 't')
         t = FF.gen()
         C = {
             _sage_const_0 : vector((_sage_const_0 , _sage_const_0 )),
             _sage_const_1 : vector((_sage_const_1 , _sage_const_0 )),
             _sage_const_2 : vector((_sage_const_4 *(t**_sage_const_2  - _sage_const_2
                                                     )/(t**_sage_const_2  + _sage_const_4 ), _sage_const_12 *t/(t**_sage_const_2  + _sage_const_4 ))),
             _sage_const_3 : vector(((t**_sage_const_4  - _sage_const_13 *t**_sage_const_2  + _sage_const_4
                                      )/(t**_sage_const_4  + _sage_const_5 *t**_sage_const_2  + _sage_const_4 ),
                                      _sage_const_6 *(t**_sage_const_3  - _sage_const_2 *t)/(t**_sage_const_4  + _sage_const_5 *t**_sage_const_2  + _sage_const_4 )))
             }
         G = FlexRiGraph([[0, 1], [1, 2], [2, 3], [0, 3]])
         return GraphMotion.ParametricMotion(G, C, 'rational', sampling_type='tan', check=False)
     elif par_type == 'symbolic':
         t = var('t')
         C = {
             _sage_const_0 : vector((_sage_const_0 , _sage_const_0 )),
             _sage_const_1 : vector((_sage_const_1 , _sage_const_0 )),
             _sage_const_2 : vector((_sage_const_4 *(t**_sage_const_2  - _sage_const_2
                                                     )/(t**_sage_const_2  + _sage_const_4 ), _sage_const_12 *t/(t**_sage_const_2  + _sage_const_4 ))),
             _sage_const_3 : vector(((t**_sage_const_4  - _sage_const_13 *t**_sage_const_2  + _sage_const_4
                                      )/(t**_sage_const_4  + _sage_const_5 *t**_sage_const_2  + _sage_const_4 ),
                                      _sage_const_6 *(t**_sage_const_3  - _sage_const_2 *t)/(t**_sage_const_4  + _sage_const_5 *t**_sage_const_2  + _sage_const_4 )))
             }
         G = FlexRiGraph([[0, 1], [1, 2], [2, 3], [0, 3]])
         return ParametricGraphMotion.ParametricMotion(G, C, 'symbolic', sampling_type='tan', check=False)
     else:
         raise exceptions.ValueError('Deltoid with par_type ' + str(par_type) + ' is not supported.')
Пример #2
0
 def _test(self):
     from sage.all import QQ, PolynomialRing, GaussValuation, FunctionField
     R = PolynomialRing(QQ, 'x')
     x = R.gen()
     v = GaussValuation(R, QQ.valuation(2))
     K = FunctionField(QQ, 'x')
     x = K.gen()
     v = K.valuation(v)
     K.valuation((v, K.hom(x/2), K.hom(2*x)))
Пример #3
0
 def _test(self):
     from sage.all import FunctionField, QQ, PolynomialRing
     K = FunctionField(QQ, 'x')
     x = K.gen()
     R = PolynomialRing(K, 'y')
     y = R.gen()
     L = K.extension(y**3 - 1 / x**3 * y + 2 / x**4, 'y')
     v = K.valuation(x)
     v.extensions(L)
Пример #4
0
 def time_is_semistable(self):
     K = FunctionField(QQ, 'x')
     x = K.gen()
     R = PolynomialRing(K, 'T')
     T = R.gen()
     f = 64 * x**3 * T - 64 * x**3 + 36 * x**2 * T**2 + 208 * x**2 * T + 192 * x**2 + 9 * x * T**3 + 72 * x * T**2 + 240 * x * T + 64 * x + T**4 + 9 * T**3 + 52 * T**2 + 48 * T
     L = K.extension(f, 'y')
     Y = SmoothProjectiveCurve(L)
     v = QQ.valuation(13)
     M = SemistableModel(Y, v)
     return M.is_semistable()
Пример #5
0
 def _test(self):
     from sage.all import GF, FunctionField, PolynomialRing
     k = GF(4)
     a = k.gen()
     R = PolynomialRing(k, 'b')
     b = R.gen()
     l = k.extension(b**2 + b + a, 'b')
     K = FunctionField(l, 'x')
     x = K.gen()
     R = PolynomialRing(K, 't')
     t = R.gen()
     F = t * x
     F.factor(proof=False)
Пример #6
0
 def _test(self):
     from sage.all import PolynomialRing, QQ, NumberField, GaussValuation, FunctionField
     R = PolynomialRing(QQ, 'x')
     x = R.gen()
     K = NumberField(x**6 + 126 * x**3 + 126, 'pi')
     v = K.valuation(2)
     R = PolynomialRing(K, 'x')
     x = R.gen()
     v = GaussValuation(R, v).augmentation(x, QQ(2) / 3)
     F = FunctionField(K, 'x')
     x = F.gen()
     v = F.valuation(v)
     S = PolynomialRing(F, 'y')
     y = S.gen()
     w0 = GaussValuation(S, v)
     G = y**2 - x**3 - 3
     w1 = w0.mac_lane_step(G)[0]
     w1.mac_lane_step(G)
Пример #7
0
def make_function_field(K):
    r"""
    Return the function field isomorphic to this field, an isomorphism,
    and its inverse.

    INPUT:

    - ``K`` -- a field

    OUTPUT: A triple `(F,\phi,\psi)`, where `F` is a rational function field,
    `\phi:K\to F` is a field isomorphism and `\psi` the inverse of `\phi`.

    It is assumed that `K` is either the fraction field of a polynomial ring
    over a finite field `k`, or a finite simple extension of such a field.

    In the first case, `F=k_1(x)` is a rational function field over a finite
    field `k_1`, where `k_1` as an *absolute* finite field isomorphic to `k`.
    In the second case, `F` is a finite simple extension of a rational function
    field as in the first case.

    .. NOTE::

        this command seems to be partly superflous by now, because the residue
        of a valuation is already of type "function field" whenever this makes sense.
        However, even if `K` is a function field over a finite field, it is not
        guaranteed that the constant base field is a 'true' finite field, and then
        it is important to change that.

    """
    from mclf.curves.smooth_projective_curves import make_finite_field
    from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
    from sage.categories.function_fields import FunctionFields
    from sage.rings.function_field.function_field import is_FunctionField

    if is_FunctionField(K):
        k = K.constant_base_field()
        if k.is_finite() and hasattr(k, "base_field"):
            # k seems to be finite, but not a true finite field
            # we construct a true finite field k1 isomorphic to k
            # and F isomorphic to K with constant base field k1
            k1, phi, psi = make_finite_field(k)
            if hasattr(K, "polynomial"):
                # K is an extension of a rational function field
                K0 = K.rational_function_field()
                F0, phi0, psi0 = make_function_field(K0)
                f = K.polynomial().change_ring(phi0)
                F = F0.extension(f)
                return F, K.hom(F.gen(), phi0), F.hom(K.gen(), psi0)
            else:
                F = FunctionField(k1, K.variable_name())
                return F, K.hom(F.gen(), phi), F.hom(K.gen(), psi)
        else:
            return K, K.Hom(K).identity(), K.Hom(K).identity()

    if hasattr(K, "modulus") or hasattr(K, "polynomial"):
        # we hope that K is a simple finite extension of a field which is
        # isomorphic to a rational function field
        K_base = K.base_field()
        F_base, phi_base, psi_base = make_function_field(K_base)
        if hasattr(K, "modulus"):
            G = K.modulus()
        else:
            G = K.polynomial()
        R = G.parent()
        R_new = PolynomialRing(F_base, R.variable_name())
        G_new = R_new([phi_base(c) for c in G.list()])
        assert G_new.is_irreducible(), "G must be irreducible!"
        # F = F_base.extension(G_new, R.variable_name())
        F = F_base.extension(G_new, 'y')
        # phi0 = R.hom(F.gen(), F)
        # to construct phi:K=K_0[x]/(G) --> F=F_0[y]/(G),
        # we first 'map' from K to K_0[x]
        phi = K.hom(R.gen(), R, check=False)
        # then from K_0[x] to F_0[y]
        psi = R.hom(phi_base, R_new)
        # then from F_0[y] to F = F_0[y]/(G)
        phi = phi.post_compose(psi.post_compose(R_new.hom(F.gen(), F)))
        psi = F.hom(K.gen(), psi_base)
        return F, phi, psi
    else:
        # we hope that K is isomorphic to a rational function field over a
        # finite field
        if K in FunctionFields():
            # K is already a function field
            k = K.constant_base_field()
            k_new, phi_base, psi_base = make_finite_field(k)
            F = FunctionField(k_new, K.variable_name())
            phi = K.hom(F.gen(), phi_base)
            psi = F.hom(K.gen(), psi_base)
            return F, phi, psi
        elif hasattr(K, "function_field"):
            F1 = K.function_field()
            phi1 = F1.coerce_map_from(K)
            psi1 = F1.hom(K.gen())
            F, phi2, psi2 = make_function_field(F1)
            phi = phi1.post_compose(phi2)
            psi = psi2.post_compose(psi1)
            return F, phi, psi
        else:
            raise NotImplementedError
Пример #8
0
# Utility functions:
#
# - pp as generator of function field over QQ
# - substitution in ratonal function, star involution
# - lists of monic and non-monic polys and forms over any base F
# - roots of a polynomial or binary form
# - affine linear combinations

from sage.all import (FunctionField, QQ, PolynomialRing, ProjectiveSpace,
                      VectorSpace, infinity)
from collections import Counter

Qp = FunctionField(QQ, 'p')
pp = Qp.gen()


def subs(f, p):
    """Substitute p for the variable of the rational function f.
    """
    if f in QQ:
        return f
    n = f.numerator()(p)
    d = f.denominator()(p)
    if d:
        return n / d
    else:
        return infinity


def star(r):
    return r if r in QQ else subs(r, 1 / pp)
Пример #9
0
def make_function_field(K):
    r"""
    Return the function field isomorphic to this field, an isomorphism,
    and its inverse.

    INPUT:

    - ``K`` -- a field

    OUTPUT: A triple `(F,\phi,\psi)`, where `F` is a rational function field,
    `\phi:K\to F` is a field isomorphism and `\psi` the inverse of `\phi`.

    It is assumed that `K` is either the fraction field of a polynomial ring
    over a finite field `k`, or a finite simple extension of such a field.

    In the first case, `F=k_1(x)` is a rational function field over a finite
    field `k_1`, where `k_1` as an *absolute* finite field isomorphic to `k`.
    In the second case, `F` is a finite simple extension of a rational function
    field as in the first case.

    """
    from mclf.curves.smooth_projective_curves import make_finite_field
    from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
    from sage.categories.function_fields import FunctionFields

    if hasattr(K, "modulus") or hasattr(K, "polynomial"):
        # we hope that K is a simple finite extension of a field which is
        # isomorphic to a rational function field
        K_base = K.base_field()
        F_base, phi_base, psi_base = make_function_field(K_base)
        if hasattr(K, "modulus"):
            G = K.modulus()
        else:
            G = K.polynomial()
        R = G.parent()
        R_new = PolynomialRing(F_base, R.variable_name())
        G_new = R_new([phi_base(c) for c in G.list()])
        assert G_new.is_irreducible(), "G must be irreducible!"
        # F = F_base.extension(G_new, R.variable_name())
        F = F_base.extension(G_new, 'y')
        # phi0 = R.hom(F.gen(), F)
        # to construct phi:K=K_0[x]/(G) --> F=F_0[y]/(G),
        # we first 'map' from K to K_0[x]
        phi = K.hom(R.gen(), R, check=False)
        # then from K_0[x] to F_0[y]
        psi = R.hom(phi_base, R_new)
        # then from F_0[y] to F = F_0[y]/(G)
        phi = phi.post_compose(psi.post_compose(R_new.hom(F.gen(), F)))
        psi = F.hom(K.gen(), psi_base)
        return F, phi, psi
    else:
        # we hope that K is isomorphic to a rational function field over a
        # finite field
        if K in FunctionFields():
            # K is already a function field
            k = K.constant_base_field()
            k_new, phi_base, psi_base = make_finite_field(k)
            F = FunctionField(k_new, K.variable_name())
            phi = K.hom(F.gen(), phi_base)
            psi = F.hom(K.gen(), psi_base)
            return F, phi, psi
        elif hasattr(K, "function_field"):
            F1 = K.function_field()
            phi1 = F1.coerce_map_from(K)
            psi1 = F1.hom(K.gen())
            F, phi2, psi2 = make_function_field(F1)
            phi = phi1.post_compose(phi2)
            psi = psi2.post_compose(psi1)
            return F, phi, psi
        else:
            raise NotImplementedError