Ejemplo n.º 1
0
    def __constructJasObject(self):
        #from types import StringType
        from jas import PolyRing, ZZ
        # set up the polynomial ring (Jas syntax)
        if 'hasParameters' in self.__dict__ and self.hasParameters != '':
            #K = 'K.<%s> = PolynomialRing(ZZ)' % self.hasParameters
            #R = K + '; R.<%s> = PolynomialRing(K)' % self.hasVariables
            K = PolyRing(ZZ(), str(self.hasParameters))
            R = PolyRing(K, str(self.hasVariables))
            gens = '%s,%s' % (self.hasParameters, self.hasVariables)
        else:
            #R = 'R.<%s> = PolynomialRing(ZZ)' % (self.hasVariables)
            R = PolyRing(ZZ(), str(self.hasVariables))
            gens = str(self.hasVariables)
        # translate Jas syntax to pure Python and execute
        #exec(preparse(R))
        Rg = "(one," + gens + ") = R.gens();"
        #print str(R)
        exec(str(Rg))  # safe here since R did evaluate
        #print "R = " + str(R)
        self.jasRing = R

        # avoid XSS: check if polynomials are clean
        from edu.jas.poly import GenPolynomialTokenizer
        vs = GenPolynomialTokenizer.expressionVariables(str(gens))
        vs = sorted(vs)
        #print "vs = " + str(vs)
        vsb = set()
        [
            vsb.update(GenPolynomialTokenizer.expressionVariables(str(s)))
            for s in self.basis
        ]
        vsb = sorted(list(vsb))
        #print "vsb = " + str(vsb)
        if vs != vsb:
            raise ValueError("invalid variables: expected " + str(vs) +
                             ", got " + str(vsb))
        # construct polynomials in the constructed ring from
        # the polynomial expressions
        self.jasBasis = []
        for ps in self.basis:
            #print "ps = " + str(ps)
            ps = str(ps)
            ps = ps.replace('^', '**')
            #exec(preparse("symbdata_ideal = %s" % ps))
            #exec("symbdata_poly = %s" % ps)
            pol = eval(ps)
            self.jasBasis.append(pol)
Ejemplo n.º 2
0
 def testRingZM(self):
     r = PolyRing( GF(17), "(t,x)", Order.INVLEX );
     self.assertEqual(str(r),'PolyRing(GFI(17),"t,x",Order.INVLEX)');
     [one,x,t] = r.gens();
     self.assertTrue(one.isONE());
     self.assertTrue(len(x)==1);
     self.assertTrue(len(t)==1);
     #
     f = 11 * x**4 - 13 * t * x**2 - 11 * x**2 + 2 * t**2 + 11 * t;
     f = f**2 + f + 3;
     #print "f = " + str(f);
     self.assertEqual(str(f),'( 4 * x**4 + 16 * t**2 * x**3 + 10 * x**3 + 9 * t**4 * x**2 + 10 * t**2 * x**2 + 4 * x**2 + 3 * t**6 * x + t**4 * x + 11 * x + 2 * t**8 + 13 * t**6 + 13 * t**4 + 6 * t**2 + 3 )');
Ejemplo n.º 3
0
 def testRingQQ(self):
     r = PolyRing( QQ(), "(t,x)", Order.INVLEX );
     self.assertEqual(str(r),'PolyRing(QQ(),"t,x",Order.INVLEX)');
     [one,x,t] = r.gens();
     self.assertTrue(one.isONE());
     self.assertTrue(len(x)==1);
     self.assertTrue(len(t)==1);
     #
     f = 11 * x**4 - 13 * t * x**2 - 11 * x**2 + 2 * t**2 + 11 * t;
     f = f**2 + f + 3;
     #print "f = " + str(f);
     self.assertEqual(str(f),'( 4 * x**4 - 52 * t**2 * x**3 + 44 * x**3 + 213 * t**4 * x**2 - 330 * t**2 * x**2 + 123 * x**2 - 286 * t**6 * x + 528 * t**4 * x - 255 * t**2 * x + 11 * x + 121 * t**8 - 242 * t**6 + 132 * t**4 - 11 * t**2 + 3 )');
Ejemplo n.º 4
0
#
# jython examples for jas.
# $Id$
#

import sys

from jas import PolyRing, QQ, RF
from jas import startLog
from jas import terminate

# Montes JSC 2002, 33, 183-208, example 11.2
# integral function coefficients

r = PolyRing(PolyRing(QQ(), "f, e, d, c, b, a", PolyRing.lex), "y,x",
             PolyRing.lex)
#r = PolyRing( PolyRing(QQ(),"f, e, d, c, b, a",PolyRing.grad), "y,x", PolyRing.lex );
#r = PolyRing( PolyRing(QQ(),"f, e, d, c, b, a",PolyRing.lex), "y,x", PolyRing.grad );
#r = PolyRing( PolyRing(QQ(),"e, d, c, b, f, a",PolyRing.lex), "y,x", PolyRing.grad );
print "Ring: " + str(r)
print

#[one,e,d,c,b,f,a,y,x] = r.gens();
#automatic: [one,f,e,d,c,b,a,y,x] = r.gens();
print "gens: ", [str(f) for f in r.gens()]
print

f1 = x**2 + b * y**2 + 2 * c * x * y + 2 * d * x + 2 * e * y + f
f2 = x + c * y + d
f3 = b * y + c * x + e
Ejemplo n.º 5
0
# $Id$
#

import sys;

from jas import PolyRing, ZZ, QQ, RealN, CC, ZM, RF, terminate
from edu.jas.root import RealArithUtil
from edu.jas.arith import ArithUtil

# example for rational and real algebraic numbers
#
#

# continued fractions:

r = PolyRing(QQ(),"alpha",PolyRing.lex);
print "r = " + str(r);
e,a = r.gens();
print "e     = " + str(e);
print "a     = " + str(a);
sqrt2 = a**2 - 2;
print "sqrt2 = " + str(sqrt2);
Qs2r = RealN(sqrt2,[1,[3,2]],a-1);
#Qs2r = RealN(sqrt2,[-2,-1],a+1);
print "Qs2r  = " + str(Qs2r.factory()) + " :: " + str(Qs2r.elem);
one,alpha = Qs2r.gens();
print "one   = " + str(one);
print "alpha = " + str(alpha);


cf = Qs2r.contFrac(20);
Ejemplo n.º 6
0
#
# jython examples for jas.
# $Id$
#

import sys;

from java.lang import System

from jas import Ring, PolyRing
from jas import ZM, QQ, AN, RF, CR
from jas import terminate, startLog

# polynomial examples: complex factorization via algebraic factorization

r = PolyRing( CR(QQ()), "x", PolyRing.lex );
print "Ring: " + str(r);
print;
[one,I,x] = r.gens();


f1 = x**3 - 2;
f2 = ( x - I ) * ( x + I );
f3 = ( x**3 - 2 * I );

#f = f1**2 * f2 * f3;
f = f1 * f2 * f3;
#f = f1 * f2;
#f = f1 * f3;
#f = f2 * f3;
#f = f3;
Ejemplo n.º 7
0
#
# jython examples for jas.
# $Id$
#

from java.lang import System

from jas import PolyRing, ZM, GF
from jas import terminate, startLog

# system biology examples: GB in Z_2
# see: Informatik Spektrum, 2009, February,
# Laubenbacher, Sturmfels: Computer Algebra in der Systembiologie

r = PolyRing(GF(2),"M, B, A, L, P",PolyRing.lex);
print "PolyRing: " + str(r);
print;

#automatic: [one,M,B,A,L,P] = r.gens();

f1 = M - A;
f2 = B - M;
f3 = A - A - L * B - A * L * B;
f4 = P - M;
f5 = L - P - L - L * B - L * P - L * B * P;
## t1 = M - 1;
## t2 = B - 1;
## t3 = A - 1;
## t4 = L - 1;
## t5 = P - 1;
#
Ejemplo n.º 8
0
import sys

from jas import Ring, PolyRing, Ideal, QQ, ZZ, GF, ZM, CC
from jas import startLog, terminate

# trinks 6/7 example

# QQ = rational numbers, ZZ = integers, CC = complex rational numbers, GF = finite field
#QQ = QQ(); ZZ = ZZ(); CC = CC();
#r = PolyRing( GF(19),"B,S,T,Z,P,W", PolyRing.lex);
#r = PolyRing( GF(1152921504606846883),"B,S,T,Z,P,W", PolyRing.lex); # 2^60-93
#r = PolyRing( GF(2**60-93),"B,S,T,Z,P,W", PolyRing.lex);
#r = PolyRing( CC(),"B,S,T,Z,P,W", PolyRing.lex);
#r = PolyRing( ZZ(),"B,S,T,Z,P,W", PolyRing.lex); # not for parallel
r = PolyRing(QQ(), "B,S,T,Z,P,W", PolyRing.lex)
print "Ring: " + str(r)
print

# sage like: with generators for the polynomial ring
#[one,I,B,S,T,Z,P,W] = r.gens(); # is automaticaly included
#[one,B,S,T,Z,P,W] = r.gens(); # is automaticaly included

f1 = 45 * P + 35 * S - 165 * B - 36
f2 = 35 * P + 40 * Z + 25 * T - 27 * S
f3 = 15 * W + 25 * S * P + 30 * Z - 18 * T - 165 * B**2
f4 = -9 * W + 15 * T * P + 20 * S * Z
f5 = P * W + 2 * T * Z - 11 * B**3
f6 = 99 * W - 11 * B * S + 3 * B**2
f7 = 10000 * B**2 + 6600 * B + 2673
Ejemplo n.º 9
0
#
# jython examples for jas.
# $Id$
#

from java.lang import System

from jas import GF, PolyRing
from jas import terminate, startLog

# polynomial examples: factorization over Z_p

#r = Ring( "Mod 1152921504606846883 (x) L" );
#r = Ring( "Mod 19 (x) L" );
r = PolyRing( GF(19), "x", PolyRing.lex );
print "Ring: " + str(r);
print;

#[one,x] = r.gens();

#f = x**15 - 1;
#f = x * ( x + 1 )**2 * ( x**2 + x + 1 )**3;
#f = x**6 - 3 * x**5 + x**4 - 3 * x**3 - x**2 - 3 * x+ 1;
#f = x**(3*11*11) + 3 * x**(2*11*11) - x**(11*11);
#f = x**(3*11*11*11) + 3 * x**(2*11*11*11) - x**(11*11*11);
#f = (x**2+1)*(x-3)*(x-5)**3;
#f = x**4 + 1;
#f = x**12 + x**9 + x**6 + x**3 + 1;
#f = x**24 - 1;
#f = x**20 - 1;
#f = x**22 - 1;
Ejemplo n.º 10
0
print "KOI   = " + str(KOI);
o1 = 2 * oneOR + 3 * IOR + 4 * JOR + 5 * KOR + 6 * oneOI + 7 * IOI + 8 * JOI + 9 * KOI;
print "o1 = " + str(o1);
o2 = (1/o1)**2;
print "o2 = " + str(o2);
o3 = o2 * o1 * o1;
print "o3 = " + str(o3);
o4 = (-69,20164)*oneOR + (-3,20164)*IOR + (-1,5041)*JOR + (-5,20164)*KOR  + (-3,10082)*oneOI + (-7,20164)*IOI + (-2,5041)*JOI + (-9,20164)*KOI;
print "o4 = " + str(o4);
o5 = o2 - o4;
print "o5  = " + str(o5);
print;


print "------- PolyRing(ZZ(),\"x,y,z\") ---------";
r = PolyRing(ZZ(),"x,y,z",PolyRing.grad);
print "r = " + str(r);
[one,x,y,z] = r.gens();
print "one = " + str(one);
print "x   = " + str(x);
print "y   = " + str(y);
print "z   = " + str(z);
p1 = 2 + 3 * x + 4 * y + 5 * z + ( x + y + z )**2;
print "p1  = " + str(p1);
p2  = z**2 + 2 * y * z + 2 * x * z + y**2 + 2 * x * y + x**2 + 5 * z + 4 * y + 3 * x + 2;
print "p2  = " + str(p2);
p3 = p1 - p2;
print "p3  = " + str(p3);
print "p3.factory() = " + str(p3.factory());
print;
Ejemplo n.º 11
0
#
# jruby examples for jas.
# $Id$
#

from java.lang import System

from jas import SolvableRing, SolvPolyRing, PolyRing, RingElem
from jas import QQ, startLog, SRC, SRF

# Ore extension solvable polynomial example, Gomez-Torrecillas, 2003

pcz = PolyRing(QQ(),"x,y,z");
#is automatic: [one,x,y,z] = pcz.gens();

zrelations = [z, y,  y * z + x
             ];

print "zrelations: = " + str([ str(f) for f in zrelations ]);
print;

pz = SolvPolyRing(QQ(), "x,y,z", PolyRing.lex, zrelations);
print "SolvPolyRing: " + str(pz);
print;

#startLog();

fl = [ z**2 + y, y**2 + x];
ff = pz.ideal("",fl);
print "ideal ff: " + str(ff);
print;
# jython examples for jas.
# $Id$
#

import sys

from java.lang import System

from jas import Ring, PolyRing, QQ, ZM, RF, GF
from jas import terminate, startLog, noThreads

# polynomial examples: ideal radical decomposition, inseparable cases, dim > 0

#noThreads(); # must be called very early

cr = PolyRing(GF(5), "c", PolyRing.lex)
print "coefficient Ring: " + str(cr)
rf = RF(cr)
print "coefficient quotient Ring: " + str(rf.ring)

r = PolyRing(rf, "x,y,z", PolyRing.lex)
print "Ring: " + str(r)
print

#automatic: [one,c,x,y,z] = r.gens();
print one, c, x, y, z

#sys.exit();

#f1 = (x**2 - 5)**2;
#f1 = (y**10 - x**5)**3;
Ejemplo n.º 13
0
#
# jython examples for jas.
# $Id$
#

import sys

from jas import Ring, PolyRing, QQ, ZZ, RingElem
from jas import startLog, terminate

# GB examples

#r = Ring( "Z(t,x,y,z) L" );
#r = Ring( "Mod 11(t,x,y,z) L" );
#r = Ring( "Rat(t,x,y) L" );
r = PolyRing(QQ(), "t,x,y", PolyRing.lex)
#r = PolyRing( ZZ(), "t,x,y", PolyRing.lex );
print "Ring: " + str(r)
print

ps = """
(
 ( t - x - 2 y ),
 ( x^4 + 4 ),
 ( y^4 + 4 )
) 
"""

# ( y^4 + 4 x y^3 - 2 y^3 - 6 x y^2 + 1 y^2 + 6 x y + 2 y - 2 x + 3 ),
# ( x^2 + 1 ),
# ( y^3 - 1 )
Ejemplo n.º 14
0
#
# jython examples for jas.
# $Id$
#

import sys

from jas import Ring, PolyRing, Ideal, PSIdeal, QQ, ZM
from jas import startLog, terminate

# example from CLO(UAG), 4.4

#R = PolyRing( GF(32003), "x,y,z" );
R = PolyRing(QQ(), "x,y,z")
print "Ring: " + str(R)
print

#automatic: [one,x,y,z] = R.gens();

f1 = x**5 - x * y**6 - z**7
f2 = x * y + y**3 + z**3
f3 = x**2 + y**2 - z**2

L = [f1, f2, f3]
#print "L = ", str(L);

F = R.ideal(list=L)
print "Ideal: " + str(F)
print

PR = R.powerseriesRing()
Ejemplo n.º 15
0
#
# jython examples for jas.
# $Id$
#

import sys

from java.lang import System

from jas import Ring, RF, QQ, PolyRing
from jas import terminate, startLog

# elementary integration

r = PolyRing(QQ(), "x", PolyRing.lex)
print "r = " + str(r)
rf = RF(r)
print "rf = " + str(rf.factory())
[one, x] = rf.gens()
print "one   = " + str(one)
print "x     = " + str(x)
print

#f = 1 / ( 1 + x**2 );

#f = x**2 / ( x**2 + 1 );

#f = 1 / ( x**2 - 2 );
#f = 1 / ( x**3 - 2 );

#f = ( x + 3 ) / ( x**2- 3 * x - 40 );
Ejemplo n.º 16
0
## 2 z_2+6ay_2+20 y_2^3+2c \&
## 3 z_1^2+y_1^2+b \&
## 3z_2^2+y_2^2+b \&
## \end{Equations}
## \end{PossoExample}

#from java.lang import System

from jas import WordRing, WordPolyRing, WordPolyIdeal, PolyRing, SolvPolyRing, RingElem
from jas import terminate, startLog
from jas import QQ, ZZ, GF, ZM, WRC

# Hawes & Gibson example 2
# rational function coefficients

r = WordPolyRing(PolyRing(ZZ(), "a, c, b", PolyRing.lex), "y2, y1, z1, z2, x")
print "Ring: " + str(r)
print

one, a, c, b, y2, y1, z1, z2, x = r.gens()

p1 = x + 2 * y1 * z1 + 3 * a * y1**2 + 5 * y1**4 + 2 * c * y1
p2 = x + 2 * y2 * z2 + 3 * a * y2**2 + 5 * y2**4 + 2 * c * y2
p3 = 2 * z2 + 6 * a * y2 + 20 * y2**3 + 2 * c
p4 = 3 * z1**2 + y1**2 + b
p5 = 3 * z2**2 + y2**2 + b

F = [p1, p2, p3, p4, p5]

# make all variables commute
cm = [RingElem(q) for q in r.ring.commute()]
#
# jython examples for jas.
# $Id$
#

import sys

from java.lang import System

from jas import QQ, AN, RF, Ring, PolyRing
from jas import terminate, startLog

# polynomial examples: factorization over Q(sqrt(2))(x)(sqrt(x))[y]

Q = PolyRing(QQ(),"w2",PolyRing.lex);
print "Q     = " + str(Q);
[e,a] = Q.gens();
print "e     = " + str(e);
print "a     = " + str(a);

root = a**2 - 2;
print "root  = " + str(root);
Q2 = AN(root,field=True);
print "Q2    = " + str(Q2.factory());
[one,w2] = Q2.gens();
#print "one   = " + str(one);
#print "w2    = " + str(w2);
print;

Qp = PolyRing(Q2,"x",PolyRing.lex);
print "Qp    = " + str(Qp);
Ejemplo n.º 18
0
F = r.ideal(list=[r1, r2, r3, r4, r5, r6, r7, r8, f1, f2, f3])
#F = r.ideal( list=[r1,r2,f1,f2,f3] );
print "F = " + str(F)
print

startLog()

G = F.GB()
print "G = " + str(G)
print "isGB(G) = " + str(G.isGB())
print

# now as solvable polynomials

p = PolyRing(QQ(), "a,b,e1,e2,e3")
#is automatic: [one,a,b,e1,e2,e3] = p.gens();

relations = [e3, e1, e1 * e3 - e1, e3, e2, e2 * e3 - e2]

print "relations: =", [str(f) for f in relations]
print

#rp = SolvPolyRing(QQ(), "a,b,e1,e2,e3", rel=relations);
rp = SolvPolyRing(QQ(), "a,b,e1,e2,e3", PolyRing.lex, relations)
print "SolvPolyRing: " + str(rp)
print

print "gens =", [str(f) for f in rp.gens()]
#[one,a,b,e1,e2,e3] = rp.gens();
#[one,I,J,K,a,b,e1,e2,e3] = rp.gens();
## 3 z_1^2+y_1^2+b \&
## 3z_2^2+y_2^2+b \&
## \end{Equations}
## \end{PossoExample}


import sys;

from jas import Ring, PolyRing, QQ
from jas import startLog, terminate

# Hawes & Gibson example 2
# rational function coefficients

#r = Ring( "IntFunc(a, c, b) (y2, y1, z1, z2, x) G" );
r = PolyRing( PolyRing(QQ(),"a, c, b",PolyRing.lex), "y2, y1, z1, z2, x", PolyRing.grad );
print "Ring: " + str(r);
print;

#[one,a,c,b,y2,y1,z1,z2,x] = r.gens();

p1 = x + 2 * y1 * z1 + 3 * a * y1**2 + 5 * y1**4 + 2 * c * y1;
p2 = x + 2 * y2 * z2 + 3 * a * y2**2 + 5 * y2**4 + 2 * c * y2;
p3 = 2 * z2 + 6 * a * y2 + 20 * y2**3 + 2 * c; 
p4 = 3 * z1**2 + y1**2 + b;
p5 = 3 * z2**2 + y2**2 + b; 

F = [p1,p2,p3,p4,p5];

g = r.ideal( list=F );
print "Ideal: " + str(g);
## 2 z_2+6ay_2+20 y_2^3+2c \&
## 3 z_1^2+y_1^2+b \&
## 3z_2^2+y_2^2+b \&
## \end{Equations}
## \end{PossoExample}

import sys

from jas import Ring, PolyRing, RF, ZZ
from jas import startLog, terminate

# Hawes & Gibson example 2
# rational function coefficients

#r = Ring( "RatFunc(a, c, b) (y2, y1, z1, z2, x) G" );
r = PolyRing(RF(PolyRing(ZZ(), "a, c, b", PolyRing.lex)), "y2, y1, z1, z2, x",
             PolyRing.grad)
print "Ring: " + str(r)
print

[one, a, c, b, y2, y1, z1, z2, x] = r.gens()

p1 = x + 2 * y1 * z1 + 3 * a * y1**2 + 5 * y1**4 + 2 * c * y1
p2 = x + 2 * y2 * z2 + 3 * a * y2**2 + 5 * y2**4 + 2 * c * y2
p3 = 2 * z2 + 6 * a * y2 + 20 * y2**3 + 2 * c
p4 = 3 * z1**2 + y1**2 + b
p5 = 3 * z2**2 + y2**2 + b

p6 = ((p5 / a) / b) / c
print "p6 = ", p6

F = [p1, p2, p3, p4, p5]
#
# jython examples for jas.
# $Id$
#

import sys

from java.lang import System

from jas import PolyRing, QQ, DD, AN, BigDecimal
from jas import terminate, startLog

# roots simplification

r = PolyRing(QQ(), "I", PolyRing.lex)
print "Ring: " + str(r)
#print;

#automatic: [one,I] = r.gens();
print "one   = ", one
print "I     = ", I

eps = QQ(1, 10)**(BigDecimal.DEFAULT_PRECISION)
#-3
#eps = QQ(1,10) ** 7;
#eps = nil;
print "eps   = " + str(eps)

ip = (I**2 + 1)
# I
iq = AN(ip, 0, True)
Ejemplo n.º 22
0
#
# jython examples for jas.
# $Id$
#

import sys

from java.lang import System

from jas import Ring, PolyRing, QQ, DD
from jas import terminate, startLog

# polynomial examples: real roots over Q

r = PolyRing(QQ(), "I,x,y,z", PolyRing.lex)
print "Ring: " + str(r)
print

#automatic: [one,I,x,y,z] = r.gens();

f1 = z - x - y * I
f2 = I**2 + 1

#f3 = z**3 - 2;
f3 = z**3 - 2 * I

print "f1 = ", f1
print "f2 = ", f2
print "f3 = ", f3
print
# jython examples for jas.
# $Id$
#

import sys;

from jas import PolyRing, QQ
from jas import startLog, terminate


# Raksanyi & Walter example
# integral/rational function coefficients

#r = Ring( "RatFunc(a1, a2, a3, a4) (x1, x2, x3, x4) L" );
#r = Ring( "IntFunc(a1, a2, a3, a4) (x1, x2, x3, x4) L" );
r = PolyRing( PolyRing(QQ(),"a1, a2, a3, a4",PolyRing.lex), 
              "x1, x2, x3, x4", PolyRing.lex);
print "Ring: " + str(r);
print;

ps = """
(
 ( x4 - { a4 - a2 } ),
 ( x1 + x2 + x3 + x4 - { a1 + a3 + a4 } ),
 ( x1 x3 + x1 x4 + x2 x3 + x3 x4 - { a1 a4 + a1 a3 + a3 a4 } ),
 ( x1 x3 x4 - { a1 a3 a4 } )
) 
""";

f = r.paramideal( ps );
print "ParamIdeal: " + str(f);
print;
Ejemplo n.º 24
0
#
# jython examples for jas.
# $Id$
#

from java.lang import System

from jas import PolyRing, QQ, ZM
from jas import terminate, startLog

import operator

# polynomial examples: squarefree: characteristic 0

r = PolyRing(QQ(), "x, y, z", PolyRing.lex)
print "Ring: " + str(r)
print

#automatic: [one,x,y,z] = r.gens();

a = r.random(k=2, l=3)
b = r.random(k=2, l=3)
c = r.random(k=1, l=3)

if a.isZERO():
    a = x
if b.isZERO():
    b = y
if c.isZERO():
    c = z
Ejemplo n.º 25
0
#
# jython examples for jas.
# $Id$
#

import sys

from jas import QQ, PolyRing
from jas import startLog
from jas import terminate

# ideal elimination example

#r = Ring( "Rat(x,y,z) G" );
r = PolyRing(QQ(), "(x,y,z)", PolyRing.grad)
print "Ring: " + str(r)
print

ps1 = """
(
 ( x^2 - 2 ),
 ( y^2 - 3 ),
 ( z^3 - x * y )
)
"""

ff = [x**2 - 2, y**2 - 3, z**3 - x * y]

#F1 = r.ideal( ps1 );
F1 = r.ideal("", ff)
print "Ideal: " + str(F1)
Ejemplo n.º 26
0
import sys

from jas import Ring, PolyRing, QQ, ZZ, Order, Scripting
from jas import startLog, terminate

# examples: from Mathematica

# check("GroebnerBasis({x^2 + y^2 + z^2 - 1, x - z + 2, z^2 - x*y},
#                      {x, y, z})",
#       "{12-28*z+27*z^2-12*z^3+3*z^4, -6+4*y+11*z-6*z^2+3*z^3, 2+x-z}");

Scripting.setCAS(Scripting.CAS.Math)
#Scripting.setCAS(Scripting.CAS.Sage);
#Scripting.setCAS(Scripting.CAS.Singular);

r = PolyRing(ZZ(), "x,y,z", Order.Lexicographic)
print "Ring: " + str(r)
print

ff = [x**2 + y**2 + z**2 - 1, x - z + 2, z**2 - x * y]

F = r.ideal("", ff)
print "F = " + str(F)
print

#startLog();

G = F.GB()
print "G = " + str(G)
print
print "Ma: " + str(
Ejemplo n.º 27
0
#
# jython examples for jas.
# $Id$
#

from java.lang import System

from jas import SolvableRing, SolvPolyRing, PolyRing
from jas import QQ, startLog, SRC, SRF

# Ore extension solvable polynomial example, Gomez-Torrecillas, 2003

pcz = PolyRing(QQ(), "x,y,z")
#is automatic: [one,x,y,z] = pcz.gens();

zrelations = [z, y, y * z + x]

print "zrelations: = " + str([str(f) for f in zrelations])
print

pz = SolvPolyRing(QQ(), "x,y,z", PolyRing.lex, zrelations)
print "SolvPolyRing: " + str(pz)
print

pzq = SRF(pz)
print "SolvableQuotientRing: " + str(pzq.ring.toScript())
# + ", assoz: " + str(pzq.ring.isAssociative());
#print "gens =" + str([ str(f) for f in pzq.ring.generators() ]);
print

pct = PolyRing(pzq, "t")
#
# jython examples for jas.
# $Id$
#

import sys

from jas import PolyRing, QQ, RF
from jas import startLog
from jas import terminate

# Montes JSC 2002, 33, 183-208, example 5.1
# integral function coefficients

r = PolyRing(PolyRing(QQ(), "a, b", PolyRing.lex), "u,z,y,x", PolyRing.lex)
print "Ring: " + str(r)
print

#automatic: [one,a,b,u,z,y,x] = r.gens();
print "gens: ", [str(f) for f in r.gens()]
print

f1 = a * x + 2 * y + 3 * z + u - 6
f2 = x + 3 * y - z + 2 * u - b
f3 = 3 * x - a * y + z - 2
f4 = 5 * x + 4 * y + 3 * z + 3 * u - 9

F = [f1, f2, f3, f4]

print "F: ", [str(f) for f in F]
print
# jython examples for jas.
# $Id$
#

import sys;
from java.lang import System
from java.lang import Integer

from jas import Ring, PolyRing
from jas import terminate
from jas import startLog
from jas import QQ, DD

# polynomial examples: complex roots over Q for zero dimensional ideal `cyclic5'

r = PolyRing(QQ(),"a,b,c,d,e",PolyRing.lex);
print "Ring: " + str(r);
print;

#is automatic: [one,a,b,c,d,e] = r.gens();

f1 = a + b + c + d + e;
f2 = a*b + b*c + c*d + d*e + e*a;
f3 = a*b*c + b*c*d + c*d*e + d*e*a + e*a*b;
f4 = a*b*c*d + b*c*d*e + c*d*e*a + d*e*a*b + e*a*b*c;
f5 = a*b*c*d*e - 1;

print "f1 = ", f1;
print "f2 = ", f2;
print "f3 = ", f3;
print "f4 = ", f4;
Ejemplo n.º 30
0
#
# jython examples for jas.
# $Id$
#

import sys

from jas import Ring, PolyRing, RF, ZZ
from jas import terminate

# Raksanyi & Walter example
# rational function coefficients

#r = Ring( "RatFunc(a1, a2, a3, a4) (x1, x2, x3, x4) G" );
r = PolyRing(RF(PolyRing(ZZ(), "a1, a2, a3, a4", PolyRing.lex)),
             "x1, x2, x3, x4", PolyRing.grad)
print "Ring: " + str(r)
print

ps = """
(
 ( x4 - { a4 - a2 } ),
 ( x1 + x2 + x3 + x4 - { a1 + a3 + a4 } ),
 ( x1 x3 + x1 x4 + x2 x3 + x3 x4 - { a1 a4 + a1 a3 + a3 a4 } ),
 ( x1 x3 x4 - { a1 a3 a4 } )
) 
"""

f = r.ideal(ps)
print "Ideal: " + str(f)
print