示例#1
0
    def test__get_linear_series__3(self):

        PolyRing.reset_base_field()
        bp_tree_1 = BasePointTree()
        bp_tree_1.add('z', (0, 0), 2).add('t', (1, 0), 1)
        bp_tree_1.add('z', (2, 3), 1)

        bp_tree_2 = LinearSeries.get([3], bp_tree_1).get_bp_tree()

        assert self.equal_output_strings(bp_tree_1.alt_str(),
                                         bp_tree_2.alt_str())
示例#2
0
    def test__get_linear_series__1(self):

        # Example from phd thesis of Niels Lubbes (page 159).
        PolyRing.reset_base_field()
        bp_tree = BasePointTree()
        bp = bp_tree.add('z', (0, 0), 1)
        bp = bp.add('t', (0, 0), 1)
        bp = bp.add('t', (-1, 0), 1)
        bp = bp.add('t', (0, 0), 1)

        ls = LinearSeries.get([2], bp_tree)

        assert str(ls) == '{ 2, <<x^2, y^2 + x*z>>, QQ[x, y, z] }'
    def test__approx_QQ_pol_lst(self):
        ring = PolyRing('x,y,z', True).ext_num_field('t^2 - 3')
        x, y, z = ring.gens()
        a0 = ring.root_gens()[0]
        q2 = sage_QQ(1) / 2
        pol_lst = [x * y * a0 + z**2 + q2 * y**2 - q2 - a0 * x, a0, -a0 * x]
        out_lst = OrbRing.approx_QQ_pol_lst(pol_lst, 1)

        c = sage_QQ(3900231685776981) / 2251799813685248

        print(out_lst)
        assert out_lst[0] == x * y * c + z**2 + q2 * y**2 - q2 - c * x
        assert out_lst[1] == c
        assert out_lst[2] == -c * x
示例#4
0
    def test__get_linear_series__6(self):

        ring = PolyRing('x,y,v,w', True)
        ring.ext_num_field('t^2 + 1')
        a0 = ring.root_gens()[0]

        bp_tree_1 = BasePointTree(['xv', 'xw', 'yv', 'yw'])
        bp = bp_tree_1.add('xv', (a0, -a0), 2)

        bp_tree_2 = LinearSeries.get([2, 2], bp_tree_1).get_bp_tree()
        bp_tree_2_str = bp_tree_2.alt_str()
        bp_tree_2_str = bp_tree_2_str.replace('(a0)', 'a0')
        bp_tree_2_str = bp_tree_2_str.replace('(-a0)', '-a0')

        assert self.equal_output_strings(bp_tree_1.alt_str(), bp_tree_2_str)
示例#5
0
    def test__quo(self):

        ring = PolyRing('x,y,z', True)
        ring.ext_num_field('t^2 + t + 1')
        ring.ext_num_field('t^3 + t + a0 + 3')

        pol1 = ring.coerce('(x+1)*(x^2+a0+1)')
        pol2 = ring.coerce('(x+1)')
        assert str(pol1) == 'x^3 + x^2 + (a0 + 1)*x + a0 + 1'

        q = ring.quo(pol1, pol2)
        assert str(q) == 'x^2 + a0 + 1'
示例#6
0
    def test__resultant(self):

        ring = PolyRing('x,y,z', True)
        ring.ext_num_field('t^2 + t + 1')
        ring.ext_num_field('t^3 + t + a0 + 3')

        pol1 = ring.coerce('(x+1)*(x^2+a0+1)')
        pol2 = ring.coerce('x^5 + x + a0 + 3')
        x = ring.coerce('x')

        r = ring.resultant(pol1, pol2, x)
        assert str(r) == '7*a0 + 2'
示例#7
0
    def test__get_implicit_projection__3(self):

        pmz_lst = ['x^2*z+y^2*z+z^2*z', 'x^2*y', 'x*y^2', 'x*y*z']
        ls = LinearSeries(pmz_lst, PolyRing('x,y,z', True))

        # this method does not work properly yet
        imp_lst = ls.get_implicit_projection(3)
    def test__get_surf( self ):

        a0 = PolyRing( 'x,y,v,w', True ).ext_num_field( 't^2 + 1' ).root_gens()[0]  # i
        bp_tree = BasePointTree( ['xv', 'xw', 'yv', 'yw'] )
        bp = bp_tree.add( 'xv', ( -a0, a0 ), 1 )  # e1
        bp = bp_tree.add( 'xv', ( a0, -a0 ), 1 )  # e2

        ls = LinearSeries.get( [2, 2], bp_tree )  # |2(l1+l2)-e1-e2|
        sig = ( 5, 1 )
        coef_lst = [-1, 1, -1, 1, 0, 1, 1, -1]
        prv_Q = [( 1, 0, 0, 1, 0, 1, 1 ), ( 1, 0, 1, 0, 0, 1, 0 ), ( 1, 0, 0, 1, 0, 0, 0 ), ( 1, 0, 0, 0, 0, 1, 1 ), ( 1, 0, 0, 0, 0, 0, 1 ), ( 0, 1, 1, 0, 1, 1, 0 )]

        dct = get_surf( ls, sig, coef_lst, prv_Q )

        print( list( dct['Q'] ) )
        print( dct['pmz_lst'] )
        print( dct['imp_lst'] )
        print( list( dct['M'] ) )
        print( list( dct['UJ'][0] ) )
        print( list( dct['UJ'][1] ) )

        assert str( list( dct['Q'] ) ) == str( prv_Q )
        assert str( dct['pmz_lst'] ) == '[-c0*s0*c1^2 + c0^2*s1^2 - c0*s0*s1^2 + s0^2*s1^2 + c0*c1^2 - 2*c0^2*s1 + 2*c0*s0*s1 - 2*s0^2*s1 + c0*s1^2 - 2*s0*s1^2 + c0^2 - c0*s0 + s0^2 - 2*c0*s1 + 4*s0*s1 + s1^2 + c0 - 2*s0 - 2*s1 + 1, -c0*s0*c1^2 + s0^2*c1^2 - c0^2*c1*s1 + s0^2*s1^2 + c0^2*c1 + c0*c1^2 - 2*s0*c1^2 - 2*s0^2*s1 - 2*s0*s1^2 + s0^2 + c1^2 + 4*s0*s1 + s1^2 - 2*s0 - 2*s1 + 1, -c0^2*c1^2 + c0^2*c1*s1 - c0*s0*s1^2 + s0^2*s1^2 - c0^2*c1 + 2*c0*s0*s1 - 2*s0^2*s1 + c0*s1^2 - 2*s0*s1^2 - c0*s0 + s0^2 - 2*c0*s1 + 4*s0*s1 + s1^2 + c0 - 2*s0 - 2*s1 + 1, -c0*s0*c1^2 - c0^2*c1*s1 + c0^2*s1^2 + s0^2*s1^2 + c0^2*c1 + c0*c1^2 - 2*c0^2*s1 - 2*s0^2*s1 - 2*s0*s1^2 + c0^2 + s0^2 + 4*s0*s1 + s1^2 - 2*s0 - 2*s1 + 1, c0^2*s1^2 + s0^2*s1^2 - 2*c0^2*s1 - 2*s0^2*s1 - 2*s0*s1^2 + c0^2 + s0^2 + 4*s0*s1 + s1^2 - 2*s0 - 2*s1 + 1, -c0*s0*c1^2 + s0^2*c1^2 - 2*c0^2*c1*s1 + c0*s0*c1*s1 - s0^2*c1*s1 + 2*c0^2*c1 - c0*s0*c1 + s0^2*c1 + c0*c1^2 - 2*s0*c1^2 - c0*c1*s1 +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x5^2 - x2*x3*x5^2 - 6*x0*x4*x5^2 + x1*x4*x5^2 - x2*x4*x5^2 + 7*x3*x4*x5^2 - 2*x4^2*x5^2 - x0*x5^3 + x2*x5^3 + x3*x5^3 - x4*x5^3]'
        assert str( list( dct['M'] ) ) == '[(-2, 1, -1/2, -1, 5, 1/2), (1, -2, -1/2, -1, 7/2, 2), (-1/2, -1/2, 0, 3/2, -3, -1/2), (-1, -1, 3/2, 2, -7/2, -1/2), (5, 7/2, -3, -7/2, -1, -3/2), (1/2, 2, -1/2, -1/2, -3/2, -2)]'
        assert str( list( dct['UJ'][0] ) ) == '[(1.35786975221142?, 1.07346104931619?, -0.55476539365996?, -0.40827309297366?, -2.0166161907848?, -0.97578089340802?), (1.164220993205174?, -1.238241275959885?, -0.069749665334111?, -0.0755220593640689?, -0.253358176151464?, 0.852764409706635?), (0.2374970415389016?, 0.06861265576467416?, 0.8393349903238033?, -0.2501991469577176?, 0.08951234160953201?, -0.1515231571929268?), (0.05097640435508013?, -0.3562824973464569?, -0.0953003146422521?, 0.01449254245924731?, 0.1356081690977796?, -0.5531500949878551?), (0.0804899878314170?, 0.04919673465402113?, 0.00930980680657234?, 0.1455320285330222?, 0.0527745414065528?, -0.00912281285573814?), (1.1245900860635?, 0.9053316050139?, -1.0130556284196?, -1.5021250674132?, 1.7776721895235?, 0.0915041576522?)]'
        assert str( list( dct['UJ'][1] ) ) == '[(-1.000000000000000?, 0, 0, 0, 0, 0), (0, -1.000000000000000?, 0, 0, 0, 0), (0, 0, -1.000000000000000?, 0, 0, 0), (0, 0, 0, -1.000000000000000?, 0, 0), (0, 0, 0, 0, -1.000000000000000?, 0), (0, 0, 0, 0, 0, 1.000000000000000?)]'
示例#9
0
    def test__get_linear_series__8(self):

        a0 = PolyRing('x,y,v,w').ext_num_field('t^2 + 1').root_gens()[0]  # i
        bp_tree_1 = BasePointTree(['xv', 'xw', 'yv', 'yw'])

        bp_tree_1.add('xv', (-2 * a0, a0), 1)  # e2
        bp_tree_1.add('xv', (2 * a0, -a0), 1)  # e3
        bp_tree_1.add('xv', (a0, -a0), 1)  # e4
        bp_tree_1.add('xv', (-a0, a0), 1)  # e5

        ls = LinearSeries.get([2, 1], bp_tree_1)  # |2e0+1e1-e2-e3-e4-e5|
        print(ls)
        print(bp_tree_1)

        bp_tree_2 = ls.get_bp_tree()
        print(bp_tree_2)

        bp_tree_2_str = bp_tree_2.alt_str()
        bp_tree_2_str = bp_tree_2_str.replace('(a0)', 'a0')
        bp_tree_2_str = bp_tree_2_str.replace('(-a0)', '-a0')

        print(bp_tree_1.alt_str())
        print(bp_tree_2.alt_str())

        assert self.equal_output_strings(bp_tree_1.alt_str(), bp_tree_2_str)
    def test__get_proj( self ):

        # construct dct
        a0 = PolyRing( 'x,y,v,w', True ).ext_num_field( 't^2 + 1' ).root_gens()[0]  # i
        bp_tree = BasePointTree( ['xv', 'xw', 'yv', 'yw'] )
        bp = bp_tree.add( 'xv', ( -a0, a0 ), 1 )  # e1
        bp = bp_tree.add( 'xv', ( a0, -a0 ), 1 )  # e2
        ls = LinearSeries.get( [2, 2], bp_tree )  # |2(l1+l2)-e1-e2|
        sig = ( 6, 1 )
        coef_lst = [-1, -1, 0, 0, 0, -1, 1, 0, -1, -1, -1]
        prv_Q = None
        dct = get_surf( ls, sig, coef_lst, prv_Q )

        # construct projection matrix P
        U, J = dct['UJ']
        U.swap_rows( 0, 6 )
        J.swap_columns( 0, 6 )
        J.swap_rows( 0, 6 )
        assert dct['M'] == approx_QQ( U.T * J * U )
        approxU = approx_QQ( U )
        P = get_prj_mat( 4, 7, 0 )
        P[0, 6] = -1;P[3, 3] = 0;P[3, 4] = 1
        P = P * approxU

        # call get_proj
        f_xyz, pmz_AB_lst = get_proj( dct['imp_lst'], dct['pmz_lst'], P )

        print( f_xyz )
        print( pmz_AB_lst )

        assert str( f_xyz ).startswith( '232136158126691416007724114435018582183550370830165237' )
        assert str( pmz_AB_lst ).startswith( '[3687965761301911367110366337978449028075575/' )
 def test__get_solution_set__1(self):
     ls = LinearSeries(
         ['x*z^13', 'x*z^13', 'x^9*y^5', 'x^8*y^6', 'x*y*z^12+2*y*z^13'],
         PolyRing('x,y,z', True))
     zls = ls.copy().chart(['z'])
     print(zls)
     sol_lst = zls.get_solution_set()
     print(sol_lst)
     assert sol_lst == [(0, 0)]
示例#12
0
    def test__aux_gcd(self):

        ring = PolyRing('x,y,z', True)
        ring.ext_num_field('t^2 + t + 1')
        ring.ext_num_field('t^3 + t + a0 + 3')

        agcd = ring.aux_gcd('[x*y^2 + a1*y^3, y^5, x^5*y^5]')
        assert str(agcd) == '([(y, 2)], [x + a1*y, y^3, x^5*y^3])'
示例#13
0
    def test__get_linear_series__2(self):

        ring = PolyRing('x,y,z', True)
        ls = LinearSeries(['x^2+y^2', 'y^2+x*z'], ring)
        bp_tree_1 = ls.get_bp_tree()

        ls = LinearSeries.get([2], bp_tree_1)
        bp_tree_2 = ls.get_bp_tree()

        assert self.equal_output_strings(str(bp_tree_1), str(bp_tree_2))
示例#14
0
    def test__factor(self):

        ring = PolyRing('x,y,z', True)

        ring.ext_num_field('t^2 + t + 1')
        ring.ext_num_field('t^3 + t + a0 + 3')

        pol = ring.coerce('(x+1)*(x^2+a0+1)')
        assert str(pol) == 'x^3 + x^2 + (a0 + 1)*x + a0 + 1'
        assert str(sage_factor(pol)) == '(x + 1) * (x + a0) * (x - a0)'

        con = ring.coerce('a0')
        assert str(sage_factor(con)) == 'a0'
示例#15
0
    def test__diff__1(self):

        ring = PolyRing('x,y,v,w', True)
        ring.ext_num_field('t^2 + 1')
        x, y, v, w, a0 = ring.coerce('x,y,v,w,a0')

        assert ring.diff(w - a0, w, 1) == 1
示例#16
0
    def test__diff__2(self):

        ring = PolyRing('x,y,v,w', True)
        ring.ext_num_field('t^2 + 1')
        x, y, v, w, a0 = ring.coerce('x,y,v,w,a0')

        assert ring.diff(x**3 - a0, x, 3) == 6
示例#17
0
    def test__diff__3(self):

        ring = PolyRing('x,y,v,w', True)
        ring.ext_num_field('t^2 + 1')
        x, y, v, w, a0 = ring.coerce('x,y,v,w,a0')

        d1 = ring.diff(y**2 * x**3 - a0, x, 2)
        d2 = ring.diff(d1, y, 2)

        assert d1 == 6 * y**2 * x
        assert d2 == 12 * x
示例#18
0
    def test__quo( self ):

        ring = PolyRing( 'x,y,z', True )
        ring.ext_num_field( 't^2 + 1' )
        ring.ext_num_field( 't^3 + a0' )

        ls = LinearSeries( ['x^2', 'x + x^2'], ring )
        assert str( ls.quo( 'x' ) ) == '{ 2, <<x, x + 1>>, QQ( <a0|t^2 + 1>, <a1|t^2 + a0*t - 1> )[x, y, z] }'
示例#19
0
    def test__subs( self ):

        ring = PolyRing( 'x,y,z', True )
        ring.ext_num_field( 't^2 + 1' )
        ring.ext_num_field( 't^3 + a0' )

        a0, a1 = ring.root_gens()
        x, y, z = ring.gens()

        pol_lst = [x ** 2 + a0 * y * z, y + a1 * z + x ]
        ls = LinearSeries( pol_lst, ring )
        assert str( ls.pol_lst ) == '[x^2 + a0*y*z, x + y + a1*z]'

        ls.subs( {x: x + 1} )
        assert str( ls.pol_lst ) == '[x^2 + a0*y*z + 2*x + 1, x + y + a1*z + 1]'
示例#20
0
    def test__get_linear_series__7(self):

        ring = PolyRing('x,y,z', True)

        # checks that 2 infinitly near base points and
        # a simple base point is not collinear.
        #
        bp_tree = BasePointTree()
        bp_tree.add('z', (1, 0), 1)
        bp = bp_tree.add('z', (0, 1), 1)
        bp.add('t', (1, 0), 1)
        ls = LinearSeries.get([1], bp_tree)

        assert ls.pol_lst == []
    def test__get_solution_set__2(self):

        ls = LinearSeries(['x^2*z+y^2*z', 'y^3+z^3'], PolyRing('x,y,z', True))
        xls = ls.copy().chart(['x'])

        sol_lst = xls.get_solution_set()

        assert str(
            xls
        ) == '{ 2, <<y^2*z + z, y^3 + z^3>>, QQ( <a0|t^2 + 1>, <a1|t^2 + a0*t - 1> )[y, z] }'

        assert str(
            sol_lst
        ) == '[(-a0, a0), (a0, -a1), (0, 0), (a0, -a0), (a0, a1 + a0), (-a0, a1), (-a0, -a1 - a0)]'
示例#22
0
    def test__translate_to_origin( self ):

        ring = PolyRing( 'x,y,z', True )
        ring.ext_num_field( 't^2 + 1' )
        ring.ext_num_field( 't^3 + a0' )

        ls = LinearSeries( ['y^2', 'y*x'], ring )
        xls = ls.copy().chart( ['x'] )

        a0, a1 = ring.coerce( 'a0,a1' )

        xls.translate_to_origin( ( a0 + 1, a1 + a0 ) )
        assert str( xls ) == '{ 2, <<y^2 + (2*a0 + 2)*y + 2*a0, y + a0 + 1>>, QQ( <a0|t^2 + 1>, <a1|t^2 + a0*t - 1> )[y, z] }'
示例#23
0
    def test__approx_QQ_coef__1(self):

        ring = PolyRing('x,y,z', True).ext_num_field('t^2 - 3')
        a0 = ring.root_gens()[0]
        ci_idx = 1
        for lbl, elt in [('a0', a0), ('-a0', -a0)]:
            print(lbl + ' = ' + str(elt.abs()))
            for ci in elt.complex_embeddings():
                print('\t\t' + str(ci))
            s = str(elt.complex_embeddings()[ci_idx])
            print(lbl + '.complex_embedding()[' + str(ci_idx) + '] = ' + s)

        print('--- a0 ---')
        out = OrbRing.approx_QQ_coef(a0, ci_idx)
        chk = sage_QQ(3900231685776981) / 2251799813685248
        print(out)
        print(sage_n(out))
        assert out == chk

        print('--- (-a0) ---')
        out = OrbRing.approx_QQ_coef(-a0, ci_idx)
        print(out)
        print(sage_n(out))
        assert out == -chk
示例#24
0
    def test__diff( self ):

        ring = PolyRing( 'x,y,z', True )
        ring.ext_num_field( 't^2 + 1' )
        ring.ext_num_field( 't^3 + a0' )

        ls = LinearSeries( ['a0*x^2+y^3*z^3', 'x+z+z^3*y^4'], ring )
        xls = ls.copy().chart( ['x'] )

        assert str( xls.diff( 3, 2 ).pol_lst ) == '[36*z, 144*y*z]'
示例#25
0
    def test__chart( self ):

        ring = PolyRing( 'x,y,z', True )
        ring.ext_num_field( 't^2 + 1' )
        ring.ext_num_field( 't^3 + a0' )


        ls = LinearSeries( ['x^2+a0*y*z', 'x+y+a1*z '], ring )
        xls = ls.copy().chart( ['x'] )

        assert str( xls.pol_lst ) == '[a0*y*z + 1, y + a1*z + 1]'
    def test__verify_get_surf( self ):

        a0 = PolyRing( 'x,y,v,w', True ).ext_num_field( 't^2 + 1' ).root_gens()[0]  # i
        bp_tree = BasePointTree( ['xv', 'xw', 'yv', 'yw'] )
        bp = bp_tree.add( 'xv', ( -a0, a0 ), 1 )  # e1
        bp = bp_tree.add( 'xv', ( a0, -a0 ), 1 )  # e2

        ls = LinearSeries.get( [2, 2], bp_tree )  # |2(l1+l2)-e1-e2|
        sig = ( 6, 1 )
        coef_lst = [-1, -1, 0, 0, 0, -1, 1, 0, -1, -1, -1]
        prv_Q = None
        dct = get_surf( ls, sig, coef_lst, prv_Q )

        test_dct = verify_get_surf( dct )
        print( test_dct )

        assert test_dct['all']
示例#27
0
    def test__blow_up_origin( self ):

        ring = PolyRing( 'x,y,z', True )
        ring.ext_num_field( 't^2 + 1' )
        ring.ext_num_field( 't^3 + a0' )

        ls = LinearSeries( ['x^2', 'x*z + y^2'], ring )
        zls = ls.copy().chart( ['z'] )

        zls, m = zls.blow_up_origin( 's' )
        assert str( zls ) == '{ 2, <<x, x*y^2 + 1>>, QQ( <a0|t^2 + 1>, <a1|t^2 + a0*t - 1> )[x, y] }'
        assert m == 1
示例#28
0
def usecase__construct_surfaces():
    '''
    We construct a surface parametrization and its Neron-Severi lattice. 
     
    Requires the linear_series package.
    '''

    # Blowup of projective plane in 3 colinear points
    # and 2 infinitely near points. The image of the
    # map associated to the linear series is a quartic
    # del Pezzo surface with 5 families of conics.
    # Moreover the surface contains 8 straight lines.
    #
    ring = PolyRing('x,y,z', True)
    p1 = (-1, 0)
    p2 = (0, 0)
    p3 = (1, 0)
    p4 = (0, 1)
    p5 = (2, 0)
    bp_tree = BasePointTree()
    bp_tree.add('z', p1, 1)
    bp_tree.add('z', p2, 1)
    bp_tree.add('z', p3, 1)
    bp = bp_tree.add('z', p4, 1)
    bp.add('t', p5, 1)
    ls = LinearSeries.get([3], bp_tree)
    NSTools.p(ls.get_bp_tree())
    NSTools.p('implicit equation =\n\t', ls.get_implicit_image())

    # construct NS-lattice where p1=e1,...,p5=e5
    rank = 6
    d_lst = ['e0-e1-e2-e3', 'e4-e5']  # basepoint p5 is infinitely near to p4
    Md_lst = []
    M = sage_identity_matrix(6)
    d_lst = [Div.new(d, rank) for d in d_lst]
    Md_lst = [Div.new(Md, rank) for Md in Md_lst]
    M = sage_matrix(M)
    dpl = DPLattice(d_lst, Md_lst, M)
    NSTools.p('Neron-Severi lattice =', dpl)

    # search representative for the equivalence class in classification
    assert dpl in DPLattice.get_cls(rank)
    def test__rand_surf_prj( self ):

        a0 = PolyRing( 'x,y,v,w', True ).ext_num_field( 't^2 + 1' ).root_gens()[0]  # i
        bp_tree = BasePointTree( ['xv', 'xw', 'yv', 'yw'] )
        bp = bp_tree.add( 'xv', ( -a0, a0 ), 1 )  # e1
        bp = bp_tree.add( 'xv', ( a0, -a0 ), 1 )  # e2

        ls = LinearSeries.get( [2, 2], bp_tree )  # |2(l1+l2)-e1-e2|
        prj_dim = 5
        prv_Q = sage_matrix( sage_QQ, [( 1, 1, 1, 1, 1, 0, 1 ), ( 0, 1, 0, 1, 0, 0, 0 ), ( 1, 0, 0, 1, 0, 1, 1 ), ( 1, 0, 1, 1, 0, 1, 0 ), ( 0, 0, 1, 0, 1, 0, 1 ), ( 0, 1, 1, 0, 1, 1, 1 )] )

        Q, pmz_lst, imp_lst = rand_surf_prj( ls, prj_dim, prv_Q )

        print( 'Q =\n' + str( list( Q ) ) )
        print( '\npmz_lst =\n' + str( pmz_lst ) )
        print( '\nimp_lst =\n' + str( imp_lst ) )

        assert Q == prv_Q
        assert str( pmz_lst ) == '[s0^2*c1^2 + c0*s0*c1*s1 - s0^2*c1*s1 + c0^2*s1^2 - c0*s0*s1^2 + s0^2*s1^2 - c0*s0*c1 + s0^2*c1 - 2*s0*c1^2 - 2*c0^2*s1 + 2*c0*s0*s1 - 2*s0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1*x4*x5 + 3*x2*x4*x5 - 13*x3*x4*x5 - 6*x4^2*x5 - x0*x5^2 - 4*x1*x5^2 + x2*x5^2 + 4*x3*x5^2 + 6*x4*x5^2 - 2*x5^3, 40*x1^2*x3 - 10*x1*x2*x3 + 40*x2^2*x3 - 20*x0*x3^2 + 10*x1*x3^2 - 45*x2*x3^2 + 25*x3^3 + 276*x0*x2*x4 - 184*x1*x2*x4 + 92*x2^2*x4 - 307*x0*x3*x4 + 239*x1*x3*x4 - 331*x2*x3*x4 + 195*x3^2*x4 - 184*x0*x4^2 - 184*x2*x4^2 + 309*x3*x4^2 + 92*x4^3 - 120*x0*x2*x5 + 80*x1*x2*x5 - 40*x2^2*x5 + 135*x0*x3*x5 - 85*x1*x3*x5 + 125*x2*x3*x5 - 80*x3^2*x5 + 126*x0*x4*x5 + 184*x1*x4*x5 + 34*x2*x4*x5 - 219*x3*x4*x5 - 224*x4^2*x5 - 20*x0*x5^2 - 80*x1*x5^2 + 20*x2*x5^2 + 40*x3*x5^2 + 172*x4*x5^2 - 40*x5^3, 400*x2^3 - 80*x1*x2*x3 - 640*x2^2*x3 - 60*x0*x3^2 + 80*x1*x3^2 + 335*x2*x3^2 - 35*x3^3 - 792*x0*x2*x4 + 228*x1*x2*x4 - 264*x2^2*x4 + 419*x0*x3*x4 - 403*x1*x3*x4 + 637*x2*x3*x4 - 255*x3^2*x4 + 328*x0*x4^2 + 428*x2*x4^2 - 493*x3*x4^2 - 164*x4^3 + 352*x0*x2*x5 + 32*x1*x2*x5 - 16*x2^2*x5 - 159*x0*x3*x5 + 223*x1*x3*x5 - 187*x2*x3*x5 + 70*x3^2*x5 - 150*x0*x4*x5 - 428*x1*x4*x5 - 386*x2*x4*x5 + 441*x3*x4*x5 + 412*x4^2*x5 - 8*x0*x5^2 + 168*x1*x5^2 + 108*x2*x5^2 - 98*x3*x5^2 - 332*x4*x5^2 + 84*x5^3, 100*x1*x2^2 - 140*x1*x2*x3 - 70*x2^2*x3 + 20*x0*x3^2 + 40*x1*x3^2 + 105*x2*x3^2 - 55*x3^3 - 236*x0*x2*x4 + 224*x1*x2*x4 - 312*x2^2*x4 + 277*x0*x3*x4 - 249*x1*x3*x4 + 596*x2*x3*x4 - 290*x3^2*x4 + 349*x0*x4^2 + 75*x1*x4^2 + 199*x2*x4^2 - 294*x3*x4^2 - 137*x4^3 + 166*x0*x2*x5 - 144*x1*x2*x5 + 122*x2^2*x5 - 147*x0*x3*x5 + 109*x1*x3*x5 - 296*x2*x3*x5 + 135*x3^2*x5 - 200*x0*x4*x5 - 474*x1*x4*x5 - 88*x2*x4*x5 + 228*x3*x4*x5 + 346*x4^2*x5 + 11*x0*x5^2 + 219*x1*x5^2 - 11*x2*x5^2 - 34*x3*x5^2 - 281*x4*x5^2 + 72*x5^3, 400*x0*x2^2 - 480*x1*x2*x3 - 40*x2^2*x3 - 260*x0*x3^2 + 480*x1*x3^2 - 315*x2*x3^2 + 215*x3^3 + 288*x0*x2*x4 - 92*x1*x2*x4 - 704*x2^2*x4 - 791*x0*x3*x4 + 167*x1*x3*x4 + 407*x2*x3*x4 + 395*x3^2*x4 + 208*x0*x4^2 + 200*x1*x4^2 - 92*x2*x4^2 + 577*x3*x4^2 - 4*x4^3 - 328*x0*x2*x5 + 352*x1*x2*x5 + 24*x2^2*x5 + 451*x0*x3*x5 + 53*x1*x3*x5 - 57*x2*x3*x5 - 230*x3^2*x5 + 150*x0*x4*x5 - 508*x1*x4*x5 - 46*x2*x4*x5 - 949*x3*x4*x5 - 68*x4^2*x5 - 88*x0*x5^2 + 48*x1*x5^2 + 188*x2*x5^2 + 322*x3*x5^2 + 148*x4*x5^2 - 76*x5^3, 100*x1^2*x2 - 40*x1*x2*x3 + 80*x2^2*x3 - 30*x0*x3^2 + 40*x1*x3^2 - 95*x2*x3^2 + 45*x3^3 + 754*x0*x2*x4 - 536*x1*x2*x4 + 618*x2^2*x4 - 903*x0*x3*x4 + 711*x1*x3*x4 - 1444*x2*x3*x4 + 810*x3^2*x4 - 811*x0*x4^2 - 125*x1*x4^2 - 561*x2*x4^2 + 916*x3*x4^2 + 343*x4^3 + 50*x1^2*x5 - 344*x0*x2*x5 + 246*x1*x2*x5 - 248*x2^2*x5 + 373*x0*x3*x5 - 281*x1*x3*x5 + 564*x2*x3*x5 - 315*x3^2*x5 + 480*x0*x4*x5 + 936*x1*x4*x5 + 112*x2*x4*x5 - 622*x3*x4*x5 - 834*x4^2*x5 - 49*x0*x5^2 - 371*x1*x5^2 + 49*x2*x5^2 + 106*x3*x5^2 + 639*x4*x5^2 - 148*x5^3, 800*x1^3 + 10*x1*x2*x3 + 280*x2^2*x3 - 80*x0*x3^2 - 10*x1*x3^2 - 295*x2*x3^2 + 95*x3^3 + 2444*x0*x2*x4 - 2296*x1*x2*x4 - 1052*x2^2*x4 - 1733*x0*x3*x4 + 1221*x1*x3*x4 + 91*x2*x3*x4 - 15*x3^2*x4 + 104*x0*x4^2 + 600*x1*x4^2 - 1496*x2*x4^2 + 2351*x3*x4^2 + 348*x4^3 - 100*x1^2*x5 - 1024*x0*x2*x5 + 816*x1*x2*x5 + 192*x2^2*x5 + 833*x0*x3*x5 - 551*x1*x3*x5 + 119*x2*x3*x5 - 40*x3^2*x5 + 190*x0*x4*x5 + 196*x1*x4*x5 + 642*x2*x4*x5 - 1977*x3*x4*x5 - 904*x4^2*x5 - 104*x0*x5^2 - 216*x1*x5^2 + 104*x2*x5^2 + 376*x3*x5^2 + 764*x4*x5^2 - 208*x5^3]'
示例#30
0
    def test__get_base_point_tree(self):

        ring = PolyRing('x,y,z', True)
        ring.ext_num_field('t^2 + 1')
        ring.ext_num_field('t^3 + a0')

        ls = LinearSeries(['x^2+a0*y*z', 'y+a1*z+x'], ring)

        out = str(ls.get_bp_tree())
        chk = """
            { 2, <<x^2 + a0*y*z, x + y + a1*z>>, QQ( <a0|t^2 + 1>, <a1|t^2 + a0*t - 1>, <a2|t^2 - a0*t - a0*a1> )[x, y, z] }
            chart=z, depth=0, mult=1, sol=(-a2 + a0, a2 - a1 - a0), { 2, <<x^2 + a0*y, x + y + a1>>, QQ( <a0|t^2 + 1>, <a1|t^2 + a0*t - 1>, <a2|t^2 - a0*t - a0*a1> )[x, y] }
            chart=z, depth=0, mult=1, sol=(a2, -a2 - a1), { 2, <<x^2 + a0*y, x + y + a1>>, QQ( <a0|t^2 + 1>, <a1|t^2 + a0*t - 1>, <a2|t^2 - a0*t - a0*a1> )[x, y] }
            """
        assert self.equal_output_strings(out, chk)