code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
#
# jython examples for jas.
# $Id$
#
from jas import Ring
from jas import Ideal
# ? example
r = Ring( "Rat(x,y,z) L" );
print "Ring: " + str(r);
print;
ps = """
(
( z^3 - y ),
( y z - x ),
( y^3 - x^2 z ),
( x z^2 - y^2 )
)
""";
f = Ideal( r, ps );
print "Ideal: " + str(f);
print;
from edu.jas.gbmod import SyzygyAbstract;
from edu.jas.poly import ModuleList;
from edu.jas.gbmod import ModGroebnerBaseAbstract;
R = SyzygyAbstract().resolution( f.pset );
for i in range(0,R.size()):
print "\n %s. resolution" % (i+1);
print "\n ", R[i];
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate
# Nabashima, ISSAC 2007, example F5
# integral function coefficients
r = Ring( "IntFunc(b, a, c) (x,y) L" );
print "Ring: " + str(r);
print;
ps = """
(
( { a } x^2 y + { b } x + y^2 ),
( { a } x^2 y + { b } x y ),
( y^2 + { b } x^2 y + { c } x y )
)
""";
#startLog();
f = r.paramideal( ps );
print "ParamIdeal: " + str(f);
print;
gs = f.CGBsystem();
gs = f.CGBsystem();
gs = f.CGBsystem();
gs = f.CGBsystem();
print "CGBsystem: " + str(gs);
print;
#sys.exit();
bg = gs.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
#sys.exit();
gs = f.CGB();
print "CGB: " + str(gs);
print;
bg = gs.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#------------------------------------------
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate
# Nabashima, ISSAC 2007, example Ex-Fig-2
# integral function coefficients
r = Ring( "IntFunc(a, b, c) (x) L" );
print "Ring: " + str(r);
print;
ps = """
(
( { a } x^3 ),
( { b } x^2 ),
( { c } x )
)
""";
#startLog();
f = r.paramideal( ps );
print "ParamIdeal: " + str(f);
print;
gs = f.CGBsystem();
print "CGBsystem: " + str(gs);
print;
bg = gs.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
#sys.exit();
gs = f.CGB();
print "CGB: " + str(gs);
print;
bg = gs.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#------------------------------------------
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate
# ideal intersection example
r = Ring( "Rat(x,y,z) L" );
print "Ring: " + str(r);
print;
ps1 = """
(
( x - 1 ),
( y - 1 ),
( z - 1 )
)
""";
ps2 = """
(
( x - 2 ),
( y - 3 ),
( z - 3 )
)
""";
F1 = r.ideal( ps1 );
#print "Ideal: " + str(F1);
#print;
F2 = r.ideal( ps2 );
#print "Ideal: " + str(F2);
#print;
#startLog();
rg1 = F1.GB();
print "rg1 = ", rg1;
print;
rg2 = F2.GB();
print "rg2 = ", rg2;
print;
#startLog();
ig = F1.intersect(F2);
print "rg1 intersect rg2 = ", ig;
print;
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import SolvableRing, SolvPolyRing, PolyRing, SolvableIdeal
from jas import QQ, Quat
# WA_32 solvable polynomial example
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();
f1 = e1 * e3**3 + e2**10 - a;
f2 = e1**3 * e2**2 + e3;
f3 = e3**3 + e3**2 - b;
f4 = ( e3**2 * e2**3 + e1 )**3;
#print "f1 = ", f1;
#print "f2 = ", f2;
#print "f3 = ", f3;
#print "f4 = ", f4;
F = [ f1, f2, f3 ];
print "F =", [ str(f) for f in F ];
print
I = rp.ideal( list=F );
print "SolvableIdeal: " + str(I);
print;
rgl = I.leftGB();
print "seq left GB:" + str(rgl);
print "isLeftGB: " + str(rgl.isLeftGB());
print;
rgt = I.twosidedGB();
print "seq twosided GB:" + str(rgt);
print "isTwosidedGB: " + str(rgt.isTwosidedGB());
print;
rgr = I.rightGB();
print "seq right GB:" + str(rgr);
print "isRightGB: " + str(rgr.isRightGB());
print;
#exit(0);
rs = """
# solvable polynomials, Weyl algebra A_3,2:
Rat(a,b,e1,e2,e3) L
#Quat(a,b,e1,e2,e3) G|3|
RelationTable
(
( e3 ), ( e1 ), ( e1 e3 - e1 ),
( e3 ), ( e2 ), ( e2 e3 - e2 )
)
""";
r = SolvableRing( rs );
print "SolvableRing: " + str(r);
print;
print "gens =", [ str(f) for f in r.gens() ];
#[one,a,b,e1,e2,e3] = r.gens();
#[one,I,J,K,a,b,e1,e2,e3] = r.gens();
fs1 = e1 * e3**3 + e2**10 - a;
fs2 = e1**3 * e2**2 + e3;
fs3 = e3**3 + e3**2 - b;
fs4 = ( e3**2 * e2**3 + e1 )**3;
#print "fs1 = ", fs1;
#print "fs2 = ", fs2;
#print "fs3 = ", fs3;
print "fs4 = ", fs4;
Fs = [ fs1, fs2, fs3 ];
print "Fs =", [ str(f) for f in Fs ];
print
Is = r.ideal( list=Fs );
print "SolvableIdeal: " + str(Is);
print;
rgsl = I.leftGB();
print "seq left GB:" + str(rgsl);
print "isLeftGB: " + str(rgsl.isLeftGB());
print;
rgst = I.twosidedGB();
print "seq twosided GB:" + str(rgst);
print "isTwosidedGB: " + str(rgst.isTwosidedGB());
print;
rgsr = I.rightGB();
print "seq right GB:" + str(rgsr);
print "isRightGB: " + str(rgsr.isRightGB());
print;
print "rgl == rgsl: " + str(rgl == rgsl);
print "rgr == rgsr: " + str(rgr == rgsr);
print "rgt == rgst: " + str(rgt == rgst);
| Python |
#
# jython examples for jas.
# $Id$
#
## \begin{PossoExample}
## \Name{Hawes2}
## \Parameters{a;b;c}
## \Variables{x;y[2];z[2]}
## \begin{Equations}
## x+2y_1z_1+3ay_1^2+5y_1^4+2cy_1 \&
## x+2y_2z_2+3ay_2^2+5y_2^4+2cy_2 \&
## 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
from jas import Ideal
from jas import startLog
from jas import terminate
#startLog();
# Hawes & Gibson example 2
# rational function coefficients
r = Ring( "IntFunc(a, c, b) (y2, y1, z1, z2, x) G" );
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);
print;
rg = g.GB();
rg = g.GB();
rg = g.GB();
rg = g.GB();
print "GB:", rg;
print;
bg = rg.isGB();
print "isGB:", bg;
print;
p7 = ( x + 1 ) / ( x**2 - x + 1 );
print "p7 = ", p7;
p8 = ( x + 1 ) % ( x**2 - x + 1 );
print "p8 = ", p8;
startLog();
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate
from edu.jas.arith import BigRational
# Legendre polynomial example
# P(0) = 1
# P(1) = x
# P(n) = 1/n [ (2n-1) * x * P(n-1) - (n-1) * P(n-2) ]
r = Ring( "Q(x) L" );
#r = Ring( "C(x) L" );
print "Ring: " + str(r);
print;
# sage like: with generators for the polynomial ring
[one,x] = r.gens();
N = 10;
P = [one,x];
for n in range(2,N):
p = (2*n-1) * x * P[n-1] - (n-1) * P[n-2];
r = (1,n); # no rational numbers in python
#r = [(1,n)]; # no complex rational numbers in python
#r = ((1,n),(0,1)); # no complex rational numbers in python
p = r * p;
P.append( p );
for n in range(0,N):
print "P[%s] = %s" % (n,P[n]);
print;
#sys.exit();
| Python |
#
# jython for jas example 3 integer programming.
# $Id$
#
# CLO2, p374,c
# 3 A + 2 B + C + D = 45
# A + 2 B + 3 C + E = 21
# 2 A + B + C + F = 18
#
# max: 3 A + 4 B + 2 C
#
import sys;
from jas import Ring
from jas import Ideal
#r = Ring( "Rat(w1,w2,w3,w4,w5,w6,z1,z2,z3) W( (0,0,0,0,0,0,1,1,1),(-3,-4,-2,0,0,0,0,0,0) )" );
#r = Ring( "Rat(w1,w2,w3,w4,w5,w6,z1,z2,z3) W( (0,0,0,0,0,0,1,1,1),( 6, 5, 5,1,1,1,0,0,0)*2 )" );
#r = Ring( "Rat(w1,w2,w3,w4,w5,w6,z1,z2,z3) W( (0,0,0,0,0,0,1,1,1),( 3, 1, 3,1,1,1,0,0,0) )" );
r = Ring( "Rat(w1,w2,w3,w4,w5,w6,z1,z2,z3) W( (0,0,0,0,0,0,1,1,1),( 9, 6, 8,2,2,2,0,0,0) )" );
print "Ring: " + str(r);
print;
ps = """
(
( z1^3 z2 z3^2 - w1 ),
( z1^2 z2^2 z3 - w2 ),
( z1 z2^3 z3 - w3 ),
( z1 - w4 ),
( z2 - w5 ),
( z3 - w6 )
)
""";
f = Ideal( r, ps );
print "Ideal: " + str(f);
print;
rg = f.GB();
print "seq Output:", rg;
print;
pf = """
(
( z1^45 z2^21 z3^18 )
)
""";
fp = Ideal( r, pf );
print "Ideal: " + str(fp);
print;
nf = fp.NF(rg);
print "NFs: " + str(nf);
print;
#rg = f.parGB(2);
#print "par Output:", rg;
#print;
#f.distClient(); # starts in background
#rg = f.distGB(2);
#print "dist Output:", rg;
#print;
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import SolvableModule
from jas import SolvableSubModule
# Quantum plane example
rsan = """
AN[ (i) (i^2 + 1) ] (Y,X,x,y) G
RelationTable
(
( y ), ( x ), ( {i} x y )
( X ), ( Y ), ( {i} Y X )
)
""";
rsc = """
C(Y,X,x,y) G |2|
RelationTable
(
( y ), ( x ), ( 0i1 x y )
( X ), ( Y ), ( 0i1 Y X )
)
""";
r = SolvableModule( rsc );
#r = SolvableModule( rsan );
print "SolvableModule: " + str(r);
print;
ps = """
(
( ( x + 1 ), ( y ) ),
( ( x y ), ( 0 ) ),
( ( x - X ), ( x - X ) ),
( ( y - Y ), ( y - Y ) )
)
""";
f = SolvableSubModule( r, ps );
print "SolvableSubModule: " + str(f);
print;
flg = f.leftGB();
print "seq left GB:", flg;
print;
ftg = f.twosidedGB();
print "seq twosided GB:", ftg;
print;
# split term order not supported for rightGB
| Python |
#
# 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 QQ, DD, EF
from jas import terminate
from jas import startLog
# polynomial examples: real root tower over Q
r = EF(QQ()).realExtend("q","q^3 - 3", "[1,2]").realExtend("w", "w^2 - q", "[1,2]").realExtend("s", "s^5 - 2", "[1,2]").polynomial("x").build();
print "Ring: " + str(r);
print;
[one,q,w,s,x] = r.gens();
print "one = " + str(one);
print "q = " + str(q);
print "w = " + str(w);
print "s = " + str(s);
print "x = " + str(x);
print;
f = x**2 - w * s;
print "f = ", f;
print;
startLog();
t = System.currentTimeMillis();
R = r.realRoots(f);
t = System.currentTimeMillis() - t;
#print "R = ", R;
print "R = ", [ a.elem.ring.getRoot() for a in R ];
print "real roots time =", t, "milliseconds";
#sys.exit();
eps = QQ(1,10) ** (DD().elem.DEFAULT_PRECISION);
print "eps = ", eps;
t = System.currentTimeMillis();
R = r.realRoots(f,eps);
t = System.currentTimeMillis() - t;
#print "R = ", [ str(r) for r in R ];
print "R = ", [ a.elem.decimalMagnitude() for a in R ];
print "real roots time =", t, "milliseconds";
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import QQ
from jas import DD
from jas import Ring
from jas import SeriesRing
from jas import startLog
from edu.jas.ps import Coefficients
from edu.jas.ps import UnivPowerSeriesMap
# example for power series
#
#
#
# rational number examples
#
psr = SeriesRing("Q(y)");
print "psr:", psr;
print;
one = psr.one();
print "one:", one;
print;
zero = psr.zero();
print "zero:", zero;
print;
r1 = psr.random(4);
print "r1:", r1;
print;
print "r1:", r1;
print;
print "r1-r1:", r1-r1;
print;
r2 = psr.random(4);
print "r2:", r2;
print;
print "r2:", r2;
print;
print "r2-r2:", r2-r2;
print;
#sys.exit();
r3 = r1 + r2;
print "r3:", r3;
print;
r4 = r1 * r2 + one;
print "r4:", r4;
print;
e = psr.exp();
print "e:", e;
print;
r5 = r1 * r2 + e;
print "r5:", r5;
print;
#print "psr.gens: ", [ str(i) for i in psr.gens() ];
[one,y] = psr.gens();
print "y:", y;
print;
r6 = one - y;
print "r6:", r6;
print;
r7 = one / r6;
print "r7:", r7;
print;
s = psr.sin();
print "s:", s;
print;
r8 = psr.gcd(y,s);
print "r8:", r8;
print;
s1 = s.evaluate( QQ(0) );
print "s1:", s1;
print;
c = psr.cos();
print "c:", c;
print;
c1 = c.evaluate( QQ(0) );
print "c1:", c1;
print;
s2c2 = s*s+c*c; # sin^2 + cos^2 = 1
print "s2c2:", s2c2;
print;
#
# floating point examples
#
dr = SeriesRing(cofac=DD());
print "dr:", dr;
print;
de = dr.exp();
print "de:", de;
print;
d0 = de.evaluate( DD(0) );
print "d0:", d0;
print;
d1 = de.evaluate( DD(0.5) );
print "d1:", d1;
print;
d01 = de.evaluate( DD(0.000000000000000001) );
print "d01:", d01;
print;
def f(a):
return a*a;
ps = psr.create(f);
print "ps:", ps;
print;
def g(a):
return a+a;
ps1 = psr.create(g);
print "ps1:", ps1;
print;
ps2 = ps * ps1;
print "ps2:", ps2;
print;
def h(a):
return psr.ring.coFac.fromInteger( 2*a );
ps3 = psr.create(jfunc=h);
print "ps3:", ps3;
print;
ps4 = ps3 * ps1;
print "ps4:", ps4;
print;
# does not work, since get() is not known
def k(a):
if a > 0:
return get(a-1).multiply( psr.ring.coFac.fromInteger( 2*a ) );
else:
return psr.ring.coFac.fromInteger( 2*a );
#no#ps5 = psr.create(jfunc=k);
#no#print "ps5:", ps5;
#no#print;
class coeff( Coefficients ):
def __init__(self,cofac):
self.coFac = cofac;
def generate(self,i):
if i == 0:
return self.coFac.getZERO();
else:
if i == 1:
return self.coFac.getONE();
else:
c = self.get( i-2 ).negate();
return c.divide( self.coFac.fromInteger(i) ).divide( self.coFac.fromInteger(i-1) );
ps6 = psr.create( clazz=coeff(psr.ring.coFac) );
print "ps6:", ps6;
print;
ps7 = ps6 - s;
print "ps7:", ps7;
print;
class cosmap( UnivPowerSeriesMap ):
def __init__(self,cofac):
self.coFac = cofac;
def map(self,ps):
return ps.negate().integrate( self.coFac.getZERO() ).integrate( self.coFac.getONE() );
ps8 = psr.fixPoint( cosmap( psr.ring.coFac ) );
print "ps8:", ps8;
print;
ps9 = ps8 - c;
print "ps9:", ps9;
print;
# conversion from polynomials
pr = Ring("Q(y) L");
print "pr:", pr;
print;
[one,yp] = pr.gens();
p1 = one;
p2 = one - yp;
ps1 = psr.fromPoly(p1);
ps2 = psr.fromPoly(p2);
# rational function as power series:
ps3 = ps1 / ps2;
print "p1:", p1;
print "p2:", p2;
print "ps1:", ps1;
print "ps2:", ps2;
print "ps3:", ps3;
print;
p1 = one * 2 + yp**3 - yp**5;
p2 = one - yp**2 + yp**4;
ps1 = psr.fromPoly(p1);
ps2 = psr.fromPoly(p2);
# rational function as power series:
ps3 = ps1 / ps2;
ps4 = ps3.integrate( QQ(1) );
ps5 = ps3.differentiate();
print "p1:", p1;
print "p2:", p2;
print "ps1:", ps1;
print "ps2:", ps2;
print "ps3:", ps3;
print "ps4:", ps4;
print "ps5:", ps5;
print;
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring, PolyRing, ParamIdeal, QQ
from jas import startLog, terminate
# Raksanyi & Walter example
# integral/rational function coefficients
r = PolyRing(PolyRing(QQ(),"a1,a2,a3,a4",PolyRing.grad),"x1,x2,x3,x4",PolyRing.lex);
#print "r = " + str(r);
[one,a1,a2,a3,a4,x1,x2,x3,x4] = r.gens();
pl = [ ( 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 = ParamIdeal(r,list=pl);
print "ParamIdeal: " + str(f);
gs = f.CGBsystem();
#print "CGBsystem: " + str(gs);
#print;
print f.CGB();
print gs.isCGBsystem();
#rs = gs.regularRepresentation();
#print "regular representation: " + str(rs);
rs = gs.regularRepresentationBC();
print "boolean closed regular representation: " + str(rs);
print rs.isRegularGB();
rsg = rs.regularGB();
print "regular GB: " + str(rsg);
print rsg.isRegularGB();
#ss = rsg.stringSlice();
#print "regular string slice: " + str(ss);
startLog();
terminate();
sys.exit();
print "one = " + str(one);
print "a1 = " + str(a1);
print "a2 = " + str(a2);
print "a3 = " + str(a3);
print "a4 = " + str(a4);
print "x1 = " + str(x1);
print "x2 = " + str(x2);
print "x3 = " + str(x3);
print "x4 = " + str(x4);
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import PolyRing, QQ, ZM
from jas import terminate
from jas import startLog
# polynomial examples: squarefree: characteristic 0
r = PolyRing(QQ(),"x, y, z",PolyRing.lex)
print "Ring: " + str(r);
print;
[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;
f = a**2 * b**3 * c;
print "a = ", a;
print "b = ", b;
print "c = ", c;
print "f = ", f;
print;
t = System.currentTimeMillis();
F = r.squarefreeFactors(f);
t = System.currentTimeMillis() - t;
print "factors:";
for g in F.keys():
i = F[g];
print "g = %s**%s" % (g,i);
print
print "factor time =", t, "milliseconds";
#startLog();
terminate();
| Python |
#
# jruby examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import SolvableRing, SolvPolyRing, PolyRing, RingElem
from jas import QQ, startLog, SLR
# 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];
fl = [ z**2 + y, x];
ff = pz.ideal("",fl);
print "ideal ff: " + str(ff);
print;
ff = ff.twosidedGB();
print "ideal ff: " + str(ff);
print;
f0 = SLR(ff,z + x + y + 1);
print "f0 = " + str(f0);
#f1 = SLR(ff, z-y+1 );
#f1 = SLR(ff, y*z+1 );
f1 = SLR(ff, y*z+x+1 );
print "f1 = " + str(f1);
f2 = f1*f0;
print "f2 = f1*f0: " + str(f2);
print;
fi = 1/f1;
print "fi = " + str(fi);
fi1 = fi*f1;
f1i = f1*fi;
print "fi*f1 = " + str(fi1);
print "f1*fi = " + str(f1i);
print;
f2i = f2*fi;
fi2 = fi*f2;
print "f2*fi = " + str(f2i);
print "fi*f2 = " + str(fi2);
print "f2*fi == f0: " + str(f2i == f0);
print "fi*f2 == f0: " + str(fi2 == f0);
print;
#exit(0);
pzc = f0.ring;
print "SolvableLocalResidueRing: " + str(pzc.toScript()) + ", assoz: " + str(pzc.isAssociative());
print "gens =" + str([ str(f) for f in pzc.generators() ]);
print;
pct = PolyRing(pzc,"t,u");
#is automatic: [one,y,z,t] = p.gens(); # no x
#exit(0);
trelations = [t, y, y * t + y,
t, z, z * t - z
];
print "trelations: = " + str([ str(f) for f in trelations ]);
print;
#startLog();
pt = SolvPolyRing(pzc, "t,u", PolyRing.lex, trelations);
print "SolvPolyRing: " + str(pt);
print "sp.gens =" + str([ str(f) for f in pt.gens() ]);
#is automatic: one,y,z,t = rp.gens(); # no x
print;
#exit(0);
a = t**2 + y;
b = t + y + 1;
c = z*t**2 - y * t - z;
print "a = " + str(a);
print "b = " + str(b);
print "c = " + str(c);
#c = c.monic();
#print "c = " + str(c);
print
ff = [ a*c, b*c, (a+b)*c ];
print "ff = " + str([ str(f) for f in ff ]);
print
ii = pt.ideal( "", ff );
print "SolvableIdeal: " + str(ii);
print;
#exit(0);
#startLog();
rgl = ii.leftGB();
print "seq left GB: " + str(rgl);
print "isLeftGB: " + str(rgl.isLeftGB());
print;
#p = RingElem(rgl.list.get(0));
p = RingElem(rgl.list[0]);
print "p = " + str(p);
print "c = " + str(c);
print "c-p = " + str(c-p);
d = c.monic();
print "d = " + str(d);
print "d-p = " + str(d-p);
print;
#exit(0);
#no: fl = [ p, p*x ]; # x non existent
#no: fl = [ p, p*z ];
#bad: fl = [ p, p*t, p*p ];
#bad: fl = [ p, p*p ];
#fl = [ p, p*t ];
#fl = [ p ];
#fl = [ t*p, (t*t+1)*p, (t*t-t)*p ];
fl = [ t*c, (t*t+1)*c, (t*t-t)*c ];
print "fl = " + str([ str(f) for f in fl ]);
print
iil = pt.ideal( "", fl );
print "SolvableIdeal_local: " + str(iil);
print;
rgll = iil.leftGB();
print "seq left GB: " + str(rgll);
print "isLeftGB: " + str(rgll.isLeftGB());
print;
#q = RingElem(rgll.list.get(0));
q = RingElem(rgll.list[0]);
print "p = " + str(p);
print "q = " + str(q);
print "q-p = " + str(q-p);
print "c = " + str(c);
print "c-q = " + str(c-q);
print "d = " + str(d);
print "d-q = " + str(d-q);
print;
fn = z**2 - y;
print "fn = " + str(fn);
#fn = x; # undefined/wrong variable, since == 0
fn = fn + 2*y;
print "fn = " + str(fn) + ", " + str(fn.isZERO());
print;
| Python |
#
# jython examples for jas.
# $Id$
#
#from java.lang import System
from jas import WordRing, WordPolyRing, WordIdeal, PolyRing, SolvPolyRing
from jas import terminate, startLog
from jas import QQ, ZZ, GF, ZM
# non-commutative polynomial examples: solvable polynomials example
r = WordPolyRing(QQ(),"a,b,e1,e2,e3");
print "WordPolyRing: " + str(r);
print;
[one,a,b,e1,e2,e3] = r.gens();
print "one = " + str(one);
print "a = " + str(a);
print "b = " + str(b);
print "e1 = " + str(e1);
print "e2 = " + str(e2);
print "e3 = " + str(e3);
print;
r1 = e3 * e1 - (e1 * e3 - e1);
r2 = e3 * e2 - (e2 * e3 - e2);
r3 = e1 * a - a * e1;
r4 = e1 * b - b * e1;
r5 = e2 * a - a * e2;
r6 = e2 * b - b * e2;
r7 = e3 * a - a * e3;
r8 = e3 * b - b * e3;
f1 = e1 * e3**3 + e2**10 - a;
f2 = e1**3 * e2**2 + e3;
f3 = e3**3 + e3**2 - b;
print "r1 = " + str(r1);
print "r2 = " + str(r2);
print "r3 = " + str(r3);
print "r4 = " + str(r4);
print "r5 = " + str(r5);
print "r6 = " + str(r6);
print "r7 = " + str(r7);
print "r8 = " + str(r8);
print "f1 = " + str(f1);
print "f2 = " + str(f2);
print "f3 = " + str(f3);
print;
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();
f1 = e1 * e3**3 + e2**10 - a;
f2 = e1**3 * e2**2 + e3;
f3 = e3**3 + e3**2 - b;
F = [ f1, f2, f3 ];
print "F =", [ str(f) for f in F ];
print
I = rp.ideal( list=F );
print "SolvableIdeal: " + str(I);
print;
rgt = I.twosidedGB();
print "seq twosided GB:" + str(rgt);
print "isTwosidedGB: " + str(rgt.isTwosidedGB());
print
print "rgt: ", [ str(f) for f in rgt.list ];
print;
| Python |
#
# jython examples for jas.
from jas import SolvableRing
# U(sl_2_e) example
rs = """
# solvable polynomials, U(sl_2_e):
Rat(e,h) G
RelationTable
(
( h ), ( e ), ( e h + 2 e )
)
""";
r = SolvableRing( rs );
print "SolvableRing: " + str(r);
print;
ps = """
(
( e^2 + h^3 )
)
""";
f = r.ideal( ps );
print "SolvableIdeal: " + str(f);
print;
rg = f.leftGB();
print "seq left Output:", rg;
print;
rg = f.twosidedGB();
print "seq twosided Output:", rg;
print;
| Python |
#
# jython examples for jas.
# $Id$
#
## \begin{PossoExample}
## \Name{Hawes2}
## \Parameters{a;b;c}
## \Variables{x;y[2];z[2]}
## \begin{Equations}
## x+2y_1z_1+3ay_1^2+5y_1^4+2cy_1 \&
## x+2y_2z_2+3ay_2^2+5y_2^4+2cy_2 \&
## 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, QQ
from jas import Ideal
from jas import startLog
from jas import terminate
from edu.jas.arith import ModIntegerRing
#startLog();
# 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;
ps = """
(
( x + 2 y1 z1 + { 3 a } y1^2 + 5 y1^4 + { 2 c } y1 ),
( x + 2 y2 z2 + { 3 a } y2^2 + 5 y2^4 + { 2 c } y2 ),
( 2 z2 + { 6 a } y2 + 20 y2^3 + { 2 c } ),
( 3 z1^2 + y1^2 + { b } ),
( 3 z2^2 + y2^2 + { b } )
)
""";
f = r.paramideal( ps );
print "Ideal: " + str(f);
print;
fi = f.toIntegralCoeff();
print "Ideal: " + str(fi);
print;
#mf = ModIntegerRing( str(2**60-93), True );
mf = ModIntegerRing( str(19), True );
fm = fi.toModularCoeff(mf);
print "Ideal: " + str(fm);
print;
fmq = fm.toQuotientCoeff();
print "Ideal: " + str(fmq);
print;
rg = fmq.GB();
print "GB:", rg;
print;
bg = rg.isGB();
print "isGB:", bg;
print;
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from java.lang import System
from java.lang import Integer
from jas import Ring
from jas import PolyRing
from jas import Ideal
from jas import terminate
from jas import startLog
from jas import QQ, DD, CR
# 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;
#f = f**3;
print "f = ", f;
print;
#startLog();
t = System.currentTimeMillis();
R = r.factors(f);
t = System.currentTimeMillis() - t;
#print "R = ", R;
#print "complex factor time =", t, "milliseconds";
g = one;
for h, i in R.iteritems():
print "h**i = "+ str(h) + "**" + str(i);
h = h**i;
g = g*h;
#print "g = ", g;
if cmp(f,g) == 0:
print "complex factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
print "complex factor time =", t, "milliseconds,", "isFactors(f,g): ", cmp(f,g);
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
#from java.lang import System
from jas import WordRing, WordPolyRing, WordIdeal, PolyRing, SolvPolyRing
from jas import terminate, startLog
from jas import QQ, ZZ, GF, ZM
# non-commutative polynomial examples: solvable polynomials example
#r = WordPolyRing(QQ(),"a,b,e1,e2,e3");
r = WordPolyRing(QQ(),"a,b,e,f,g");
print "WordPolyRing: " + str(r);
print;
[one,a,b,e,f,g] = r.gens();
print "one = " + str(one);
print "a = " + str(a);
print "b = " + str(b);
print "e = " + str(e);
print "f = " + str(f);
print "g = " + str(g);
print;
r1 = g * e - (e*g - e);
r2 = g * f - (f*g - f);
r3 = e * a - a * e;
r4 = e * b - b * e;
r5 = f * a - a * f;
r6 = f * b - b * f;
r7 = g * a - a * g;
r8 = g * b - b * g;
f1 = e * g**3 + f**10 - a;
f2 = e**3 * f**2 + g;
f3 = g**3 + g**2 - b;
print "r1 = " + str(r1);
print "r2 = " + str(r2);
print "r3 = " + str(r3);
print "r4 = " + str(r4);
print "r5 = " + str(r5);
print "r6 = " + str(r6);
print "r7 = " + str(r7);
print "r8 = " + str(r8);
print "f1 = " + str(f1);
print "f2 = " + str(f2);
print "f3 = " + str(f3);
print;
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();
f1 = e1 * e3**3 + e2**10 - a;
f2 = e1**3 * e2**2 + e3;
f3 = e3**3 + e3**2 - b;
F = [ f1, f2, f3 ];
print "F =", [ str(f) for f in F ];
print
I = rp.ideal( list=F );
print "SolvableIdeal: " + str(I);
print;
rgt = I.twosidedGB();
print "seq twosided GB:" + str(rgt);
print "isTwosidedGB: " + str(rgt.isTwosidedGB());
print
print "rgt: ", [ str(f) for f in rgt.list ];
print;
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import Ring
from jas import Ideal
# ? example
r = Ring( "Rat(x,y,z) L" );
print "Ring: " + str(r);
print;
ps = """
(
( z^3 - y ),
( y z - x ),
( y^3 - x^2 z ),
( x z^2 - y^2 )
)
""";
f = Ideal( r, ps );
print "Ideal: " + str(f);
print;
rg = f.GB();
print "seq Output:", rg;
print;
from edu.jas.gbmod import SyzygyAbstract;
from edu.jas.poly import ModuleList;
from edu.jas.gbmod import ModGroebnerBaseAbstract;
s = SyzygyAbstract().zeroRelations( rg.list );
sl = ModuleList(rg.pset.ring,s);
print "syzygy:", sl;
print;
z = SyzygyAbstract().isZeroRelation( s, rg.list );
print "is zero s ?",
if z:
print "true"
else:
print "false"
print;
zg = sl;
for i in range(1,len(r.ring.vars)+1):
print "\n %s. resolution" % i;
sl = zg;
mg = ModGroebnerBaseAbstract().GB(sl);
print "Mod GB: ", mg;
print;
zg = SyzygyAbstract().zeroRelations(mg);
print "syzygies of Mod GB: ", zg;
print;
if ModGroebnerBaseAbstract().isGB( mg ):
print "is GB";
else:
print "is not GB";
if SyzygyAbstract().isZeroRelation(zg,mg):
print "is Syzygy";
else:
print "is not Syzygy";
if not zg.list:
break;
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import Ring
from jas import Ideal
from jas import terminate
from jas import startLog
# polynomial examples: factorization
#r = Ring( "Mod 1152921504606846883 (x,y,z) L" );
#r = Ring( "Rat(x,y,z) L" );
#r = Ring( "C(x,y,z) L" );
r = Ring( "Z(x,y,z) L" );
#r = Ring( "Z(x) L" );
#r = Ring( "Mod 3 (x,y,z) L" );
#r = Ring( "Z(y,x) L" );
print "Ring: " + str(r);
print;
[one,x,y,z] = r.gens();
#f = z * ( y + 1 )**2 * ( x**2 + x + 1 )**3;
#f = z * ( y + 1 ) * ( x**2 + x + 1 );
#f = ( y + 1 ) * ( x**2 + x + 1 );
#f = ( y + z**2 ) * ( x**2 + x + 1 );
#f = x**4 * y + x**3 + z + x + z**2 + y * z**2;
## f = x**3 + ( ( y + 2 ) * z + 2 * y + 1 ) * x**2 \
## + ( ( y + 2 ) * z**2 + ( y**2 + 2 * y + 1 ) * z + 2 * y**2 + y ) * x \
## + ( y + 1 ) * z**3 + ( y + 1 ) * z**2 + ( y**3 + y**2 ) * z + y**3 + y**2;
#f = ( x + y * z + y + z + 1 ) * ( x**2 + ( y + z ) * x + y**2 + z**2 );
f = ( x + y * z + y + z + 1 ) * ( x**2 + ( y + z ) * x + y**2 + 1 );
#f = ( x + y ) * ( x - y);
print "f = ", f;
print;
startLog();
t = System.currentTimeMillis();
G = r.factors(f);
t = System.currentTimeMillis() - t;
print "#G = ", len(G);
#print "factor time =", t, "milliseconds";
g = one;
for h, i in G.iteritems():
print "h**i = (", h, ")**" + str(i);
h = h**i;
g = g*h;
#print "g = ", g;
if cmp(f,g) == 0:
print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
print "factor time =", t, "milliseconds,", "isFactors(f,g): ", cmp(f,g);
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys
from java.lang import System
from jas import PolyRing, Ideal
from jas import terminate, startLog
from jas import ZM, RF, QQ, DD
# system biology examples: GB in RF()
# see: Informatik Spektrum, 2009, February,
# Laubenbacher, Sturmfels: Computer Algebra in der Systembiologie
# example from: http://theory.bio.uu.nl/rdb/books/tb.pdf
# ------------ input rational expression --------------------
r = PolyRing(RF(PolyRing(QQ(),"A",PolyRing.lex)),"L, M, R",PolyRing.lex);
print "PolyRing: " + str(r);
print;
[one,A,L,M,R] = r.gens();
c = 1;
gamma = 1;
v = 1;
c0 = QQ(5,100); # 0.05
h = 2;
n = 5;
delta = QQ(2,10); # 0.2
f1 = R - 1/(1+A**n);
f2 = M * L - delta * A - ( v * M * A ) / ( h + A );
f3 = c0 + c * ( 1 - 1 / ( 1 + A**n ) - gamma * M);
F = [f1,f2,f3];
print "f1 = " + str(f1);
print "f2 = " + str(f2);
print "f3 = " + str(f3);
print;
I = r.ideal( "", list=F );
print "Ideal: " + str(I);
print;
#sys.exit();
G = I.GB();
print "GB: " + str(G);
print;
# ------------ GB and CGB --------------------
r2 = PolyRing(PolyRing(QQ(),"L",PolyRing.lex),"A, M, R",PolyRing.lex);
#r2 = PolyRing(RF(PolyRing(QQ(),"L",PolyRing.lex)),"A, M, R",PolyRing.lex);
print "PolyRing: " + str(r2);
print;
[one,L,A,M,R] = r2.gens();
fi1 = ( (21,20) * A**6 + (21,10) * A**5 + (1,20) * A + (1,10) ) * L - ( (1,5) * A**7 + (29,20) * A**6 + (1,5) * A**2 + (9,20) * A );
fi2 = ( A**5 + 1 ) * M - ( (21,20) * A**5 + (1,20) );
fi3 = ( A**5 + 1 ) * R - ( 1 );
#fi4 = L - 1;
Fi = [fi1,fi2,fi3];
print "fi1 = " + str(fi1);
print "fi2 = " + str(fi2);
print "fi3 = " + str(fi3);
#print "fi4 = " + str(fi4);
print;
Ii = r2.ideal( "", list=Fi );
print "Ideal: " + str(Ii);
print;
Gi = Ii.GB();
print "GB: " + str(Gi);
print;
Ipi = r2.paramideal( "", list=Gi.list );
print "ParamIdeal: " + str(Ipi);
print;
cgb = Ipi.CGB();
print "CGB: " + str(cgb);
print;
#sys.exit();
# ------------ real roots --------------------
r3 = PolyRing(QQ(),"A",PolyRing.lex);
print "PolyRing: " + str(r3);
print;
eps = QQ(1,10) ** DD().elem.DEFAULT_PRECISION;
print "eps = ", eps;
[one,A] = r3.gens();
plot={};
plotd={};
br = 1;
for i in range(1,30):
L = QQ(-1) + (i,10);
#L = QQ(9,10) + (i,100);
fr = QQ(5) * ( (1,5) ) * A**7 - ( (21,20) * L - (29,20) ) * A**6 - ( (21,10) * L ) * A**5 + ( (1,5) ) * A**2 - ( (1,20) * L - (9,20) ) * A - ( (1,10) * L );
print "L = " + str(DD(L));
#print "fr = " + str(fr);
#print;
t = System.currentTimeMillis();
R = r3.realRoots(fr);
t = System.currentTimeMillis() - t;
# print "R = " + str([ str(DD(r.elem.getRational())) for r in R ]);
print "R = " + str([ r.elem.decimalMagnitude() for r in R ]);
plot[float(DD(L))] = R;
#print "real roots time =", t, "milliseconds";
if len(R) != br:
br = len(R);
print "#(real roots) = %s" % br;
b = L - (11,100);
for j in range(1,12):
L = b + (j,100);
fri = QQ(5) * ( (1,5) ) * A**7 - ( (21,20) * L - (29,20) ) * A**6 - ( (21,10) * L ) * A**5 + ( (1,5) ) * A**2 - ( (1,20) * L - (9,20) ) * A - ( (1,10) * L );
R = r3.realRoots(fri);
print "L = %s, Ri = %s" %(DD(L),[ r.elem.decimalMagnitude() for r in R ]);
plot[float(DD(L))] = R;
R = r3.realRoots(fri,eps);
plotd[float(DD(L))] = [ r.elem.decimalMagnitude() for r in R ];
t = System.currentTimeMillis();
R = r3.realRoots(fr,eps);
plotd[float(DD(L))] = [ r.elem.decimalMagnitude() for r in R ];
t = System.currentTimeMillis() - t;
print "R = " + str([ r.elem.decimalMagnitude() for r in R ]);
print "real roots time =", t, "milliseconds";
print;
print "real algebraic numbers:";
pk = plot.keys();
pk.sort();
for l in pk:
print "%s, %s" %(l,[ str(p.elem) for p in plot[l]]);
print;
print "real root approxmations:";
pk = plotd.keys();
pk.sort();
for l in pk:
print "%s, %s" %(l,[ str(p) for p in plotd[l]]);
print;
# ------------ factor polynomial --------------------
r5 = PolyRing(QQ(),"L",PolyRing.lex);
print "PolyRing: " + str(r5);
print;
[one,L] = r5.gens();
frl = L**5 + (5,31) * L**4 - (10,31) * L**3 + (10,31) * L**2 - (5,31) * L + (1,31);
#frl = (1,4) * L - (1,4);
print "frl = " + str(frl);
print;
t = System.currentTimeMillis();
R = r5.realRoots(frl);
t = System.currentTimeMillis() - t;
print "R = " + str([ r.elem.decimalMagnitude() for r in R ]);
print "real roots time =", t, "milliseconds";
t = System.currentTimeMillis();
R = r5.realRoots(frl,eps);
t = System.currentTimeMillis() - t;
print "R = " + str([ r.elem.decimalMagnitude() for r in R ]);
print "real roots time =", t, "milliseconds";
t = System.currentTimeMillis();
fk = r5.squarefreeFactors(frl);
#fk = r5.factors(frl);
t = System.currentTimeMillis() - t;
#print "fk = " + str(fk);
#print "factor time =", t, "milliseconds";
g = one;
for h, i in fk.iteritems():
print "h**i = (", h, ")**" + str(i);
h = h**i;
g = g*h;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import QQ, DD, Ring
from jas import MultiSeriesRing, MPS
from jas import startLog
from edu.jas.ps import MultiVarCoefficients
from edu.jas.ps import MultiVarPowerSeriesMap
# example for power series
#
#
#
# rational number examples
#
psr = MultiSeriesRing("Q(x,y,z)",truncate=4);
print "psr:", psr;
print;
one = psr.one();
print "one:", one;
print;
zero = psr.zero();
print "zero:", zero;
print;
r1 = psr.random(4);
print "r1:", r1;
print;
print "r1:", r1;
print;
print "r1-r1:", r1-r1;
print;
r2 = psr.random(4);
print "r2:", r2;
print;
print "r2:", r2;
print;
print "r2-r2:", r2-r2;
print;
#sys.exit();
r3 = r1 + r2;
print "r3:", r3;
print;
r4 = r1 * r2 + one;
print "r4:", r4;
print;
e = psr.exp(1);
print "e:", e;
print;
r5 = r1 * r2 + e;
print "r5:", r5;
print;
#print "psr.gens: ", [ str(i) for i in psr.gens() ];
[one,x,y,z] = psr.gens();
print "x:", x;
print "y:", y;
print "z:", z;
print;
r6 = one - y;
print "r6:", r6;
print;
r7 = one / r6;
print "r7:", r7;
print;
s = psr.sin(1);
print "s:", s;
print;
r8 = psr.gcd(y,s);
print "r8:", r8;
print;
## s1 = s.evaluate( QQ(0) );
## print "s1:", s1;
## print;
c = psr.cos(1);
print "c:", c;
print;
## c1 = c.evaluate( QQ(0) );
## print "c1:", c1;
## print;
s2c2 = s*s+c*c; # sin^2 + cos^2 = 1
print "s2c2:", s2c2;
print;
#sys.exit();
# conversion from polynomials
pr = Ring("Q(x,y,z) L");
print "pr:", pr;
print;
[one,xp,yp,zp] = pr.gens();
p1 = one;
p2 = one - yp;
ps1 = psr.fromPoly(p1);
ps2 = psr.fromPoly(p2);
# rational function as power series:
ps3 = ps1 / ps2;
print "p1:", p1;
print "p2:", p2;
print "ps1:", ps1;
print "ps2:", ps2;
print "ps3:", ps3;
print;
p1 = one * 2 + yp**3 - yp**5;
p2 = one - yp**2 + yp**4;
ps1 = psr.fromPoly(p1);
ps2 = psr.fromPoly(p2);
# rational function as power series:
ps3 = ps1 / ps2;
ps4 = ps3.integrate( QQ(1), 1 );
ps5 = ps3.differentiate(1);
print "p1:", p1;
print "p2:", p2;
print "ps1:", ps1;
print "ps2:", ps2;
print "ps3:", ps3;
print "ps4:", ps4;
print "ps5:", ps5;
print;
#sys.exit();
#
# floating point examples
#
dr = MultiSeriesRing(cofac=DD(),names=psr.ring.polyRing().getVars(),truncate=psr.ring.truncate());
print "dr:", dr;
print;
de = dr.exp(1);
print "de:", de;
print;
def f(a):
return a.totalDeg();
ps = psr.create(f);
print "ps:", ps;
print;
def g(a):
return a.maxDeg();
ps1 = psr.create(g);
print "ps1:", ps1;
print;
ps2 = ps * ps1;
print "ps2:", ps2;
print;
def h(a):
return psr.ring.coFac.fromInteger( 2*a.maxDeg() );
ps3 = psr.create(jfunc=h);
print "ps3:", ps3;
print;
ps4 = ps3 * ps1;
print "ps4:", ps4;
print;
def k(a):
if a.signum() > 0:
r = psr.ring.coFac.fromInteger( 2*a.totalDeg() );
else:
r = psr.ring.coFac.getONE();
#print "r: ", r;
return r;
ps5 = MPS(psr.ring.coFac,psr.ring.getVars(),f=k);
print "ps5:", ps5;
print;
#sys.exit();
class coeff( MultiVarCoefficients ):
def __init__(self,r):
MultiVarCoefficients.__init__(self,r);
self.coFac = r.coFac;
def generate(self,i):
#print "i: ", i;
if i.signum() < 0:
return self.coFac.getZERO();
else:
if i.isZERO():
return self.coFac.getONE();
else:
c = self.coFac.getONE(); #self.get( i-1 ).negate();
return c.divide( self.coFac.fromInteger(i.totalDeg()) ).divide( self.coFac.fromInteger(i.totalDeg()-1) );
ps6 = psr.create( clazz=coeff(psr.ring) );
print "ps6:", ps6;
print;
ps7 = ps6 - s;
print "ps7:", ps7;
print;
#sys.exit();
class cosmap( MultiVarPowerSeriesMap ):
def __init__(self,cofac):
self.coFac = cofac;
def map(self,ps):
return ps.negate().integrate( self.coFac.getZERO(), 1 ).integrate( self.coFac.getONE(), 1 );
ps8 = psr.fixPoint( cosmap( psr.ring.coFac ) );
print "ps8:", ps8;
print;
ps9 = ps8 - c;
print "ps9:", ps9;
print;
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring, Ideal
from jas import startLog, terminate
# sicora, e-gb example
r = Ring( "Z(t) L" );
print "Ring: " + str(r);
print;
ps = """
(
( 2 t + 1 ),
( t**2 + 1 )
)
""";
f = r.ideal( ps );
print "Ideal: " + str(f);
print;
#startLog();
g = f.eGB();
print "seq e-GB:", g;
print "is e-GB:", g.iseGB();
print;
| Python |
#
# 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, ZM, RF
# polynomial examples: ideal radical decomposition, inseparable case, 0-dim
cr = PolyRing(ZM(5),"c",PolyRing.lex);
print "coefficient Ring: " + str(cr);
rf = RF(cr);
print "coefficient quotient Ring: " + str(rf);
r = PolyRing(rf,"x,y,z",PolyRing.lex);
print "Ring: " + str(r);
print;
[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;
#f2 = y**6 + 2 * x * y**4 + 4 * x**2 * y**2 + 4 * x**3;
#f2 = y**6 + 2 * x * y**4 + 3 * x**2 * y**2 + 4 * x**3;
f1 = (x**2 + 2)**2;
f2 = (y**2 + 2)**3;
#f2 = f2**5;
f3 = z**10 - c**5;
f4 = (y**2 - x)**3;
print "f1 = ", f1;
print "f2 = ", f2;
print "f3 = ", f3;
#print "f4 = ", f4;
print;
F = r.ideal( list=[f1,f2,f3] );
print "F = ", F;
print;
startLog();
t = System.currentTimeMillis();
R = F.radicalDecomp();
t = System.currentTimeMillis() - t;
print "R = ", R;
print;
print "decomp time =", t, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import SolvableRing
# exterior calculus example
# Hartley and Tuckey, 1993,
# GB in Clifford and Grassmann algebras
rs = """
# exterior calculus example:
Rat(a,b,c,f,g,h,u,v,w,x,y,z) L
RelationTable
(
( b ), ( a ), ( - a b ),
( c ), ( a ), ( - a c ),
( f ), ( a ), ( - a f ),
( g ), ( a ), ( - a g ),
( h ), ( a ), ( - a h ),
( u ), ( a ), ( - a u ),
( v ), ( a ), ( - a v ),
( w ), ( a ), ( - a w ),
( x ), ( a ), ( - a x ),
( y ), ( a ), ( - a y ),
( z ), ( a ), ( - a z ),
( c ), ( b ), ( - b c ),
( f ), ( b ), ( - b f ),
( g ), ( b ), ( - b g ),
( h ), ( b ), ( - b h ),
( u ), ( b ), ( - b u ),
( v ), ( b ), ( - b v ),
( w ), ( b ), ( - b w ),
( x ), ( b ), ( - b x ),
( y ), ( b ), ( - b y ),
( z ), ( b ), ( - b z ),
( f ), ( c ), ( - c f ),
( g ), ( c ), ( - c g ),
( h ), ( c ), ( - c h ),
( u ), ( c ), ( - c u ),
( v ), ( c ), ( - c v ),
( w ), ( c ), ( - c w ),
( x ), ( c ), ( - c x ),
( y ), ( c ), ( - c y ),
( z ), ( c ), ( - c z ),
( g ), ( f ), ( - f g ),
( h ), ( f ), ( - f h ),
( u ), ( f ), ( - f u ),
( v ), ( f ), ( - f v ),
( w ), ( f ), ( - f w ),
( x ), ( f ), ( - f x ),
( y ), ( f ), ( - f y ),
( z ), ( f ), ( - f z ),
( h ), ( g ), ( - g h ),
( u ), ( g ), ( - g u ),
( v ), ( g ), ( - g v ),
( w ), ( g ), ( - g w ),
( x ), ( g ), ( - g x ),
( y ), ( g ), ( - g y ),
( z ), ( g ), ( - g z ),
( u ), ( h ), ( - h u ),
( v ), ( h ), ( - h v ),
( w ), ( h ), ( - h w ),
( x ), ( h ), ( - h x ),
( y ), ( h ), ( - h y ),
( z ), ( h ), ( - h z ),
( v ), ( u ), ( - u v ),
( w ), ( u ), ( - u w ),
( x ), ( u ), ( - u x ),
( y ), ( u ), ( - u y ),
( z ), ( u ), ( - u z ),
( w ), ( v ), ( - v w ),
( x ), ( v ), ( - v x ),
( y ), ( v ), ( - v y ),
( z ), ( v ), ( - v z ),
( x ), ( w ), ( - w x ),
( y ), ( w ), ( - w y ),
( z ), ( w ), ( - w z ),
( y ), ( x ), ( - x y ),
( z ), ( x ), ( - x z ),
( z ), ( y ), ( - y z )
)
""";
r = SolvableRing( rs );
print "SolvableRing: " + str(r);
print;
# ( a b + c f + g h ),
# ( u v + w x + y z ),
# ( a v + w x + y z ),
ps = """
(
( a b + c f + g h ),
( u v + w x + y z ),
( a^2 ),
( b^2 ),
( c^2 ),
( f^2 ),
( g^2 ),
( h^2 ),
( u^2 ),
( v^2 ),
( w^2 ),
( x^2 ),
( y^2 ),
( z^2 )
)
""";
f = r.ideal( ps );
print "SolvableIdeal: " + str(f);
print;
rg = f.leftGB();
print "seq left GB:", rg;
print;
#rg = f.twosidedGB();
#print "seq twosided GB:", rg;
#print;
#rg = f.rightGB();
#print "seq right GB:", rg;
#print;
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import QQ, Ring, PolyRing, Ideal
from jas import startLog, terminate
# trinks 6/7 example
#r = Ring( "Mod 19 (B,S,T,Z,P,W) L" );
#r = Ring( "Mod 1152921504606846883 (B,S,T,Z,P,W) L" ); # 2^60-93
#r = Ring( "Quat(B,S,T,Z,P,W) L" );
#r = Ring( "Z(B,S,T,Z,P,W) L" );
#r = Ring( "C(B,S,T,Z,P,W) L" );
#r = Ring( "Rat(B,S,T,Z,P,W) L" );
r = PolyRing( QQ(),"B,S,T,Z,P,W", PolyRing.lex);
print "Ring: " + str(r);
print;
ps = """
(
( 45 P + 35 S - 165 B - 36 ),
( 35 P + 40 Z + 25 T - 27 S ),
( 15 W + 25 S P + 30 Z - 18 T - 165 B**2 ),
( - 9 W + 15 T P + 20 S Z ),
( P W + 2 T Z - 11 B**3 ),
( 99 W - 11 B S + 3 B**2 ),
( 10000 B**2 + 6600 B + 2673 )
)
""";
# ( 10000 B**2 + 6600 B + 2673 )
# ( B**2 + 33/50 B + 2673/10000 )
#f = Ideal( r, ps );
#print "Ideal: " + str(f);
#print;
f = r.ideal( ps );
print "Ideal: " + str(f);
print;
#startLog();
rg = f.GB();
#print "seq Output:", rg;
#print;
rg = f.parGB(2);
#print "par Output:", rg;
#print;
f.distClient(); # starts in background
rg = f.distGB(2);
#print "dist Output:", rg;
#print;
terminate();
sys.exit(); # required because of distClient
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import SolvableRing
from edu.jas.poly import ModuleList;
from edu.jas.gbmod import SolvableSyzygyAbstract;
# WA_32 example
rs = """
# solvable polynomials, Weyl algebra A_3,2:
Rat(a,b,e1,e2,e3) G3|
RelationTable
(
( e3 ), ( e1 ), ( e1 e3 - e1 ),
( e3 ), ( e2 ), ( e2 e3 - e2 )
)
""";
r = SolvableRing( rs );
print "SolvableRing: " + str(r);
print;
ps = """
(
( e1 e3^3 + e2^10 - a ),
( e1^3 e2^2 + e3 ),
( e3^3 + e3^2 - b )
)
""";
f = r.ideal( ps );
print "SolvableIdeal: " + str(f);
print;
Z = SolvableSyzygyAbstract().leftZeroRelationsArbitrary( f.list );
Zp = ModuleList( r.ring, Z );
print "seq left syz Output:", Zp;
print;
if SolvableSyzygyAbstract().isLeftZeroRelation( Zp.list, f.list ):
print "is left syzygy";
else:
print "is not left syzygy";
Zr = SolvableSyzygyAbstract().rightZeroRelationsArbitrary( f.list );
Zpr = ModuleList( r.ring, Zr );
print "seq right syz Output:", Zpr;
print;
if SolvableSyzygyAbstract().isRightZeroRelation( Zpr.list, f.list ):
print "is right syzygy";
else:
print "is not right syzygy";
rg = f.leftGB();
print "seq left Output:", rg;
print;
if rg.isLeftGB():
print "is left GB";
else:
print "is not left GB";
g = rg.list;
rg = f.twosidedGB();
print "seq twosided Output:", rg;
print;
if rg.isTwosidedGB():
print "is twosided GB";
else:
print "is not twosided GB";
rgb = rg.rightGB();
print "seq right Output:", rgb;
print;
if rgb.isRightGB():
print "is right GB";
else:
print "is not right GB";
| Python |
#
# jython for jas example 3 integer programming.
# $Id$
#
# CLO2, p374,c
# 3 A + 2 B + C + D = 45
# A + 2 B + 3 C + E = 21
# 2 A + B + C + F = 18
#
# max: 3 A + 4 B + 2 C
#
import sys;
from jas import Ring
from jas import Ideal
r = Ring( "Rat(w1,w2,w3,w4,w5,w6,z1,z2,z3) W( (0,0,0,0,0,0,1,1,1),(-3,-4,-2,0,0,0,0,0,0) )" );
#r = Ring( "Rat(w1,w2,w3,w4,w5,w6,z1,z2,z3) W( (0,0,0,0,0,0,1,1,1),( 6, 5, 5,1,1,1,0,0,0)*2 )" );
#r = Ring( "Rat(w1,w2,w3,w4,w5,w6,z1,z2,z3) W( (0,0,0,0,0,0,1,1,1),( 3, 1, 3,1,1,1,0,0,0) )" );
#r = Ring( "Rat(w1,w2,w3,w4,w5,w6,z1,z2,z3) W( (0,0,0,0,0,0,1,1,1),( 9, 6, 8,2,2,2,0,0,0) )" );
print "Ring: " + str(r);
print;
ps = """
(
( z1^3 z2 z3^2 - w1 ),
( z1^2 z2^2 z3 - w2 ),
( z1 z2^3 z3 - w3 ),
( z1 - w4 ),
( z2 - w5 ),
( z3 - w6 )
)
""";
f = Ideal( r, ps );
print "Ideal: " + str(f);
print;
rg = f.GB();
print "seq Output:", rg;
print;
pf = """
(
( z1^45 z2^21 z3^18 )
)
""";
fp = Ideal( r, pf );
print "Ideal: " + str(fp);
print;
nf = fp.NF(rg);
print "NFs: " + str(nf);
print;
#rg = f.parGB(2);
#print "par Output:", rg;
#print;
#f.distClient(); # starts in background
#rg = f.distGB(2);
#print "dist Output:", rg;
#print;
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring, PolyRing, SolvPolyRing
from jas import Ideal
from jas import Module, SubModule, SolvableModule, SolvableSubModule
from jas import startLog
from jas import terminate
from jas import ZZ, QQ, ZM, GF, DD, CC, Quat, Oct, AN, RealN, RF, RC, LC, RR, PS, MPS, Vec, Mat
from edu.jas.arith import BigDecimal
print "------- ZZ = BigInteger ------------";
z1 = ZZ(12345678901234567890);
print "z1 = " + str(z1);
z2 = z1**2 + 12345678901234567890;
print "z2 = " + str(z2);
print;
print "------- QQ = BigRational ------------";
r1 = QQ(1,12345678901234567890);
print "r1 = " + str(r1**3);
r2 = r1**2 + (1,12345678901234567890);
print "r2 = " + str(r2);
print;
print "------- ZM = ModInteger ------------";
m1 = ZM(19,12345678901234567890);
print "m1 = " + str(m1);
m2 = m1**2 + 12345678901234567890;
print "m2 = " + str(m2);
print;
print "------- GF = ModInteger ------------";
m1 = GF(19,12345678901234567890);
print "m1 = " + str(m1);
m2 = m1**2 + 12345678901234567890;
print "m2 = " + str(m2);
print;
print "------- DD = BigDecimal ------------";
d1 = DD(12345678901234567890);
print "d1 = " + str(d1);
d2 = (1/d1)**2;
print "d2 = " + str(d2);
print;
print "------- CC = BigComplex ------------";
c1 = CC((1,2),(5,));
print "c1 = " + str(c1);
c2 = (1/c1)**2;
print "c2 = " + str(c2);
c3 = CC(0,(1,));
c3 = 1/c3;
print "c3 = " + str(c3);
[one,I] = CC().gens();
print "one = " + str(one);
print "I = " + str(I);
c4 = c3 + 5 * I;
print "c4 = " + str(c4);
c5 = (-396,10201)-(80,10201)*I;
print "c5 = " + str(c5);
print;
print "------- Quat = BigQuaternion ------------";
[oneQ,IQ,JQ,KQ] = Quat().gens();
print "oneQ = " + str(oneQ);
print "IQ = " + str(IQ);
print "JQ = " + str(JQ);
print "KQ = " + str(KQ);
q1 = 2 + 3 * IQ + 4 * JQ + 5 * KQ;
print "q1 = " + str(q1);
q2 = (1/q1)**2;
print "q2 = " + str(q2);
q3 = q2 * q1 * q1;
print "q3 = " + str(q3);
q4 = (-23,1458) + (-1,243)*IQ + (-4,729)*JQ + (-5,729)*KQ
print "q4 = " + str(q4);
q5 = q2 - q4;
print "q5 = " + str(q5);
print;
print "------- Oct = BigOctonion ------------";
#print [ str(g) for g in Oct().gens() ];
[oneOR,IOR,JOR,KOR,oneOI,IOI,JOI,KOI] = Oct().gens();
print "oneOR = " + str(oneOR);
print "IOR = " + str(IOR);
print "JOR = " + str(JOR);
print "KOR = " + str(KOR);
print "oneOI = " + str(oneOI);
print "IOI = " + str(IOI);
print "JOI = " + str(JOI);
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;
print "------- PolyRing(QQ(),\"x,y,z\") ---------";
r = PolyRing(QQ(),"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);
s1 = QQ(1,2) + QQ(2,3) * x + QQ(2,5) * y + ( x + y + z )**2;
print "s1 = " + str(s1);
s2 = (1,2) + (2,3) * x + (2,5) * y + ( x + y + z )**2;
print "s2 = " + str(s2);
s3 = z**2 + 2 * y * z + 2 * x * z + y**2 + 2 * x * y + x**2 + (2,5) * y + (2,3) * x + (1,2);
print "s3 = " + str(s3);
s4 = s1 - s3;
print "s4 = " + str(s4);
print "s4.factory() = " + str(s4.factory());
print;
print "------- PolyRing(ZM(11),\"x,y,z\") ---------";
r = PolyRing(ZM(11),"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 = 12 + 13 * x + 14 * y + 15 * 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 + 4 * z + 3 * y + 2 * x + 1;
print "p2 = " + str(p2);
p3 = p1 - p2;
print "p3 = " + str(p3);
print "p3.factory() = " + str(p3.factory());
print;
print "------- PolyRing(DD(),\"x,y,z\") ---------";
r = PolyRing(DD(),"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 = 0.2 + 0.3 * x + 0.4 * y + 0.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 + 0.5 * z + 0.40000000000000002220446049250313080847263336181641 * y + 0.29999999999999998889776975374843459576368331909180 * x + 0.200000000000000011102230246251565404236316680908203125;
print "p2 = " + str(p2);
p3 = p1 - p2;
print "p3 = " + str(p3);
print "p3.factory() = " + str(p3.factory());
print;
print "------- PolyRing(CC(),\"x,y,z\") ---------";
r = PolyRing(CC(),"x,y,z",PolyRing.grad);
print "r = " + str(r);
[one,I,x,y,z] = r.gens();
print "one = " + str(one);
print "I = " + str(I);
print "x = " + str(x);
print "y = " + str(y);
print "z = " + str(z);
s1 = CC((1,2)) + CC((2,3)) * x + 3 * I * y + ( x + y + z )**2;
print "s1 = " + str(s1);
#print "s1.factory() = " + str(s1.factory());
#print "s1.coefficients() = " + str(s1.coefficients());
s2 = ((1,2),) + ((2,3),) * x + 3 * I * y + ( x + y + z )**2;
print "s2 = " + str(s2);
#print "s2.factory() = " + str(s2.factory());
#print "s2.coefficients() = " + str(s2.coefficients());
s3 = z**2 + ((2,),) * y * z + ((2,),) * x * z + y**2 + ((2,),) * x * y + x**2 + ((0,),(3,)) * y + ((
2,3),) * x + ((1,2),);
print "s3 = " + str(s3);
#print "s3.factory() = " + str(s3.factory());
#print "s3.coefficients() = " + str(s3.coefficients());
s4 = s3 - s1;
print "s4 = " + str(s4);
print "s4.factory() = " + str(s4.factory());
print;
print "------- PolyRing(Quat(),\"x,y,z\") ---------";
r = PolyRing(Quat(),"x,y,z",PolyRing.grad);
print "r = " + str(r);
[oneQ,IQ,JQ,KQ,x,y,z] = r.gens();
print "oneQ = " + str(oneQ);
print "IQ = " + str(IQ);
print "JQ = " + str(JQ);
print "KQ = " + str(KQ);
print "x = " + str(x);
print "y = " + str(y);
print "z = " + str(z);
s1 = Quat((1,2)) + Quat((2,3)) * x + Quat((2,5)) * y + ( x + y + z )**2;
print "s1 = " + str(s1);
s2 = ((1,2),) + ((2,3),) * x + ((2,5),) * y + ( x + y + z )**2;
print "s2 = " + str(s2);
s3 = z**2 + 2 * y * z + 2 * x * z + y**2 + 2 * x * y + x**2 + (2,5) * y + (2,3) * x + (1,2);
print "s3 = " + str(s3);
s4 = s3 - s1;
print "s4 = " + str(s4);
print "s4.factory() = " + str(s4.factory());
print;
print "------- PolyRing(Oct(),\"x,y,z\") ---------";
r = PolyRing(Oct(),"x,y,z",PolyRing.grad);
print "r = " + str(r);
[oneOR,IOR,JOR,KOR,oneOI,IOI,JOI,KOI,x,y,z] = r.gens();
print "oneOR = " + str(oneOR);
print "IOR = " + str(IOR);
print "JOR = " + str(JOR);
print "KOR = " + str(KOR);
print "oneOI = " + str(oneOI);
print "IOI = " + str(IOI);
print "JOI = " + str(JOI);
print "KOI = " + str(KOI);
print "x = " + str(x);
print "y = " + str(y);
print "z = " + str(z);
s1 = Oct(Quat((1,2))) + Oct(Quat((2,3))) * x + Oct(Quat((2,5))) * y + ( x + y + z )**2;
print "s1 = " + str(s1);
s2 = QQ(1,2) + QQ(2,3) * x + QQ(2,5) * y + ( x + y + z )**2;
print "s2 = " + str(s2);
s3 = z**2 + 2 * y * z + 2 * x * z + y**2 + 2 * x * y + x**2 + (2,5) * y + (2,3) * x + (1,2);
print "s3 = " + str(s3);
s4 = s3 - s1;
print "s4 = " + str(s4);
print "s4.factory() = " + str(s4.factory());
print;
print "------- AN(alpha**2 - 2) ---------";
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);
Qs2 = AN(sqrt2);
print "Qs2 = " + str(Qs2.factory());
[one,alpha] = Qs2.gens();
print "one = " + str(one);
print "alpha = " + str(alpha);
b = alpha**2 - 2;
print "b = " + str(b);
c = 1 / alpha;
print "c = " + str(c);
Qs2x = AN(alpha**2 - 2);
print "Qs2x = " + str(Qs2x.factory());
print;
print "------- GF_17(alpha**2 - 2) ---------";
r = PolyRing(GF(17),"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);
Qs2 = AN(sqrt2);
print "Qs2 = " + str(Qs2.factory());
[one,alpha] = Qs2.gens();
print "one = " + str(one);
print "alpha = " + str(alpha);
b = alpha**2 - 2;
print "b = " + str(b);
c = 1 / alpha;
print "c = " + str(c);
Qs2x = AN(alpha**2 - 2);
print "Qs2x = " + str(Qs2x.factory());
print;
print "------- RealN(alpha**2 - 2,(1,2) ---------";
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,2));
print "Qs2r = " + str(Qs2r.factory());
[one,alpha] = Qs2r.gens();
print "one = " + str(one);
print "alpha = " + str(alpha);
b = 7 * alpha - 10;
print "b = " + str(b);
print "b.factory() = " + str(b.factory());
print "sign(b) = " + str(b.signum());
print "magnitude(b) = " + str(BigDecimal(b.elem.magnitude()));
c = 1 / b;
print "c = " + str(c);
print "sign(c) = " + str(c.signum());
print "magnitude(c) = " + str(BigDecimal(c.elem.magnitude()));
Qs2rx = RealN( alpha**2 - 2, ( 1, 2 ) );
print "Qs2rx = " + str(Qs2rx.factory());
print;
print "------- PolyRing(PolyRing(QQ(),\"a,b,c\"),\"x,y,z\") ---------";
r = PolyRing(QQ(),"a,b,c",PolyRing.grad);
print "r = " + str(r);
pr = PolyRing(r,"x,y,z",PolyRing.lex);
print "pr = " + str(pr);
[one,a,b,c,x,y,z] = pr.gens();
print "one = " + str(one);
print "a = " + str(a);
print "b = " + str(b);
print "c = " + str(c);
print "x = " + str(x);
print "y = " + str(y);
print "z = " + str(z);
s1 = QQ(1,2) + ( QQ(2,3) - c ) * x + ( QQ(2,5) + a + b )**2 * y + ( x + y + z )**2;
print "s1 = " + str(s1);
s2 = (1,2) + ( (2,3) - c ) * x + ( (2,5) + a + b )**2 * y + ( x + y + z )**2;
print "s2 = " + str(s2);
s3 = z**2 + ( 2 ) * y * z + ( 2 ) * x * z + y**2 + ( 2 ) * x * y + ( b**2 + 2 * a * b + a**2 + (4,5) * b + (4,5) * a + (4,25) ) * y + x**2 - ( c - (2,3) ) * x + ( (1,2) );
print "s3 = " + str(s3);
s4 = s1 + s2 - 2 * s3;
print "s4 = " + str(s4);
print "s4.factory() = " + str(s4.factory());
x = PolyRing(PolyRing(QQ(),"a, b, c",PolyRing.grad),"x, y, z",PolyRing.lex);
print "x = " + str(x);
print;
print "------- RF(PolyRing(ZZ(),\"a,b,c\",PolyRing.lex)) ---------";
r = PolyRing(ZZ(),"a,b,c",PolyRing.lex);
print "r = " + str(r);
rf = RF(r);
print "rf = " + str(rf.factory());
[one,a,b,c] = rf.gens();
print "one = " + str(one);
print "a = " + str(a);
print "b = " + str(b);
print "c = " + str(c);
q1 = a / b;
print "q1 = " + str(q1);
q2 = ( -2 * c**2 + 4 * b**2 + 4 * a**2 - 7 );
print "q2 = " + str(q2);
q3 = ( -7 * b + 4 * a + 12 );
print "q3 = " + str(q3);
q4 = q2 / q3;
print "q4 = " + str(q4);
q5 = ( 2 * c**2 - 4 * b**2 - 4 * a**2 + 7 ) / (7 * b - 4 * a - 12 );
print "q5 = " + str(q5);
q6 = q4 - q5;
print "q6 = " + str(q6);
print "q6.factory() = " + str(q6.factory());
x = RF(PolyRing(ZZ(),"a, b, c",PolyRing.lex));
print "x = " + str(x.factory());
print;
print "------- RC(PolyRing(QQ(),\"a,b,c\",PolyRing.lex)) ---------";
r = PolyRing(QQ(),"a,b,c",PolyRing.lex);
print "r = " + str(r);
[pone,pa,pb,pc] = r.gens();
print "pone = " + str(pone);
print "pa = " + str(pa);
print "pb = " + str(pb);
print "pc = " + str(pc);
g1 = pa**2 - 2;
print "g1 = " + str(g1);
g2 = pb**3 - 2;
print "g2 = " + str(g2);
g3 = pc**2 - pa*pb;
print "g3 = " + str(g3);
F = Ideal(r,list=[g1,g2,g3]);
print "F = " + str(F);
rc = RC(F);
print "rc.factory() = " + str(rc.factory());
[one,a,b,c] = rc.gens();
print "one = " + str(one);
print "a = " + str(a);
print "b = " + str(b);
print "c = " + str(c);
r1 = a*b + c;
print "r1 = " + str(r1);
r2 = r1*r1*r1 - r1*r1 + one;
print "r2 = " + str(r2);
r3 = r2**3 - r1 + one;
print "r3 = " + str(r3);
r4 = ( -120 * a * b**2 * c + 606 * b**2 * c + 1917 * a * b * c + 400 * b * c - 132 * a * c - 673 * c + 432 * a * b**2 + 2130 * b**2 + 1436 * a * b - 72 * b + 100 * a - 1950 );
print "r4 = " + str(r4);
r5 = r3 - r4;
print "r5 = " + str(r5);
print "r5.factory() = " + str(r5.factory());
r6 = 1/r2;
print "r6 = " + str(r6);
r7 = r6 * r2;
print "r7 = " + str(r7);
#F1 = Ideal(PolyRing(QQ(),"a, b, c",PolyRing.lex),list=[( pa**2 - 2 ), ( pb**3 - 2 ), ( pc**2 - pa * pb )]);
#print "F1 = " + str(F1);
rc1 = RC(Ideal(PolyRing(QQ(),"a, b, c",PolyRing.lex),list=[( a**2 - 2 ), ( b**3 - 2 ), ( c**2 - a * b )]));
print "rc1.factory() = " + str(rc1.factory());
print;
print "------- LC(PolyRing(QQ(),\"a,b,c\",PolyRing.lex)) ---------";
r = PolyRing(QQ(),"a,b,c",PolyRing.lex);
print "r = " + str(r);
[pone,pa,pb,pc] = r.gens();
print "pone = " + str(pone);
print "pa = " + str(pa);
print "pb = " + str(pb);
print "pc = " + str(pc);
g1 = pa**2 - 2;
print "g1 = " + str(g1);
g2 = pb**3 - 2;
print "g2 = " + str(g2);
g3 = pc**2 - pa*pb;
print "g3 = " + str(g3);
F = Ideal(r,list=[g1,g2,g3]);
print "F = " + str(F);
lc = LC(F);
print "lc.factory() = " + str(lc.factory());
print "gens = " + str([ str(x) for x in lc.gens() ]);
[one,a,a1,b,b1,c,c1] = lc.gens();
print "one = " + str(one);
print "a = " + str(a);
print "b = " + str(b);
print "c = " + str(c);
#F1 = Ideal(PolyRing(QQ(),"a, b, c",PolyRing.lex),list=[( pa**2 - 2 ), ( pb**3 - 2 ), ( pc**2 - pa * pb )]);
#print "F1 = " + str(F1);
lc1 = LC(Ideal(PolyRing(QQ(),"a, b, c",PolyRing.lex),list=[( a**2 - 2 ), ( b**3 - 2 ), ( c**2 - a * b )]));
print "lc1.factory() = " + str(lc1.factory());
l1 = a*b + c;
print "l1 = " + str(l1);
l2 = l1*l1*l1 - l1*l1 + one;
print "l2 = " + str(l2);
l3 = 1/l2;
print "l3 = " + str(l3);
l4 = l3 * l2;
print "l4 = " + str(l4);
l5 = a**2 - 2 + 1;
print "l5 = " + str(l5);
l6 = 1/l5;
print "l6 = " + str(l6);
l7 = (l1 * l2) / l2;
print "l7 = " + str(l7);
print;
print "------- RR( [QQ(),ZM(19),DD()] ) ---------";
r = RR( [QQ(),ZM(19),DD()] );
print "r = " + str(r);
print "r.factory() = " + str(r.factory());
rc1 = RR( [ QQ(), ZM(19), DD() ] );
print [ str(x) for x in r.gens() ];
print "rc1.factory() = " + str(rc1.factory());
[pg0,pg1,pg2] = r.gens();
print "pg0 = " + str(pg0);
print "pg1 = " + str(pg1);
print "pg2 = " + str(pg2);
r1 = pg1 + pg2 + pg0;
print "r1 = " + str(r1);
r2 = r1 * r1 + 7 * r1;
print "r2 = " + str(r2);
r3 = r2**3;
print "r3 = " + str(r3);
r4 = 1/r3;
print "r4 = " + str(r4);
r5 = r4 - r1;
print "r5 = " + str(r5);
r6 = ( (-511,512)*pg0 + 17*pg1 - 0.998046875*pg2 );
print "r6 = " + str(r6);
print;
print "------- PS(QQ(),\"x\") ---------";
r = PS(QQ(),"x");
print "r = " + str(r);
print "r.factory() = " + str(r.factory());
[one,x] = r.gens();
print "one = " + str(one);
print "x = " + str(x);
p1 = x**2 - 2;
print "p1 = " + str(p1);
p2 = x**3 - 2;
print "p2 = " + str(p2);
p3 = x**2 - p1 * p2;
print "p3 = " + str(p3);
p4 = - 4 + 3 * x**2 + 2 * x**3 - x**5;
print "p4 = " + str(p4);
def g1(i):
return r.ring.coFac.fromInteger( 2*i );
def g2(i):
#print "2*QQ(i) = " + str(QQ(2)*QQ(i))
return 2*QQ(i);
r = PS(QQ(),"x",g2);
print "r = " + str(r);
print "r.factory() = " + str(r.factory());
[one,x] = r.gens();
print "one = " + str(one);
print "x = " + str(x);
p1 = x**2 - r;
print "p1 = " + str(p1);
p2 = x**3 - r/2;
print "p2 = " + str(p2);
print;
print "------- MPS(QQ(),\"x,y\") ---------";
r = MPS(QQ(),"x,y");
print "r = " + str(r);
print "r.factory() = " + str(r.factory());
one,x,y = r.gens();
print "one = " + str(one);
print "x = " + str(x);
print "y = " + str(y);
p1 = x**2 - 2*y;
print "p1 = " + str(p1);
p2 = x**3 * y - y**2;
print "p2 = " + str(p2);
p3 = x**2 * y**2 - p1 * p2;
print "p3 = " + str(p3);
p4 = - 4 + 3 * x**2 + 2 * x**3 - x**5;
print "p4 = " + str(p4);
def g1(i):
return r.ring.coFac.fromInteger( i.getVal(0)*i.getVal(1) );
def g2(i):
#print "QQ(i.0)*QQ(i.1) = " + str(QQ(i.0)*QQ(i.1))
return QQ(i.getVal(0)) * QQ(i.getVal(1));
r = MPS(QQ(),"x,y",g2);
print "r = " + str(r);
print "r.factory() = " + str(r.factory());
one,x,y = r.gens();
print "one = " + str(one);
print "x = " + str(x);
print "y = " + str(y);
p1 = x**2 - r;
print "p1 = " + str(p1);
p2 = y**3 + r/2;
print "p2 = " + str(p2);
print;
print "------- Vec(QQ(),7) ---------";
r = Vec(QQ(),7);
print "r = " + str(r);
print "r.factory() = " + str(r.factory());
#print [ str(g) for g in r.gens() ];
[e1,e2,e3,e4,e5,e6,e7] = r.gens();
print "e1 = " + str(e1);
print "e2 = " + str(e2);
print "e3 = " + str(e3);
print "e4 = " + str(e4);
print "e5 = " + str(e5);
print "e6 = " + str(e6);
print "e7 = " + str(e7);
v1 = e1 + e3;
print "v1 = " + str(v1);
#v2 = v1 + 5 * e7;
#print "v2 = " + str(v2);
v3 = v1 - e1 - e3;
print "v3 = " + str(v3);
print;
print "------- Mat(QQ(),3,3) ---------";
r = Mat(QQ(),3,3);
print "r = " + str(r);
print "r.factory() = " + str(r.factory());
#print [ str(g) for g in r.gens() ];
[e11,e12,e13,e21,e22,e23,e31,e32,e33] = r.gens();
print "e11 = " + str(e11);
print "e12 = " + str(e12);
print "e13 = " + str(e13);
print "e21 = " + str(e21);
print "e22 = " + str(e22);
print "e23 = " + str(e23);
print "e31 = " + str(e31);
print "e32 = " + str(e32);
print "e33 = " + str(e33);
m1 = e11 + e31;
print "m1 = " + str(m1);
m2 = m1 * m1 + 5*e22;
print "m2 = " + str(m2);
m3 = m2**3 - 125*e21 - 125*e23;
print "m3 = " + str(m3);
#m4 = 1/m2;
#print "m4 = " + str(m4);
m5 = ( ( 1, 0, 0 ), ( -125, 125, -125 ), ( 1, 0, 0 ) ); # is PyTuple!
print "m5 = " + str(m5);
m6 = m3 * m5;
print "m6 = " + str(m6);
print;
print "------- Mat(PolyRing(QQ(),\"x,y,z\",PolyRing.lex),3,3) ---------";
r = Mat(PolyRing(QQ(),"x,y,z",PolyRing.lex),3,3);
print "r = " + str(r);
print "r.factory() = " + str(r.factory());
#print [ str(g) for g in r.gens() ];
for g in r.gens():
print "g = " + str(g);
print;
print "------- PolyRing(Mat(QQ(),3,3),\"x,y,z\",PolyRing.lex) ---------";
r = PolyRing(Mat(QQ(),3,3),"x,y,z",PolyRing.lex);
print "r = " + str(r);
for g in r.gens():
print "g = " + str(g);
print;
print "------- SolvPolyRing(QQ(),\"x,y,z\") ---------";
r = PolyRing(QQ(),"x,y,z",PolyRing.lex);
print "r = " + str(r);
[pone,px,py,pz] = r.gens();
print "pone = " + str(pone);
print "px = " + str(px);
print "py = " + str(py);
print "pz = " + str(pz);
rel = ( py, px, px * py - 1 , pz, py, py * pz - 1 );
#print "rel = " + str(rel);
sr = SolvPolyRing(QQ(),"x,y,z",PolyRing.lex,rel);
print "sr = " + str(sr);
[one,x,y,z] = sr.gens();
print "one = " + str(one);
print "x = " + str(x);
print "y = " + str(y);
print "z = " + str(z);
print "one.factory() = " + str(one.factory());
s1 = QQ(1,2) + QQ(2,3) * x + QQ(2,5) * y + ( x + y + z )**2;
print "s1 = " + str(s1);
s2 = (1,2) + (2,3) * x + (2,5) * y + ( x + y + z )**2;
print "s2 = " + str(s2);
s3 = z**2 + 2 * y * z + 2 * x * z + y**2 + 2 * x * y + x**2 + (2,5) * y + (2,3) * x + (1,2);
print "s3 = " + str(s3);
s4 = s1 - s3;
print "s4 = " + str(s4);
print "s4.factory() = " + str(s4.factory());
sr1 = SolvPolyRing(QQ(),"x, y, z",PolyRing.lex,(( z ), ( y ), ( y * z - 1 ),( y ), ( x ), ( x * y - 1 )));
print "sr1 = " + str(sr1);
s5 = z * y;
print "s5 = " + str(s5);
s6 = s5**3;
print "s6 = " + str(s6);
s7 = ( z * y )**3;
print "s7 = " + str(s7);
s8 = s7 - s6;
print "s8 = " + str(s8);
s9 = y**3 * z**3 - 3 * y**2 * z**2 + 3 * y * z - 1;
print "s9 = " + str(s9);
s10 = s9 - s7;
print "s10 = " + str(s10);
print;
print "------- SubModule(PolyRing(QQ(),\"u, v, l\",PolyRing.lex) ---------";
p = PolyRing(QQ(),"u, v, l",PolyRing.lex);
print "p = " + str(p);
[one,u,v,l] = p.gens();
print "one = " + str(one);
print "u = " + str(u);
print "v = " + str(v);
print "l = " + str(l);
m = Module(ring=p,cols=4);
print "m = " + str(m);
for g in m.gens():
print "g =", str(g);
m1 = ( 0, 1, l + v, 0 )
m2 = ( 0, v, u * l**2, 0 )
m3 = ( 0, l + 3 * v, 0, u )
m4 = ( 0, v * l + v**2, u**2, 0 )
m5 = ( 0, l**2, u, 0 )
m6 = ( 1, 0, 0, l**2 )
m7 = ( 1, 0, l + 3 * v, 0 )
m8 = ( 1, 2, 0, l**2 )
m9 = ( u, 0, 0, v * l + v**2 )
m10 = ( l + v, 0, 0, u )
m11 = ( l**2, 0, 0, v )
m12 = ( l**2, 0, 2 * u,v )
ml = [m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12];
#ml=[ ( 0, 1, l + v, 0 ), ( 0, v, u * l**2, 0 ), ( 0, l + 3 * v, 0, u ), ( 0, v * l + v**2, u**2, 0 ), ( 0, l**2, u, 0 ), ( 1, 0, 0, l**2 ), ( 1, 0, l + 3 * v, 0 ), ( 1, 2, 0, l**2 ), ( u, 0, 0, v * l + v**2 ), ( l + v, 0, 0, u ), ( l**2, 0, 0, v ), ( l**2, 0, 2 * u,v ) ];
#print "ml = " + str(ml);
#print;
sm = m.submodul(list=ml);
#sm = SubModule(m,list=ml);
print "sm = " + str(sm);
xm = SubModule(PolyRing(QQ(),"u, v, l",PolyRing.lex),list=[ ( 0, 1, ( l + v ), 0 ), ( 0, v, u * l**2, 0 ), ( 0, ( l + 3 * v ), 0, u ), ( 0, ( v * l + v**2 ), u**2, 0 ), ( 0, l**2, u, 0 ), ( 1, 0, 0, l**2 ), ( 1, 0, ( l + 3 * v ), 0 ), ( 1, 2, 0, l**2 ), ( u, 0, 0, ( v * l + v**2 ) ), ( ( l + v ), 0, 0, u ), ( l**2, 0, 0, v ), ( l**2, 0, 2 * u, v ) ])
# SubModule(PolyRing(QQ(),"u, v, l",PolyRing.lex),list=[ ( 0, 1, ( l + v ), 0 ), ( 0, v, u * l**2, 0 ), ( 0, ( l + 3 * v ), 0, u ), ( 0, ( v * l + v**2 ), u**2, 0 ), ( 0, l**2, u, 0 ), ( 1, 0, 0, l**2 ), ( 1, 0, ( l + 3 * v ), 0 ), ( 1, 2, 0, l**2 ), ( u, 0, 0, ( v * l + v**2 ) ), ( ( l + v ), 0, 0, u ), ( l**2, 0, 0, v ), ( l**2, 0, 2 * u, v ) ])
# SubModule(PolyRing(QQ(),"u, v, l",PolyRing.lex),list=[ ( 0, (1,), l + v, 0 ), ( 0, v, u * l**2, 0 ), ( 0, l + (3,) * v, 0, u ), ( 0, v * l + v**2, u**2, 0 ), ( 0, l**2, u, 0 ), ( (1,), 0, 0, l**2 ), ( (1,), 0, l + (3,) * v, 0 ), ( (1,), (2,), 0, l**2 ), ( u, 0, 0, v * l + v**2 ), ( l + v, 0, 0, u ), ( l**2, 0, 0, v ), ( l**2, 0, (2,) * u, v ) ]);
# SubModule(PolyRing(QQ(),"u, v, l",PolyRing.lex),list=[ ( 0, (1,), l + v, 0 ), ( 0, v, u * l**2, 0 ), ( 0, l + (3,) * v, 0, u ), ( 0, v * l + v**2, u**2, 0 ), ( 0, l**2, u, 0 ), ( (1,), 0, 0, l**2 ), ( (1,), 0, l + (3,) * v, 0 ), ( (1,), (2,), 0, l**2 ), ( u, 0, 0, v * l + v**2 ), ( l + v, 0, 0, u ), ( l**2, 0, 0, v ), ( l**2, 0, (2,) * u, v ) ]);
print "xm = " + str(xm);
print;
#rg = sm.GB();
#print "rg:", rg;
#print "isGB:", rg.isGB();
#print;
print "------- SolvableSubModule(SolvPolyRing(CC(),\"X,Y,x,y\")) ---------";
r = PolyRing(CC(),"X,Y,x,y",PolyRing.lex);
print "r = " + str(r);
[pone,pi,pX,pY,px,py] = r.gens();
print "pone = " + str(pone);
print "pi = " + str(pi);
print "pX = " + str(pX);
print "pY = " + str(pY);
print "px = " + str(px);
print "py = " + str(py);
#rel = ( py, px, px * py - 1 , pz, py, py * pz - 1 );
rel = [ py, px, pi * px * py, pX, pY, pi * pY * pX ];
print "rel = " + str([ str(x) for x in rel ]);
sr = SolvPolyRing(CC(),"X,Y,x,y",PolyRing.lex,rel);
print "sr = " + str(sr);
[one,i,X,Y,x,y,] = sr.gens();
print "one = " + str(one);
print "i = " + str(i);
print "X = " + str(X);
print "Y = " + str(Y);
print "x = " + str(x);
print "y = " + str(y);
m1 = ( ( x + 1 ), ( y ) )
m2 = ( ( x * y ), ( 0 ) )
m3 = ( ( x - X ), ( x - X ) )
m4 = ( ( y - Y ), ( y - Y ) )
ml = [m1,m2,m3,m4];
#print "ml = " + str(ml);
ssm = SolvableSubModule( sr, list=ml );
print "ssm: " + str(ssm);
print;
xsm = SolvableSubModule(SolvPolyRing(CC(),"X, Y, x, y",PolyRing.lex,rel=[y, x, ( ((0,),(1,)) * x * y ), Y, X, ( ((0,),(1,)) * X * Y )]),list=[ ( x - X, x - X ), ( x + ((1,),), y ), ( y - Y, y - Y ), ( x * y, 0 ) ]);
# SolvableSubModule(SolvPolyRing(CC(),"X, Y, x, y",PolyRing.lex,rel=[y, x, ( ((0,),(1,)) * x * y ), Y, X, ( ((0,),(1,)) * X * Y )]),list=[ ( x - X, x - X ), ( x + ((1,),), y ), ( y - Y, y - Y ), ( x * y, 0 ) ]);
# SolvableSubModule(SolvPolyRing(CC(),"X, Y, x, y",PolyRing.lex,(( y ), ( x ), ( ((0,),(1,)) * x * y ),( Y ), ( X ), ( ((0,),(1,)) * X * Y ))),list=[ ( x - X, x - X ), ( x + ((1,),), y ), ( y - Y, y - Y ), ( x * y, 0 ) ]);
print "xsm: " + str(xsm);
print;
## mlg = ssm.leftGB();
## print "mlg:", mlg;
## print;
## mtg = ssm.twosidedGB();
## print "mtg:", mtg;
## print;
print "------------------------------------";
#print "globals() = " + str(globals());
terminate();
sys.exit();
print "globals() = " + str(globals());
print "locals() = " + str(locals());
print "vars() = " + str(vars());
| Python |
#
# read output of jas runnings and prepare input for gnuplot
#
import re;
import os;
exam = "kat_6";
runs = "t16";
#bname = exam + "_" + runs;
bname = "k6seqpair-3"
fname = bname + ".out";
oname = bname + ".po";
f=open(fname,"r");
print f;
o=open(oname,"w");
print o;
res = {};
resold = {};
for line in f:
if line.find("executed in") > 0:
print line,
if line.find("sequential") >= 0:
s = re.search(".*in (\d+)",line);
if s != None:
t = ('0', s.group(1));
res[ int( t[0] ) ] = float( t[1] );
resold[ int( t[0] ) ] = float( t[1] );
else:
if line.find("-old") >= 0:
s = re.search("(\d+).*in (\d+)",line);
if s != None:
t = s.groups();
t0 = int( t[0] );
if resold.has_key( t0 ):
resold[ t0 ] = ( resold[ t0 ] + float(t[1]) )/2.0;
else:
resold[ t0 ] = float( t[1] );
else:
s = re.search("(\d+).*in (\d+)",line);
if s != None:
t = s.groups();
t0 = int( t[0] );
if res.has_key( t0 ):
res[ t0 ] = ( res[ t0 ] + float(t[1]) )/2.0;
else:
res[ t0 ] = float( t[1] );
# print "t = ", t, "\n";
print "\nres = ", res;
print "resold = ", resold;
ks = res.keys();
#print "ks = ", ks;
ks.sort();
#print "ks = ", ks;
s1 = ks[0];
st = res[ s1 ];
#print "s1 = ", s1;
#print "st = ", st;
kso = resold.keys();
#print "kso = ", kso;
kso.sort();
#print "kso = ", kso;
s1o = kso[0];
sto = resold[ s1o ];
#print "s1o = ", s1o;
#print "sto = ", sto;
speed = {};
speedold = {};
for k in ks:
speed[ k ] = st / res[ k ];
for k in kso:
speedold[ k ] = sto / resold[ k ];
print "speed = ", speed;
print "speedold = ", speedold;
print;
o.write("\n#threads time speedup timeold speedupold\n");
print "#threads time speedup timeold speedupold";
for k in ks:
o.write(str(k) + " " + str(res[k]) + " " + str(speed[k]) + " " + str(resold[k]) + " " + str(speedold[k]) +"\n");
print(str(k) + " " + str(res[k]) + " " + str(speed[k]) + " " + str(resold[k]) + " " + str(speedold[k]));
f.close();
o.close();
#---------------------------------------
pscript = """
set grid
set term %s
set output "%s.ps"
set title "GBs of Katsuras example on compute"
set time
set xlabel "#CPUs"
set multiplot
set size 0.75,0.5
set origin 0,0.5
set ylabel "milliseconds"
# smooth acsplines
plot "%s.po" title '%s computing time' with linespoints, \
"%s.po" using 1:4 title '%s-old computing time' with linespoints, \
"%s.po" using 1:( %s/$1 ) title '%s ideal' with linespoints
set size 0.75,0.5
set origin 0,0
set ylabel "speedup"
# smooth bezier
plot "%s.po" using 1:3 title '%s speedup' with linespoints, \
"%s.po" using 1:5 title '%s-old speedup' with linespoints, \
"%s.po" using 1:1 title '%s ideal' with linespoints
unset multiplot
pause mouse
""";
#---------------------------------------
psname = bname + ".ps";
pname = "plotin.gp"
p=open(pname,"w");
print p;
pscript = pscript % ("x11",bname,bname,exam,bname,exam,bname,str(res[0]),exam,bname,exam,bname,exam,bname,exam);
#pscript = pscript % ("postscript",bname,bname,exam,bname,exam,bname,str(res[0]),exam,bname,exam,bname,exam,bname,exam);
p.write(pscript);
p.close();
os.system("gnuplot plotin.gp");
cmd = "ps2pdf " + psname;
print "cmd: " + cmd;
#os.system(cmd);
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
# example cyclic6, optimize term order
# optimal is no change
#r = Ring( "Rat (x1,x2,x3,x4,x5,x6) G" );
#r = Ring( "Mod 3 (x1,x2,x3,x4,x5,x6) L" );
#r = Ring( "Rat (x6,x5,x4,x3,x2,x1) G" );
#r = Ring( "Mod 19 (x6,x5,x4,x3,x2,x1) G" );
r = Ring( "Mod 3 (x6,x5,x4,x3,x2,x1) G" );
print "Ring: " + str(r);
print;
ps = """
(
x1 + x2 + x3 + x4 + x5 + x6,
x1*x2 + x1*x6 + x2*x3 + x3*x4 + x4*x5 + x5*x6,
x1*x2*x3 + x1*x2*x6 + x1*x5*x6 + x2*x3*x4 + x3*x4*x5 + x4*x5*x6,
x1*x2*x3*x4 + x1*x2*x3*x6 + x1*x2*x5*x6 + x1*x4*x5*x6 + x2*x3*x4*x5 + x3*x4*x5*x6,
x1*x2*x3*x4*x5 + x1*x2*x3*x4*x6 + x1*x2*x3*x5*x6 + x1*x2*x4*x5*x6 + x1*x3*x4*x5*x6 + x2*x3*x4*x5*x6,
x1*x2*x3*x4*x5*x6 - 1
)
""";
#x1 + x2 + x3 + x4 + x5 + x6,
#x1*x2*x3*x4*x5*x6 - 1
f = Ideal( r, ps );
print "Ideal: " + str(f);
print;
startLog();
o = f.optimize();
print "optimized Ideal: " + str(o);
print;
rg = f.GB();
print "Output:", rg;
print;
#org = o.GB();
#print "opt Output:", org;
#print;
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import PolyRing, ZM, QQ
from jas import terminate
from jas import startLog
# polynomial examples: factorization over Z_p
r = PolyRing(ZM(1152921504606846883,field=True),"(x)",PolyRing.lex);
#r = PolyRing(ZM(19),"x",PolyRing.lex );
#r = PolyRing(ZM(23),"x",PolyRing.lex );
print "Ring: " + str(r);
print;
[one,x] = r.gens();
#f = x**4 - 1;
#f = x**3 + 1;
f = x**3 - x - 1;
print "f = ", f;
print;
startLog();
t = System.currentTimeMillis();
#G = r.squarefreeFactors(f);
G = r.factorsAbsolute(f);
t = System.currentTimeMillis() - t;
print "G = ", G.toScript();
print "factor time =", t, "milliseconds";
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import PolyRing, QQ, RF
from jas import Ideal
from jas import startLog
from jas import terminate
# Suzuki and Sato, ISSAC 2006, example 1
# integral function coefficients
#r = PolyRing( QQ(),"b,a,z,y,x", PolyRing.lex );
#r = PolyRing( RF( PolyRing(QQ(),"a, b",PolyRing.lex) ), "z,y,x", PolyRing.lex );
r = PolyRing( PolyRing(QQ(),"b, a",PolyRing.lex), "z,y,x", PolyRing.lex );
print "Ring: " + str(r);
print;
[one,b,a,z,y,x] = r.gens();
print "gens: ", [ str(f) for f in r.gens() ];
print;
#f1 = x**2 - a;
#f2 = y**3 - b;
f1 = x**3 - a;
f2 = y**4 - b;
f3 = x + y - z;
F = [f1,f2,f3];
print "F: ", [ str(f) for f in F ];
print;
startLog();
## If = r.ideal( "", list = F );
## print "Ideal: " + str(If);
## print;
## G = If.GB();
## print "GB: " + str(G);
## print;
## E = G.eliminateRing( PolyRing(QQ(),"b, a",PolyRing.lex) );
## print "E: " + str(E);
## print;
## sys.exit();
If = r.paramideal( "", list = F );
print "ParamIdeal: " + str(If);
print;
G = If.GB();
print "GB: " + str(G);
print;
terminate();
sys.exit();
GS = If.CGBsystem();
print "CGBsystem: " + str(GS);
print;
bg = GS.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
#terminate();
#sys.exit();
CG = If.CGB();
print "CGB: " + str(CG);
print;
bg = CG.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#------------------------------------------
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import PolyRing, QQ, RF
from jas import Ideal
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();
[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;
F = [f1,f2,f3];
print "F: ", [ str(f) for f in F ];
print;
#startLog();
If = r.paramideal( "", list = F );
print "ParamIdeal: " + str(If);
print;
G = If.GB();
print "GB: " + str(G);
print;
## sys.exit();
startLog();
GS = If.CGBsystem();
#GS = If.CGBsystem();
#GS = If.CGBsystem();
print "CGBsystem: " + str(GS);
print;
bg = GS.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
terminate();
sys.exit();
CG = If.CGB();
print "CGB: " + str(CG);
print;
bg = CG.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#------------------------------------------
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
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: real roots over Q for zero dimensional ideals
#r = Ring( "Rat(x) L" );
#r = Ring( "Q(x) L" );
r = PolyRing(QQ(),"x,y,z",PolyRing.lex);
print "Ring: " + str(r);
print;
[one,x,y,z] = r.gens();
f1 = (x**2 - 5)*(x**2 - 3)**2;
f2 = y**2 - 3;
f3 = z**3 - x * y;
print "f1 = ", f1;
print "f2 = ", f2;
print "f3 = ", f3;
print;
F = r.ideal( list=[f1,f2,f3] );
print "F = ", F;
print;
startLog();
t = System.currentTimeMillis();
R = F.realRoots();
t = System.currentTimeMillis() - t;
print "R = ", R;
print;
print "real roots = ";
F.realRootsPrint()
print "real roots time =", t, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
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: real roots over Q for zero dimensional ideals
r = PolyRing(QQ(),"q,w,s,x",PolyRing.lex);
print "Ring: " + str(r);
print;
[one,q,w,s,x] = r.gens();
# EF(QQ()).realExtend("q","q^3 - 3", "[1,2]").realExtend("w", "w^2 - q", "[1,2]").realExtend("s", "s^5 - 2", "[1,2]").polynomial("x").build();
f1 = q**3 - 3;
f2 = w**2 - q;
#f3 = s**5 - 2;
f3 = s**3 - 2;
f4 = x**2 - w * s;
print "f1 = ", f1;
print "f2 = ", f2;
print "f3 = ", f3;
print "f4 = ", f4;
print;
F = r.ideal( list=[f1,f2,f3,f4] );
print "F = ", F;
print;
startLog();
t = System.currentTimeMillis();
R = F.realRoots();
t = System.currentTimeMillis() - t;
print "R = ", R;
print;
print "real roots = ";
F.realRootsPrint()
print "real roots time =", t, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
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: zero dimensional ideals prime and primary decomposition
#r = Ring( "Rat(x) L" );
#r = Ring( "Q(x) L" );
r = PolyRing(QQ(),"x,y,z",PolyRing.lex);
print "Ring: " + str(r);
print;
[one,x,y,z] = r.gens();
f1 = (x**2 - 5)**2;
f2 = y**3 - x;
f3 = z**2 - y * x;
print "f1 = ", f1;
print "f2 = ", f2;
print "f3 = ", f3;
print;
F = r.ideal( list=[f1,f2,f3] );
print "F = ", F;
print;
startLog();
t = System.currentTimeMillis();
P = F.primeDecomp();
t1 = System.currentTimeMillis() - t;
print "P = ", P;
print;
print "prime decomp time =", t1, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
#from java.lang import System
from jas import WordRing, WordPolyRing, WordIdeal
from jas import terminate, startLog
from jas import QQ, ZZ, GF, ZM
# non-commutative polynomial examples: evans example
r = WordPolyRing(QQ(),"x,y,z");
print "WordPolyRing: " + str(r);
print;
[one,x,y,z] = r.gens();
print "one = " + str(one);
print "x = " + str(x);
print "y = " + str(y);
print "z = " + str(z);
print;
f1 = x * y - z;
f2 = y * z + 2 * x + z;
f3 = y * z + x;
print "f1 = " + str(f1);
print "f2 = " + str(f2);
print "f3 = " + str(f3);
print;
F = r.ideal( list=[f1,f2,f3] );
print "F = " + str(F);
print;
startLog();
G = F.GB();
print "G = " + str(G);
print "isGB(G) = " + str(G.isGB());
print;
#exit(0);
c1 = f1 * f2;
c2 = f2 * f1;
s = c1 - c2;
print "c1 = " + str(c1);
print "c2 = " + str(c2);
print "s = " + str(s);
print;
Fa = r.ideal( list=[f1,f2,f3,c1,c2,s] );
print "Fa = " + str(Fa);
print;
Ga = Fa.GB();
print "Ga = " + str(Ga);
print "isGB(Ga) = " + str(Ga.isGB());
#print;
#print "G = " + str(G);
print "G == Ga: " + str(cmp(G,Ga));
print "G == Ga: " + str(G.list == Ga.list);
print;
| Python |
#
# jython examples for jas.
# $Id$
#
#import sys;
from jas import Ring, PolyRing, Ideal
from jas import ZZ
from jas import startLog
# e-gb and d-gb example to compare with hermit normal form
r = PolyRing( ZZ(), "x4,x3,x2,x1", PolyRing.lex );
print "Ring: " + str(r);
print;
[one,x4,x3,x2,x1] = r.gens();
f1 = x1 + 2 * x2 + 3 * x3 + 4 * x4 + 3;
f2 = 3 * x2 + 2 * x3 + x4 + 2;
f3 = 3 * x3 + 5 * x4 + 1;
f4 = 5 * x4 + 4;
L = [f1,f2,f3,f4];
#print "L = ", str(L);
f = r.ideal( list=L );
print "Ideal: " + str(f);
print;
#startLog();
g = f.eGB();
print "seq e-GB:", g;
print "is e-GB:", g.iseGB();
print;
#sys.exit();
d = f.dGB();
print "seq d-GB:", d;
print "is d-GB:", d.isdGB();
print;
#startLog();
print "d-GB == e-GB:", g.pset.equals(d.pset);
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import SolvableRing
# WA_1 example
rs = """
# solvable polynomials, Weyl algebra A_1:
Rat(p,t,x,d) G
RelationTable
(
( d ), ( x ), ( x d + 1 )
)
""";
r = SolvableRing( rs );
print "SolvableRing: " + str(r);
print;
ps = """
(
( x^7 ),
( x d + 7 )
)
""";
i7 = r.ideal( ps );
print "SolvableIdeal: " + str(i7);
print;
i7rg = i7.leftGB();
print "seq left i7 Output:", i7rg;
print;
ps = """
(
( d^7 ),
( x d - 7 + 1 )
)
""";
j7 = r.ideal( ps );
print "SolvableIdeal: " + str(j7);
print;
j7rg = j7.leftGB();
print "seq left i7 Output:", j7rg;
print;
| Python |
#
# jython examples for jas.
# $Id$
#
import sys
from java.lang import System
from jas import Ring, RF, QQ, PolyRing
from jas import terminate
from jas import 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 );
f = ( x**7 - 24 * x**4 - 4 * x**2 + 8 * x - 8 ) / ( x**8 + 6 * x**6 + 12 * x**4 + 8 * x**2 );
print "f = ", f;
print;
#sys.exit();
#startLog();
t = System.currentTimeMillis();
e1 = r.integrate(f);
t = System.currentTimeMillis() - t;
print "e1 = ", e1;
## print "e1.toScript() = ";
## for a in e1.logarithm:
## print a.toScript();
print "integration time =", t, "milliseconds";
print
t = System.currentTimeMillis();
e2 = f.integrate();
t = System.currentTimeMillis() - t;
print "e2 = ", e2;
print "integration time =", t, "milliseconds";
print
#startLog();
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate
# Nabashima, ISSAC 2007, example F3
# integral function coefficients
r = Ring( "IntFunc(c, b, a, d) (x) L" );
print "Ring: " + str(r);
print;
ps = """
(
( { a } x^4 + { c } x^2 + { b } ),
( { b } x^3 + x^2 + 2 ),
( { c } x^2 + { d } x )
)
""";
#startLog();
f = r.paramideal( ps );
print "ParamIdeal: " + str(f);
print;
gs = f.CGBsystem();
gs = f.CGBsystem();
gs = f.CGBsystem();
gs = f.CGBsystem();
print "CGBsystem: " + str(gs);
print;
sys.exit();
bg = gs.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
#sys.exit();
gs = f.CGB();
print "CGB: " + str(gs);
print;
bg = gs.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#------------------------------------------
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import Ring
from jas import Ideal
# sparse polynomial powers
#r = Ring( "Mod 1152921504606846883 (x,y,z) G" );
#r = Ring( "Rat(x,y,z) G" );
#r = Ring( "C(x,y,z) G" );
r = Ring( "Z(x,y,z) L" );
print "Ring: " + str(r);
print;
ps = """
(
( 1 + x^2147483647 + y^2147483647 + z^2147483647 )
( 1 + x + y + z )
( 10000000001 + 10000000001 x + 10000000001 y + 10000000001 z )
)
""";
f = Ideal( r, ps );
print "Ideal: " + str(f);
print;
pset = f.pset;
print "pset:", pset;
print;
plist = pset.list;
print "plist:", plist;
print;
p = plist[0];
#p = plist[2];
print "p:", p;
print;
q = p;
for i in range(1,20):
q = q.multiply(p);
print "q:", q.length();
print;
q1 = q.sum( r.ring.getONE() );
#print "q1:", q1;
print "q1:", q1.length();
print;
t = System.currentTimeMillis();
q2 = q.multiply(q1);
t = System.currentTimeMillis() - t;
print "q2:", q2.length();
print "t:",t;
print;
print "Integer.MAX_VALUE = ", Integer.MAX_VALUE;
| Python |
#
# jython examples for jas.
# $Id$
#
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: ideal radical decomposition
#r = Ring( "Rat(x) L" );
#r = Ring( "Q(x) L" );
r = PolyRing(QQ(),"x,y,z",PolyRing.lex);
print "Ring: " + str(r);
print;
[one,x,y,z] = r.gens();
f1 = (x**2 - 5)**2;
f2 = (y**2 - 3)**3 * (y**2 - 5);
f3 = z**3 - x * y;
#print "f1 = ", f1;
print "f2 = ", f2;
print "f3 = ", f3;
print;
F = r.ideal( list=[f2,f3] );
print "F = ", F;
print;
startLog();
t = System.currentTimeMillis();
R = F.radicalDecomp();
t = System.currentTimeMillis() - t;
print "R = ", R;
print;
print "decomp time =", t, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import ParamIdeal
from jas import startLog
from jas import terminate
# simple example for comprehensive GB
# integral/rational function coefficients
#r = Ring( "RatFunc(u,v) (x,y) L" );
r = Ring( "IntFunc(u,v) (x,y) L" );
print "Ring: " + str(r);
print;
ps = """
(
( { v } x y + x ),
( { u } y^2 + x^2 )
)
""";
f = r.paramideal( ps );
print "ParamIdeal: " + str(f);
print;
#sys.exit();
#startLog();
gs = f.CGBsystem();
print "CGBsystem: " + str(gs);
print;
#sys.exit();
bg = gs.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
#sys.exit();
#startLog();
gs = f.CGB();
print "CGB: " + str(gs);
print;
#startLog();
bg = gs.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#sys.exit();
| Python |
import sys;
from jas import Ring, PolyRing, ParamIdeal, QQ, ZM, RR
from jas import startLog, terminate
# Boolean coefficient boolean GB
# see S. Inoue and A. Nagai "On the Implementation of Boolean Groebner Bases" in ASCM 2009
# Z_2 regular ring coefficent example
r = PolyRing(RR(ZM(2),3),"x,y",PolyRing.lex);
print "r = " + str(r);
#print len(r.gens())
[s1,s2,s3,x,y] = r.gens();
one = r.one();
print "one = " + str(one);
print "s1 = " + str(s1);
print "s2 = " + str(s2);
print "s2 = " + str(s3);
print "x = " + str(x);
print "y = " + str(y);
brel = [ x**2 - x, y**2 - y ];
print "brel = " + str(brel[0]) + ", " + str(brel[1]);
pl = [ ( one + s1 + s2 ) * ( x*y + x +y ), s1 * x + s1, s2 * y + s2, x * y ];
#pl = [ ( one ) * ( x*y + x +y ), s1 * x + s1, s2 * y + s2, x * y ];
pl = pl + brel;
startLog();
f = ParamIdeal(r,list=pl);
print "Ideal: " + str(f);
gb = f.regularGB();
print "boolean GB: " + str(gb);
#ss = gb.stringSlice();
#print "regular string slice: " + str(ss);
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate
# Raksanyi & Walter example
# rational function coefficients
r = Ring( "IntFunc(a1, a2, a3, a4) (x1, x2, x3, x4) L" );
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 "Ideal: " + str(f);
print;
#startLog();
rg = f.GB();
rg = f.GB();
print "Ideal: " + str(rg);
print;
bg = rg.isGB();
if bg:
print "isGB: true";
else:
print "isGB: false";
print;
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import SolvableRing
# U(sl_3) example
rs = """
# solvable polynomials, U(sl_3):
Rat(Xa,Xb,Xc,Ya,Yb,Yc,Ha,Hb) G
RelationTable
(
( Xb ), ( Xa ), ( Xa Xb - Xc ),
( Ya ), ( Xa ), ( Xa Ya - Ha ),
( Yc ), ( Xa ), ( Xa Yc + Yb ),
( Ha ), ( Xa ), ( Xa Ha + 2 Xa ),
( Hb ), ( Xa ), ( Xa Hb - Xa),
( Yb ), ( Xb ), ( Xb Yb - Hb ),
( Yc ), ( Xb ), ( Xb Yc - Ya ),
( Ha ), ( Xb ), ( Xb Ha - Xb ),
( Hb ), ( Xb ), ( Xb Hb + 2 Xb ),
( Ya ), ( Xc ), ( Xc Ya + Xb ),
( Yb ), ( Xc ), ( Xc Yb - Xa ),
( Yc ), ( Xc ), ( Xc Yc - Ha - Hb ),
( Ha ), ( Xc ), ( Xc Ha + Xc ),
( Hb ), ( Xc ), ( Xc Hb + Xc ),
( Yb ), ( Ya ), ( Ya Yb + Yc ),
( Ha ), ( Ya ), ( Ya Ha - 2 Ya ),
( Hb ), ( Ya ), ( Ya Hb + Ya ),
( Ha ), ( Yb ), ( Yb Ha + Yb ),
( Hb ), ( Yb ), ( Yb Hb - 2 Yb ),
( Ha ), ( Yc ), ( Yc Ha - Yc ),
( Hb ), ( Yc ), ( Yc Hb - Yc )
)
""";
r = SolvableRing( rs );
print "SolvableRing: " + str(r);
print;
ps = """
(
( Xa + Hb ),
( Xb + Ha Hb )
)
""";
f = r.ideal( ps );
print "SolvableIdeal: " + str(f);
print;
rg = f.leftGB();
print "seq left Output:", rg;
print;
rg = f.twosidedGB();
print "seq twosided Output:", rg;
print;
| Python |
#
# jython examples for jas.
# $Id$
#
## \begin{PossoExample}
## \Name{Hawes2}
## \Parameters{a;b;c}
## \Variables{x;y[2];z[2]}
## \begin{Equations}
## x+2y_1z_1+3ay_1^2+5y_1^4+2cy_1 \&
## x+2y_2z_2+3ay_2^2+5y_2^4+2cy_2 \&
## 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 Ideal
from jas import startLog
from jas import terminate
#startLog();
# 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,p6];
g = r.ideal( list=F );
print "Ideal: " + str(g);
print;
rg = g.GB();
rg = g.GB();
rg = g.GB();
rg = g.GB();
print "GB:", rg;
print;
bg = rg.isGB();
print "isGB:", bg;
print;
p7 = 1 / b;
print "p7 = ", p7;
p8 = p7 * b;
print "p8 = ", p8;
startLog();
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate
# Nabashima, ISSAC 2007, example F2
# integral function coefficients
r = Ring( "IntFunc(b, a) (x,y) L" );
print "Ring: " + str(r);
print;
ps = """
(
( { a } x^2 y^3 + { b } y + y ),
( x^2 y^2 + x y + 2 ),
( { a } x^2 + { b } y + 2 )
)
""";
#startLog();
f = r.paramideal( ps );
print "ParamIdeal: " + str(f);
print;
gs = f.CGBsystem();
gs = f.CGBsystem();
gs = f.CGBsystem();
gs = f.CGBsystem();
print "CGBsystem: " + str(gs);
print;
#sys.exit();
bg = gs.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
#sys.exit();
gs = f.CGB();
print "CGB: " + str(gs);
print;
bg = gs.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#------------------------------------------
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys
from java.lang import System
from jas import PolyRing, Ideal
from jas import QQ, AN, RF
from jas import terminate, startLog
# polynomial examples: prime/primary decomposition in Q[w2,x,wx,y,z]
Q = PolyRing(QQ(),"w2,x,wx,y,z",PolyRing.lex);
print "Q = " + str(Q);
[e,w2,x,wx,y,z] = Q.gens();
print "e = " + str(e);
print "w2 = " + str(w2);
print "x = " + str(x);
print "wx = " + str(wx);
print "y = " + str(y);
print "z = " + str(z);
print;
w1 = w2**2 - 2;
w2 = wx**2 - x;
f1 = ( y**2 - x ) * ( y**2 - 2 );
#f1 = ( y**2 - x )**3 * ( y**2 - 2 )**2;
f2 = ( z**2 - y**2 );
print "w1 = ", w1;
print "w2 = ", w2;
print "f1 = ", f1;
print "f2 = ", f2;
print;
F = Q.ideal( list=[w1,w2,f1,f2] );
print "F = ", F;
print;
#sys.exit();
startLog();
t = System.currentTimeMillis();
P = F.primeDecomp();
#P = F.primaryDecomp();
t1 = System.currentTimeMillis() - t;
print "P = ", P;
print;
print "prime/primary decomp time =", t1, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import PolyRing, QQ, ZM, AN
from jas import terminate
from jas import startLog
# polynomial examples: squarefree: characteristic p, finite algebraic
ar = PolyRing(ZM(7,field=True),"i",PolyRing.lex)
[one,i] = ar.gens();
# irred for 7, 11, 19
r = PolyRing(AN(i**2+1,field=True),"x, y, z",PolyRing.lex)
print "Ring: " + str(r);
print;
[one,i,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;
f = a**2 * b**7 * c;
print "a = ", a;
print "b = ", b;
print "c = ", c;
print "f = ", f;
print;
t = System.currentTimeMillis();
F = r.squarefreeFactors(f);
t = System.currentTimeMillis() - t;
print "factors:";
for g in F.keys():
i = F[g];
print "g = %s**%s" % (g,i);
print
print "factor time =", t, "milliseconds";
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import PolyRing, QQ, ZM, RF
from jas import terminate
from jas import startLog
# polynomial examples: squarefree: characteristic p, infinite
r = PolyRing( RF(PolyRing(ZM(5,field=True),"u, v",PolyRing.lex)), "x y z",PolyRing.lex);
print "r = " + str(r);
[one,u,v,x,y,z] = r.gens();
print "one = " + str(one);
print "u = " + str(u);
print "v = " + str(v);
print "x = " + str(x);
print "y = " + str(y);
print "z = " + str(z);
print "Ring: " + str(r);
print;
a = r.random(k=1,l=3);
b = r.random(k=1,l=3);
c = r.random(k=1,l=3);
if a.isZERO():
a = x;
if b.isZERO():
b = y;
if c.isZERO():
c = z;
#f = a**2 * b**3 * c;
f = b**5 * c;
print "a = ", a;
print "b = ", b;
print "c = ", c;
print "f = ", f;
print;
t = System.currentTimeMillis();
F = r.squarefreeFactors(f);
t = System.currentTimeMillis() - t;
print "factors:";
for g in F.keys():
i = F[g];
print "g = %s**%s" % (g,i);
print
print "factor time =", t, "milliseconds";
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring, PolyRing, Ideal
from jas import QQ, ZZ, RF
from jas import startLog, terminate
# example: Algebraic Statistics
# Drton, Sturmfels, Sullivant, example 2.1.3
r = PolyRing(RF(PolyRing(QQ(),"u0,u1,u2,u12",PolyRing.lex)),"l1,l2",PolyRing.grad);
print "Ring: " + str(r);
print;
print one,u0,u1,u2,u12,l1,l2;
f1 = (u1+u12)*(l1+l2+2)*(l1+1)*(l1+l2+1)\
+ (u12)*l1*(l1+1)*(l1+l2+1)\
- (u2+u12)*l1*(l1+l2+2)*(l1+l2+1)\
- (u0+u1+u2+u12)*l1*(l1+l2+2)*(l1+1) ;
f2 = (u2+u12)*(l1+l2+2)*(l2+1)*(l1+l2+1)\
+ (u12)*l2*(l2+1)*(l1+l2+1)\
- (u1+u12)*l2*(l1+l2+2)*(l1+l2+1)\
- (u0+u1+u2+u12)*l2*(l1+l2+2)*(l2+1) ;
print f1;
print f2;
print
#h = l1*l2*(l1+1)*(l2+1)*(l1+l2+1)*(l1+l2+2);
h = l1*l2*(l1+1);
hp = (l2+1);
hpp = (l1+l2+1)*(l1+l2+2);
print h;
print hp;
print hpp;
print
F = r.ideal(list=[f1,f2]);
print F;
print
H = r.ideal(list=[h]);
print H;
print
Hp = r.ideal(list=[hp]);
print Hp;
print
Hpp = r.ideal(list=[hpp]);
print Hpp;
print
startLog();
G = F.GB();
print G;
print
#startLog();
Q = G.sat(H);
print Q;
print
Q = Q.sat(Hp);
print Q;
print
Q = Q.sat(Hpp);
print Q;
print
D = Q.radicalDecomp();
print D;
print
#Di = Q.decomposition();
#print Di;
#print
#startLog();
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import SolvableRing
# WA_32 solvable polynomial example
rs = """
# solvable polynomials, Weyl algebra A_3,2:
Rat(a,b,e1,e2,e3) G|3|
RelationTable
(
( e3 ), ( e1 ), ( e1 e3 - e1 ),
( e3 ), ( e2 ), ( e2 e3 - e2 )
)
""";
r = SolvableRing( rs );
print "SolvableRing: " + str(r);
print;
ps = """
(
( e1 e3^3 + e2^10 - a ),
( e1^3 e2^2 + e3 ),
( e3^3 + e3^2 - b )
)
""";
f = r.ideal( ps );
print "SolvableIdeal: " + str(f);
print;
rg = f.leftGB();
print "seq left GB:", rg;
print;
rg = f.twosidedGB();
print "seq twosided GB:", rg;
print;
rg = f.rightGB();
print "seq right GB:", rg;
print;
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import Ring
from jas import Ideal
from jas import terminate
from jas import startLog
# polynomial examples: factorization over Z
r = Ring( "Z(x) L" );
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;
#f = x**8 - 40 * x**6 + 352 * x**4 - 960 * x**2 + 576;
#f = 362408718672000 * x**9 + 312179013226080 * x**8 - 591298435728000 * x**6 - 509344705789920 * x**5 - 1178946881112000 * x**2 - 4170783473878580 * x - 2717923400363451;
#f = 292700016000 * x**8 + 614670033600 * x**7 - 417466472400 * x**6 - 110982089400 * x**5 + 1185906158780 * x**4 - 161076194335 * x**3 + 204890011200 * x**2 - 359330651400 * x - 7719685302;
#f = x**10 - 212 * x**9 - 1760 * x**8 + 529 * x**7 - 93699 * x**6 - 726220 * x**5 + 37740 * x**4 + 169141 * x**3 + 24517680 * x**2 - 9472740;
#f = x**4 - 1;
#f = x**3 - x**2 + x - 1;
#f = x**8 + 4 * x**6 + 8 * x**4 - 8 * x**2 + 4;
#f = x**15 + 122 * x**10 - 122 * x**5 - 1;
#f = x**16 + 272 * x**12 - 7072 * x**8 + 3207424 * x**4 + 12960000;
f = x**16 + 16 * x**12 + 96 * x**8 + 256 * x**4 + 256;
f = f * (x**24 + 272 * x**20 - 7072 * x**16 + 3207424 * x**12 + 12960000 * x**8);
print "f = ", f;
print;
startLog();
t = System.currentTimeMillis();
#G = r.squarefreeFactors(f);
G = r.factors(f);
t = System.currentTimeMillis() - t;
print "G = ", [ str(h)+"**"+str(i) for (h,i) in G.iteritems() ];
#print "factor time =", t, "milliseconds";
g = one;
for h, i in G.iteritems():
print "h**i = (", h, ")**" + str(i);
h = h**i;
g = g*h;
#print "g = ", g;
if cmp(f,g) == 0:
print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
print "factor time =", t, "milliseconds,", "isFactors(f,g): ", cmp(f,g);
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from java.lang import System
from java.lang import Integer
from jas import Ring
from jas import PolyRing
from jas import Ideal
from jas import QQ, AN
from jas import terminate
from jas import startLog
# polynomial examples: absolute factorization over Q(i)
Qr = PolyRing(QQ(),"i",PolyRing.lex);
print "Qr = " + str(Qr);
[e,a] = Qr.gens();
print "e = " + str(e);
print "a = " + str(a);
imag = a**2 + 1;
print "imag = " + str(imag);
Qi = AN(imag,field=True);
print "Qi = " + str(Qi.factory());
[one,i] = Qi.gens();
print "one = " + str(one);
print "i = " + str(i);
print;
r = PolyRing(Qi,"x",PolyRing.lex)
print "r = " + str(r);
[one,i,x] = r.gens();
print "one = " + str(one);
print "i = " + str(i);
print "x = " + str(x);
print;
#f = x**7 - 1;
#f = x**6 + x**5 + x**4 + x**3 + x**2 + x + 1;
#f = x**2 - i;
#f = x**3 - i;
#f = x**2 + 1;
#f = x**5 - 1;
#f = x**4 + x**3 + x**2 + x + (1,);
#f = ( x**2 - i - 1 ) * ( x**2 + i + 1 );
f = ( x**2 - i ) * ( x**2 + i + 1 );
print "f = ", f;
print;
#startLog();
t = System.currentTimeMillis();
G = r.factors(f);
t = System.currentTimeMillis() - t;
#print "G = ", G;
#print "factor time =", t, "milliseconds";
f2 = one;
for h, i in G.iteritems():
print "h**i = (", h, ")**" + str(i);
h = h**i;
f2 = f2*h;
#print "f2 = ", f2;
print;
if cmp(f,f2) == 0:
print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
print "factor time =", t, "milliseconds,", "isFactors(f,g): ", cmp(f,f2);
print;
startLog();
t = System.currentTimeMillis();
G = r.factorsAbsolute(f);
t = System.currentTimeMillis() - t;
print "G = ", G.toScript();
print
print "factor time =", t, "milliseconds";
print
#sys.exit();
#startLog();
terminate();
| Python |
#
# 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, startLog, noThreads
from jas import QQ, ZM, RF
# polynomial examples: ideal radical decomposition, inseparable cases, dim > 0
#noThreads(); # must be called very early
cr = PolyRing(ZM(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;
[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;
f1 = (x**2 + 2)**2;
f2 = (y**2 - x)**5;
#f2 = f2**5;
f3 = (z**2 - c)**5;
f4 = (y**2 - x)**3;
#print "f1 = ", f1;
print "f2 = ", f2;
print "f3 = ", f3;
#print "f4 = ", f4;
print;
#F = r.ideal( list=[f1,f2,f3] );
F = r.ideal( list=[f2,f3] );
print "F = ", F;
print;
startLog();
t = System.currentTimeMillis();
R = F.radicalDecomp();
t = System.currentTimeMillis() - t;
print "R = ", R;
print;
print "decomp time =", t, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import Ring
from jas import Ideal
# trinks 7 example
r = Ring( "Rat(B,S,T,Z,P,W) L" );
print "Ring: " + str(r);
print;
ps = """
(
( 45 P + 35 S - 165 B - 36 ),
( 35 P + 40 Z + 25 T - 27 S ),
( 15 W + 25 S P + 30 Z - 18 T - 165 B**2 ),
( - 9 W + 15 T P + 20 S Z ),
( P W + 2 T Z - 11 B**3 ),
( 99 W - 11 B S + 3 B**2 ),
( B**2 + 33/50 B + 2673/10000 )
)
""";
f = Ideal( r, ps );
print "Ideal: " + str(f);
print;
g = f.GB();
print "Groebner base:", g;
print;
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
# pppj 2006 paper examples
r = Ring( "Z(x1,x2,x3) L" );
print "Ring: " + str(r);
print;
ps = """
(
( 3 x1^2 x3^4 + 7 x2^5 - 61 )
)
""";
#f = Ideal( r, ps );
#print "Ideal: " + str(f);
#print;
f = r.ideal( ps );
print "Ideal: " + str(f);
print;
from java.lang import System
from java.io import StringReader
from edu.jas.structure import *
from edu.jas.arith import *
from edu.jas.poly import *
from org.apache.log4j import BasicConfigurator;
BasicConfigurator.configure();
pps = """
3 x1^2 x3^4 + 7 x2^5 - 61
""";
ri = r.ring;
print "ri = " + str(ri);
pol = r.pset;
print "pol = " + str(pol);
pol = ri.parse( pps );
print "pol = " + str(pol);
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import Ring
from jas import Ideal
from jas import terminate
from jas import startLog
# polynomial examples: factorization over Z_p
#r = Ring( "Mod 1152921504606846883 (x) L" );
#r = Ring( "Mod 19 (x) L" );
r = Ring( "Mod 19 (x) L" );
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;
#f = x**8 - 40 * x**6 + 352 * x**4 - 960 * x**2 + 576;
#f = 362408718672000 * x**9 + 312179013226080 * x**8 - 591298435728000 * x**6 - 509344705789920 * x**5 - 1178946881112000 * x**2 - 4170783473878580 * x - 2717923400363451;
#f = 292700016000 * x**8 + 614670033600 * x**7 - 417466472400 * x**6 - 110982089400 * x**5 + 1185906158780 * x**4 - 161076194335 * x**3 + 204890011200 * x**2 - 359330651400 * x - 7719685302;
#f = x**10 - 212 * x**9 - 1760 * x**8 + 529 * x**7 - 93699 * x**6 - 726220 * x**5 + 37740 * x**4 + 169141 * x**3 + 24517680 * x**2 - 9472740;
#f = x**4 - 1;
f = x**2 + 1;
#f = x**19 + x;
#f = x**3 - x**2 + x - 1;
#f = x**8 + 4 * x**6 + 8 * x**4 - 8 * x**2 + 4;
#f = x**16 + 272 * x**12 - 7072 * x**8 + 3207424 * x**4 + 12960000;
#f = x**16 + 16 * x**12 + 96 * x**8 + 256 * x**4 + 256;
#f = x**24 + 272 * x**20 - 7072 * x**16 + 3207424 * x**12 + 12960000 * x**8;
print "f = ", f;
print;
startLog();
t = System.currentTimeMillis();
#G = r.squarefreeFactors(f);
G = r.factors(f);
t = System.currentTimeMillis() - t;
print "#G = ", len(G);
#print "factor time =", t, "milliseconds";
g = one;
for h, i in G.iteritems():
print "h**i = (", h, ")**" + str(i);
h = h**i;
g = g*h;
#print "g = ", g;
if cmp(f,g) == 0:
print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
print "factor time =", t, "milliseconds,", "isFactors(f,g): ", cmp(f,g);
print;
#startLog();
terminate();
| Python |
#
# 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( ZM(32003), "x,y,z" );
R = PolyRing( QQ(), "x,y,z" );
print "Ring: " + str(R);
print;
[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();
print "Power series ring: " + str(PR);
print;
Fp = PSIdeal(PR,L);
print "Power series ideal: " + str(Fp);
print;
startLog();
#9+5 # truncate at total degree 9
S = Fp.STD();
#print "std: " + str(S);
print;
for p in S.list:
#print "p = ", str(p.asPolynomial());
print "p = ", str(p);
print;
#sys.exit();
#terminate();
| Python |
#
# jython examples for jas.
from jas import SolvableRing
# U(sl_2_f) example
rs = """
# solvable polynomials, U(sl_2_f):
Rat(f,h) G
RelationTable
(
( h ), ( f ), ( f h - 2 f )
)
""";
r = SolvableRing( rs );
print "SolvableRing: " + str(r);
print;
ps = """
(
( h^2 + f^3 )
)
""";
f = r.ideal( ps );
print "SolvableIdeal: " + str(f);
print;
rg = f.leftGB();
print "seq left Output:", rg;
print;
rg = f.twosidedGB();
print "seq twosided Output:", rg;
print;
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import Ring
from jas import Ideal
from jas import terminate
from jas import startLog
# polynomial examples: factorization
#r = Ring( "Mod 1152921504606846883 (x,y,z) L" );
#r = Ring( "Rat(x,y,z) L" );
#r = Ring( "C(x,y,z) L" );
#r = Ring( "Z(x,y,z) L" );
#r = Ring( "Q(x) L" );
r = Ring( "Z(x) L" );
#r = Ring( "Mod 11 (x) L" );
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;
#f = x**8 - 40 * x**6 + 352 * x**4 - 960 * x**2 + 576;
#f = 362408718672000 * x**9 + 312179013226080 * x**8 - 591298435728000 * x**6 - 509344705789920 * x**5 - 1178946881112000 * x**2 - 4170783473878580 * x - 2717923400363451;
#f = 292700016000 * x**8 + 614670033600 * x**7 - 417466472400 * x**6 - 110982089400 * x**5 + 1185906158780 * x**4 - 161076194335 * x**3 + 204890011200 * x**2 - 359330651400 * x - 7719685302;
#f = x**10 - 212 * x**9 - 1760 * x**8 + 529 * x**7 - 93699 * x**6 - 726220 * x**5 + 37740 * x**4 + 169141 * x**3 + 24517680 * x**2 - 9472740;
#f = x**4 - 1;
#f = x**3 - x**2 + x - 1;
#f = x**8 + 4 * x**6 + 8 * x**4 - 8 * x**2 + 4;
#f = x**16 + 272 * x**12 - 7072 * x**8 + 3207424 * x**4 + 12960000;
#f = x**16 + 16 * x**12 + 96 * x**8 + 256 * x**4 + 256;
#f = x**24 + 272 * x**20 - 7072 * x**16 + 3207424 * x**12 + 12960000 * x**8;
#f = (-1+x)*(1+x)*(1+x+x**2)*(1-x+x**2);
f = x**16 - 1;
# ==
#f = (-1+x)*(1+x)*(1+x**2)*(1+x**4)*(1+x**8);
print "f = ", f;
print;
startLog();
t = System.currentTimeMillis();
#G = r.squarefreeFactors(f);
G = r.factors(f);
t = System.currentTimeMillis() - t;
print "#G = ", len(G);
#print "factor time =", t, "milliseconds";
g = one;
for h, i in G.iteritems():
print "h**i = (", h, ")**" + str(i);
h = h**i;
g = g*h;
#print "g = ", g;
if cmp(f,g) == 0:
print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
print "factor time =", t, "milliseconds,", "isFactors(f,g): ", cmp(f,g);
print;
#d = g / c;
#m = g % c;
#print "d = ", d;
#print "m = ", m;
#print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate
# Nabashima, ISSAC 2007, example Ex-4.3
# integral function coefficients
r = Ring( "IntFunc(a, b) (y,x) L" );
print "Ring: " + str(r);
print;
ps = """
(
( x y + x ),
( { a } x^2 + y + 2 ),
( { b } x y + y )
)
""";
#startLog();
f = r.paramideal( ps );
print "ParamIdeal: " + str(f);
print;
gs = f.CGBsystem();
print "CGBsystem: " + str(gs);
print;
bg = gs.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
#sys.exit();
gs = f.CGB();
print "CGB: " + str(gs);
print;
bg = gs.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#------------------------------------------
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import ParamIdeal
from jas import startLog
from jas import terminate
# 2 univariate polynomials of degree 2 example for comprehensive GB
# integral/rational function coefficients
#r = Ring( "RatFunc(u,v) (x,y) L" );
r = Ring( "IntFunc(a2, a1, a0, b2, b1, b0) (x) L" );
print "Ring: " + str(r);
print;
ps = """
(
( { a2 } x^2 + { a1 } x + { a0 } ),
( { b2 } x^2 + { b1 } x + { b0 } )
)
""";
f = r.paramideal( ps );
print "ParamIdeal: " + str(f);
print;
#sys.exit();
#startLog();
gs = f.CGBsystem();
print "CGBsystem: " + str(gs);
print;
#sys.exit();
bg = gs.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
#sys.exit();
gs = f.CGB();
print "CGB: " + str(gs);
print;
terminate();
sys.exit();
bg = gs.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
## \begin{PossoExample}
## \Name{Hawes2}
## \Parameters{a;b;c}
## \Variables{x;y[2];z[2]}
## \begin{Equations}
## x+2y_1z_1+3ay_1^2+5y_1^4+2cy_1 \&
## x+2y_2z_2+3ay_2^2+5y_2^4+2cy_2 \&
## 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, QQ, ZZ, RF
from jas import Ideal
from jas import startLog
from jas import terminate
#startLog();
# 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;
ps = """
(
( x + 2 y1 z1 + { 3 a } y1^2 + 5 y1^4 + { 2 c } y1 ),
( x + 2 y2 z2 + { 3 a } y2^2 + 5 y2^4 + { 2 c } y2 ),
( 2 z2 + { 6 a } y2 + 20 y2^3 + { 2 c } ),
( 3 z1^2 + y1^2 + { b } ),
( 3 z2^2 + y2^2 + { b } )
)
""";
f = r.ideal( ps );
print "Ideal: " + str(f);
print;
rg = f.GB();
rg = f.GB();
print "GB:", rg;
print;
bg = rg.isGB();
print "isGB:", bg;
print;
startLog();
terminate();
#sys.exit();
| Python |
#
# 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, startLog, noThreads
from jas import QQ, ZM, RF, AN
# polynomial examples: ideal radical decomposition, example 8.16 in GB book, base field with p-th root
# noThreads(); # must be called very early
prime = 5;
cf = ZM(prime);
#cf = QQ();
ca = PolyRing(cf,"t",PolyRing.lex);
print "ca = " + str(ca);
[ea,ta] = ca.gens();
print "ea = " + str(ea);
print "ta = " + str(ta);
print;
Qpt = RF(ca);
#print Qpt.gens();
[ea2,ta2] = Qpt.gens();
print "ea2 = " + str(ea2);
print "ta2 = " + str(ta2);
print;
cr = PolyRing(Qpt,"wpt",PolyRing.lex);
print "polynomial quotient ring: " + str(cr);
[et2,t,wpt] = cr.gens();
print "et2 = " + str(et2);
print "t = " + str(t);
print "wpt = " + str(wpt);
print;
root = wpt**prime - ta2;
af = AN(root,field=True);
print "coefficient algebraic quotient ring: " + str(af.ring.toScript());
#print af.gens();
##xx = AN(( wpt**5 + 4 * t ),True,PolyRing(RF(PolyRing(ZM(5),"t",PolyRing.lex)),"wpt",PolyRing.lex))
##print "xx: " + str(xx.ring.toScript());
[one,t,wpt] = af.gens();
print "one = " + str(one);
print "t = " + str(t);
print "wpt = " + str(wpt);
#print one,t,wpt;
print;
#sys.exit();
r = PolyRing(af,"x,y",PolyRing.lex);
print "polynomial ring: " + str(r);
#print;
[one,t,wpt,x,y] = r.gens();
#print one,t,wpt,x,y;
print "one = " + str(one);
print "t = " + str(t);
print "wpt = " + str(wpt);
print "x = " + str(x);
print "y = " + str(y);
print;
#sys.exit();
f1 = x**prime - t;
f2 = y**prime - t;
f2 = f2**3;
f3 = (y-x);
f3 = f3**prime;
print "f1 = ", f1;
print "f2 = ", f2;
#print "f3 = ", f3;
print;
F = r.ideal( list=[f1,f2] );
print "F = ", F;
print;
startLog();
t = System.currentTimeMillis();
R = F.radicalDecomp();
#R = F.primeDecomp();
t = System.currentTimeMillis() - t;
print "R = ", R;
print;
print "decomp time =", t, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import PolyRing, QQ, RF
from jas import Ideal
from jas import startLog
from jas import terminate
# Montes JSC 2002, 33, 183-208, example 5.1, simplified
# integral function coefficients
r = PolyRing( PolyRing(QQ(),"a, b",PolyRing.lex), "u,z,y,x", PolyRing.lex );
print "Ring: " + str(r);
print;
[one,a,b,u,z,y,x] = r.gens();
print "gens: ", [ str(f) for f in r.gens() ];
print;
f1 = 756 * x - 39 * a * b - 4 * b - 155 - 117 * a + ( 117 * a + 51 ) * u;
f2 = 189 * y + 6 * a * b - 107 - 43 * b + 18 * a - ( 18 * a - 123 ) * u;
f3 = 756 * z - 1439 + 236 * b + 99 * a + 33 * a * b - ( 99 * a - 15 ) * u;
f4 = ( 9 * a**2 - 30 * a + 21 ) * u - 9 * a**2 - 3 * a**2 * b + 11 * a * b + 22 * a - 49 + 28 * b;
F = [f1,f2,f3,f4];
print "F: ", [ str(f) for f in F ];
print;
#startLog();
If = r.paramideal( "", list = F );
print "ParamIdeal: " + str(If);
print;
## G = If.GB();
## print "GB: " + str(G);
## print;
## sys.exit();
GS = If.CGBsystem();
GS = If.CGBsystem();
GS = If.CGBsystem();
print "CGBsystem: " + str(GS);
print;
bg = GS.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
terminate();
sys.exit();
CG = If.CGB();
print "CGB: " + str(CG);
print;
bg = CG.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#------------------------------------------
#sys.exit();
| Python |
#
# 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 = Ring( "Q(x) L" );
r = PolyRing(QQ(),"a,b,c,d,e",PolyRing.lex);
print "Ring: " + str(r);
print;
[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;
print "f5 = ", f5;
print;
F = r.ideal( list=[f1,f2,f3,f4,f5] );
print "F = ", F;
print;
startLog();
#G = F.GB();
#print "G = ", G;
#print;
#sys.exit();
t = System.currentTimeMillis();
R = F.complexRoots();
#R = F.realRoots();
t = System.currentTimeMillis() - t;
print;
print "R = ", R;
print;
print "complex roots: ";
F.complexRootsPrint()
print "complex roots time =", t, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import SolvableRing
# U(sl_3) example
rs = """
# solvable polynomials, U(sl_3):
Rat(Xa,Xb,Xc,Ya,Yb,Yc,Ha,Hb) G
RelationTable
(
( Xb ), ( Xa ), ( Xa Xb - Xc ),
( Ya ), ( Xa ), ( Xa Ya - Ha ),
( Yc ), ( Xa ), ( Xa Yc + Yb ),
( Ha ), ( Xa ), ( Xa Ha + 2 Xa ),
( Hb ), ( Xa ), ( Xa Hb - Xa),
( Yb ), ( Xb ), ( Xb Yb - Hb ),
( Yc ), ( Xb ), ( Xb Yc - Ya ),
( Ha ), ( Xb ), ( Xb Ha - Xb ),
( Hb ), ( Xb ), ( Xb Hb + 2 Xb ),
( Ya ), ( Xc ), ( Xc Ya + Xb ),
( Yb ), ( Xc ), ( Xc Yb - Xa ),
( Yc ), ( Xc ), ( Xc Yc - Ha - Hb ),
( Ha ), ( Xc ), ( Xc Ha + Xc ),
( Hb ), ( Xc ), ( Xc Hb + Xc ),
( Yb ), ( Ya ), ( Ya Yb + Yc ),
( Ha ), ( Ya ), ( Ya Ha - 2 Ya ),
( Hb ), ( Ya ), ( Ya Hb + Ya ),
( Ha ), ( Yb ), ( Yb Ha + Yb ),
( Hb ), ( Yb ), ( Yb Hb - 2 Yb ),
( Ha ), ( Yc ), ( Yc Ha - Yc ),
( Hb ), ( Yc ), ( Yc Hb - Yc )
)
""";
r = SolvableRing( rs );
print "SolvableRing: " + str(r);
print;
ps = """
(
( Xb + Yb )
)
""";
# ( Xa + Xb + Xc + Ya + Yb + Yc + Ha + Hb )
f = r.ideal( ps );
print "SolvIdeal: " + str(f);
print;
fl = f.list;
print "fl: ", fl;
p = fl[0];
print "p: ", p;
print;
from java.lang import System
p2 = p;
n = 15;
t = System.currentTimeMillis();
for i in range(1,n):
p2 = p2.multiply(p);
t1 = System.currentTimeMillis() -t;
print "one product in %s ms" % t1;
print "p^%s.length: " % n, p2.length();
print;
p2 = p;
t = System.currentTimeMillis();
for i in range(1,n):
p2 = p2.multiply(p);
t1 = System.currentTimeMillis() -t;
print "one product in %s ms" % t1;
print "p^%s.length: " % n, p2.length();
print;
ps = """
(
( Xa ),
( Xb ),
( Xc ),
( Ya ),
( Yb ),
( Yc ),
( Ha ),
( Hb )
)
""";
f = r.ideal( ps );
#print "SolvableIdeal: " + str(f);
#print;
fl = f.list;
Yb = fl[4];
p1 = Yb;
Xb = fl[1];
p2 = Xb;
n = 10;
t = System.currentTimeMillis();
for i in range(1,n):
p1 = p1.multiply(Yb);
p2 = p2.multiply(Xb);
p = p1.multiply(p2);
t1 = System.currentTimeMillis() -t;
print "products in %s ms" % t1;
print "Xb^%s * Yb^%s: " % (n,n); #, p;
print;
pp = p;
p1 = Yb;
p2 = Xb;
t = System.currentTimeMillis();
for i in range(1,n):
p1 = p1.multiply(Yb);
p2 = p2.multiply(Xb);
p = p1.multiply(p2);
t1 = System.currentTimeMillis() -t;
print "products in %s ms" % t1;
print "Xb^%s * Yb^%s: " % (n,n); #, p;
print;
print "pp == p: ", (pp == p);
print;
#print "SolvIdeal: " + str(f);
#print;
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from jas import PolyRing, Ideal
from jas import terminate, startLog
from jas import ZM
# system biology examples: GB in Z_2
# see: Informatik Spektrum, 2009, February,
# Laubenbacher, Sturmfels: Computer Algebra in der Systembiologie
r = PolyRing(ZM(2),"M, B, A, L, P",PolyRing.lex);
print "PolyRing: " + str(r);
print;
[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;
#
## t1 = M;
## t2 = B;
## t3 = A;
## t4 = L;
## t5 = P;
#
## t1 = M;
## t2 = B;
## t3 = A;
## t4 = L - 1;
## t5 = P;
#
t1 = M;
t2 = B;
t3 = A - 1;
t4 = L - 1;
t5 = P;
F = [f1,f2,f3,f4,f5];
#F = [f1,f2,f3,f4,f5,t1,t2,t3,t4,t5];
I = r.ideal( "", list=F );
print "Ideal: " + str(I);
print;
G = I.GB();
print "GB: " + str(G);
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import Ring
from jas import Ideal
from jas import terminate
from jas import startLog
# polynomial examples: absolute factorization over Q
#r = Ring( "Rat(x) L" );
r = Ring( "Q(x) L" );
print "Ring: " + str(r);
print;
[one,x] = r.gens();
#f = x**5 - 1;
#f = x**6 - 1;
f = x**3 - 2;
f = f*f;
#f = x**7 - 1;
#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;
#f = x**8 - 40 * x**6 + 352 * x**4 - 960 * x**2 + 576;
#f = 362408718672000 * x**9 + 312179013226080 * x**8 - 591298435728000 * x**6 - 509344705789920 * x**5 - 1178946881112000 * x**2 - 4170783473878580 * x - 2717923400363451;
#f = 292700016000 * x**8 + 614670033600 * x**7 - 417466472400 * x**6 - 110982089400 * x**5 + 1185906158780 * x**4 - 161076194335 * x**3 + 204890011200 * x**2 - 359330651400 * x - 7719685302;
#f = x**10 - 212 * x**9 - 1760 * x**8 + 529 * x**7 - 93699 * x**6 - 726220 * x**5 + 37740 * x**4 + 169141 * x**3 + 24517680 * x**2 - 9472740;
#f = x**2 + 1;
#f = x**3 - x**2 + x - 1;
#f = x**6 - 5 * x**4 + 5 * x**2 + 4;
#f = x**8 + 4 * x**6 + 8 * x**4 - 8 * x**2 + 4;
#f = x**4 + 2 * x**2 - 4 * x + 2;
#f = x**16 + 272 * x**12 - 7072 * x**8 + 3207424 * x**4 + 12960000;
#f = x**16 + 16 * x**12 + 96 * x**8 + 256 * x**4 + 256;
#f = x**24 + 272 * x**20 - 7072 * x**16 + 3207424 * x**12 + 12960000 * x**8;
print "f = ", f;
print;
startLog();
t = System.currentTimeMillis();
#G = r.squarefreeFactors(f);
G = r.factorsAbsolute(f);
t = System.currentTimeMillis() - t;
print "G = ", G.toScript();
print
print "factor time =", t, "milliseconds";
print
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate
# trinks 6/7 example
#r = Ring( "Mod 19 (B,S,T,Z,P,W) L" );
#r = Ring( "Mod 1152921504606846883 (B,S,T,Z,P,W) L" ); # 2^60-93
#r = Ring( "Quat(B,S,T,Z,P,W) L" );
#r = Ring( "Z(B,S,T,Z,P,W) L" );
#r = Ring( "C(B,S,T,Z,P,W) L" );
r = Ring( "Rat(B,S,T,Z,P,W) L" );
print "Ring: " + str(r);
print;
ps = """
(
( 45 P + 35 S - 165 B - 36 ),
( 35 P + 40 Z + 25 T - 27 S ),
( 15 W + 25 S P + 30 Z - 18 T - 165 B**2 ),
( - 9 W + 15 T P + 20 S Z ),
( P W + 2 T Z - 11 B**3 ),
( 99 W - 11 B S + 3 B**2 ),
( 10000 B**2 + 6600 B + 2673 )
)
""";
# ( 10000 B**2 + 6600 B + 2673 )
# ( B**2 + 33/50 B + 2673/10000 )
#f = Ideal( r, ps );
#print "Ideal: " + str(f);
#print;
f = r.ideal( ps );
print "Ideal: " + str(f);
print;
#startLog();
rg = f.GB();
#print "seq Output:", rg;
#print;
rg = f.parGB(2);
#print "par Output:", rg;
#print;
f.distClient(); # starts in background
rg = f.distGB(2);
#print "dist Output:", rg;
#print;
terminate();
sys.exit();
| Python |
#
# jruby examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import SolvableRing, SolvPolyRing, PolyRing, RingElem
from jas import QQ, startLog, SLC
# 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];
fl = [ z**2 + y, x];
ff = pz.ideal("",fl);
print "ideal ff: " + str(ff);
print;
ff = ff.twosidedGB();
print "ideal ff: " + str(ff);
print;
f0 = SLC(ff,z + x + y + 1);
print "f0 = " + str(f0);
#f1 = SLC(ff, z-y+1 );
#f1 = SLC(ff, y*z+1 );
f1 = SLC(ff, y*z+x+1 );
print "f1 = " + str(f1);
f2 = f1*f0;
print "f2 = f1*f0: " + str(f2);
print;
fi = 1/f1;
print "fi = " + str(fi);
fi1 = fi*f1;
f1i = f1*fi;
print "fi*f1 = " + str(fi1);
print "f1*fi = " + str(f1i);
print;
f2i = f2*fi;
fi2 = fi*f2;
print "f2*fi = " + str(f2i);
print "fi*f2 = " + str(fi2);
print "f2*fi != f0: " + str(f2i != f0);
print "fi*f2 == f0: " + str(fi2 == f0);
print;
#exit(0);
pzc = f0.ring;
print "SolvableLocalRing: " + str(pzc.toScript()) + ", assoz: " + str(pzc.isAssociative());
print "gens =" + str([ str(f) for f in pzc.generators() ]);
print;
pct = PolyRing(pzc,"t,u");
#is automatic: [one,y,z,t] = p.gens(); # no x
#exit(0);
trelations = [t, y, y * t + y,
t, z, z * t - z
];
print "trelations: = " + str([ str(f) for f in trelations ]);
print;
#startLog();
pt = SolvPolyRing(pzc, "t,u", PolyRing.lex, trelations);
print "SolvPolyRing: " + str(pt);
print "sp.gens =" + str([ str(f) for f in pt.gens() ]);
#is automatic: one,y,z,t = rp.gens(); # no x
print;
#exit(0);
a = t**2 + y;
b = t + y + 1;
c = z*t**2 - y * t - z;
print "a = " + str(a);
print "b = " + str(b);
print "c = " + str(c);
#c = c.monic();
#print "c = " + str(c);
print
ff = [ a*c, b*c, (a+b)*c ];
print "ff = " + str([ str(f) for f in ff ]);
print
ii = pt.ideal( "", ff );
print "SolvableIdeal: " + str(ii);
print;
#exit(0);
startLog();
rgl = ii.leftGB();
print "seq left GB: " + str(rgl);
print "isLeftGB: " + str(rgl.isLeftGB());
print;
#p = RingElem(rgl.list.get(0));
p = RingElem(rgl.list[0]);
print "p = " + str(p);
print "c = " + str(c);
print "c-p = " + str(c-p);
d = c.monic();
print "d = " + str(d);
print "d-p = " + str(d-p);
#print "monic(p) = " + str(p.monic());
#pp = p * p;
#print "p*p = " + str(pp);
#print "p*y*z = " + str(p*y*z);
#print "p*t = " + str(p*t);
#print "t*p = " + str(t*p);
print;
#exit(0);
#no: fl = [ p, p*x ]; # x non existent
#no: fl = [ p, p*z ];
#bad: fl = [ p, p*t, p*p ];
#bad: fl = [ p, p*p ];
#fl = [ p, p*t ];
#fl = [ p ];
#fl = [ t*p, (t*t+1)*p, (t*t-t)*p ];
fl = [ t*c, (t*t+1)*c, (t*t-t)*c ];
print "fl = " + str([ str(f) for f in fl ]);
print
iil = pt.ideal( "", fl );
print "SolvableIdeal_local: " + str(iil);
print;
rgll = iil.leftGB();
print "seq left GB: " + str(rgll);
print "isLeftGB: " + str(rgll.isLeftGB());
print;
#q = RingElem(rgll.list.get(0));
q = RingElem(rgll.list[0]);
print "p = " + str(p);
print "q = " + str(q);
print "q-p = " + str(q-p);
print "c = " + str(c);
print "c-q = " + str(c-q);
print "d = " + str(d);
print "d-q = " + str(d-q);
print;
#exit(0);
# back to p:
#flu = [ p, 1-sigma^{-deg}(lc(p))*u ];
#flu = [ p, u-1 ];
#flu = [ c, c.lc() * u-1 ];
flu = [ c, u-1 ];
print "flu = [" + str([ str(f) for f in flu ]);
print
lu = pt.ideal( "", flu );
print "SolvableIdeal_local: " + str(lu);
print;
llu = lu.leftGB();
print "seq left GB: " + str(llu);
print "isLeftGB: " + str(llu.isLeftGB());
print;
s = RingElem(llu.list[0]);
print "s = " + str(s);
print;
| Python |
#
# 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: real roots over Q
r = PolyRing(QQ(),"I,x,y,z",PolyRing.lex);
print "Ring: " + str(r);
print;
[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;
F = r.ideal( list=[f1,f2,f3] );
print "F = ", F;
print;
startLog();
G = F.GB();
print "G = ", G;
print;
#terminate();
#sys.exit();
r = PolyRing(QQ(),"x,y",PolyRing.lex);
print "Ring: " + str(r);
print;
[one,x,y] = r.gens();
# y**3 - 3 * I * x * y**2 - 3 * x**2 * y + I * x**3 - 2 * I = z**3 - 2
#fr = y**3 - 3 * x**2 * y;
#fi = -3 * x * y**2 + x**3 - 2;
# y**3 - 3 * I * x * y**2 - 3 * x**2 * y + I * x**3 + 2 = z**3 - 2 I
fr = y**3 - 3 * x**2 * y - 2;
fi = -3 * x * y**2 + x**3;
print "fr = ", fr;
print "fi = ", fi;
print;
F = r.ideal( list=[fr,fi] );
print "F = ", F;
print;
G = F.GB();
print "G = ", G;
print;
t = System.currentTimeMillis();
R = G.realRoots();
t = System.currentTimeMillis() - t;
print "R = ", R;
print;
print "real roots: ";
G.realRootsPrint()
print "real roots time =", t, "milliseconds";
print;
print "G = ", G;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import PolyRing, Ideal, ZZ
from jas import startLog, terminate
# tuzun, e-gb example
r = PolyRing(ZZ(), "(t)" );
print "Ring: " + str(r);
[one,t] = r.gens();
print "one: " + str(one);
print "t: " + str(t);
print;
f1 = 2 * t + 1;
f2 = t**2 + 1;
F = [f1,f2];
I = r.ideal( list=F );
print "Ideal: " + str(I);
print;
#startLog();
G = I.eGB();
print "seq e-GB:", G;
print "is e-GB:", G.iseGB();
print;
p = f1 + 2*f2 - f1*f2 + f1**4;
print "p:", p;
n = G.eReduction(p);
print "n:", n;
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import PolyRing, QQ, RF
from jas import Ideal
from jas import startLog
from jas import terminate
# Montes JSC 2002, 33, 183-208, example 11.4
# integral function coefficients
R = PolyRing( PolyRing(QQ(),"Q2, P2, Q1, P1",PolyRing.lex), "f3, e3, f2, e2", PolyRing.lex );
print "Ring: " + str(R);
print;
[one, Q2, P2, Q1, P1, f3, e3, f2, e2] = R.gens();
print "gens: ", [ str(f) for f in R.gens() ];
print;
fp1 = 14 - 12 * e2 - 110 * f2 - 2 * e3 - 10 * f3 - P1;
fp2 = 2397 - 2200 * e2 + 240 * f2 - 200 * e3 + 40 * f3 - 20 * Q1;
fp3 = 16 * e2**2 - 4 * e2 * e3 - 20 * e2 * f3 + 20 * e3 * f2 + 16 * f2**2 - 4 * f2 * f3 - 12 * e2 + 110 * f2 - P2;
fp4 = 2599 * e2**2 - 400 * e2 * e3 + 80 * e2 * f3 - 80 * e3 * f2 + 2599 * f2**2 - 400 * f2 * f3 - 2200 * e2 - 240 * f2 - 20 * Q2;
print "fp1: " + str(fp1);
print "fp2: " + str(fp2);
print "fp3: " + str(fp3);
print "fp4: " + str(fp4);
print;
F = [fp1,fp2,fp3,fp4];
print "F: ", [ str(f) for f in F ];
print;
startLog();
If = R.paramideal( "", list = F );
print "ParamIdeal: " + str(If);
print;
## G = If.GB();
## print "GB: " + str(G);
## print;
GS = If.CGBsystem();
GS = If.CGBsystem();
GS = If.CGBsystem();
print "CGBsystem: " + str(GS);
print;
bg = GS.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
terminate();
sys.exit();
CG = If.CGB();
print "CGB: " + str(CG);
print;
bg = CG.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#------------------------------------------
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
## \begin{PossoExample}
## \Name{Hawes2}
## \Parameters{a;b;c}
## \Variables{x;y[2];z[2]}
## \begin{Equations}
## x+2y_1z_1+3ay_1^2+5y_1^4+2cy_1 \&
## x+2y_2z_2+3ay_2^2+5y_2^4+2cy_2 \&
## 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 Ideal
from jas import startLog
from jas import terminate
#startLog();
# Hawes & Gibson example 2
# rational function coefficients
#r = Ring( "RatFunc(a, c, b) (y2, y1, z1, z2, x) L" );
r = PolyRing( RF(PolyRing(ZZ(),"a, c, b",PolyRing.lex)), "y2, y1, z1, z2, x", PolyRing.lex );
print "Ring: " + str(r);
print;
ps = """
(
( x + 2 y1 z1 + { 3 a } y1^2 + 5 y1^4 + { 2 c } y1 ),
( x + 2 y2 z2 + { 3 a } y2^2 + 5 y2^4 + { 2 c } y2 ),
( 2 z2 + { 6 a } y2 + 20 y2^3 + { 2 c } ),
( 3 z1^2 + y1^2 + { b } ),
( 3 z2^2 + y2^2 + { b } )
)
""";
f = r.ideal( ps );
print "Ideal: " + str(f);
print;
startLog();
o = f.optimize();
print "optimized Ideal: " + str(o);
print;
p = o.paramideal();
p = p.optimizeCoeffQuot();
print "optimized coeff Ideal: " + str(p);
print;
#rg = o.GB();
#print "GB:", rg;
#print;
rg = p;
bg = rg.isGB();
print "isGB:", bg;
print;
terminate();
#sys.exit();
| Python |
#
# jython for jas example 3 integer programming.
# $Id$
#
# CLO2, p374,a,b
# 3 A + 2 B + C + D = 10
# 4 A + B + C = 5
#
# max: 2 A + 3 B + C + 5 D
#
import sys;
from jas import Ring
from jas import Ideal
#r = Ring( "Rat(w1,w2,w3,w4,z1,z2) W( (0,0,0,0,1,1),(-2,-3,-1,-5,0,0) )" );
#r = Ring( "Rat(w1,w2,w3,w4,z1,z2) W( (0,0,0,0,1,1),( 7, 3, 2, 1,0,0)*6 )" );
r = Ring( "Rat(w1,w2,w3,w4,z1,z2) W( (0,0,0,0,1,1),(40,15,11, 1,0,0) )" );
print "Ring: " + str(r);
print;
ps = """
(
( z1^3 z2^4 - w1 ),
( z1^2 z2 - w2 ),
( z1 z2 - w3 ),
( z1 - w4 )
)
""";
f = Ideal( r, ps );
print "Ideal: " + str(f);
print;
rg = f.GB();
print "seq Output:", rg;
print;
pf = """
(
( z1^10 z2^5 ),
( z1^20 z2^14 )
)
""";
fp = Ideal( r, pf );
print "Ideal: " + str(fp);
print;
nf = fp.NF(rg);
print "NFs: " + str(nf);
print;
#rg = f.parGB(2);
#print "par Output:", rg;
#print;
#f.distClient(); # starts in background
#rg = f.distGB(2);
#print "dist Output:", rg;
#print;
#sys.exit();
| Python |
#
# jython examples for jas.
from jas import SolvableModule
from jas import SolvableSubModule
# Quantum plane example
rsan = """
# not with twosidedGB, because of field
AN[ (i) (i^2 + 1) ] (Y,X,x,y) G
RelationTable
(
( y ), ( x ), ( {i} x y )
( X ), ( Y ), ( {i} Y X )
)
""";
rsc = """
# not supported: C(Y,X,x,y) G |2|
C(Y,X,x,y) G
RelationTable
(
( y ), ( x ), ( 0i1 x y )
( X ), ( Y ), ( 0i1 Y X )
)
""";
r = SolvableModule( rsc );
#r = SolvableModule( rsan );
print "SolvableModule: " + str(r);
print;
ps = """
(
( ( x + 1 ), ( y ) ),
( ( x y ), ( 0 ) ),
( ( x - X ), ( x - X ) ),
( ( y - Y ), ( y - Y ) )
)
""";
f = SolvableSubModule( r, ps );
print "SolvableSubModule: " + str(f);
print;
flg = f.leftGB();
print "seq left GB:", flg;
print;
if flg.isLeftGB():
print "is left GB";
else:
print "is not left GB";
ftg = f.twosidedGB();
print "seq twosided GB:", ftg;
print;
if ftg.isLeftGB():
print "twosided GB is left GB";
else:
print "twosided GB is not left GB";
if ftg.isRightGB():
print "twosided GB is right GB";
else:
print "twosided GB is not right GB";
if ftg.isTwosidedGB():
print "is twosided GB";
else:
print "is not twosided GB";
from jas import startLog
startLog();
frg = f.rightGB();
print "seq right GB:", frg;
print;
if frg.isRightGB():
print "is right GB";
else:
print "is not right GB";
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import SolvableRing
from jas import startLog, terminate
# WA_32 example
rs = """
# solvable polynomials, Weyl algebra A_3,2:
Rat(a,b,e1,e2,e3) G
RelationTable
(
( e3 ), ( e1 ), ( e1 e3 - e1 ),
( e3 ), ( e2 ), ( e2 e3 - e2 )
)
""";
r = SolvableRing( rs );
print "SolvableRing: " + str(r);
print;
ps = """
(
( e1 e3^3 + e2^10 - a ),
( e1^3 e2^2 + e3 ),
( e3^3 + e3^2 - b )
)
""";
f = r.ideal( ps );
print "SolvableIdeal: " + str(f);
print;
startLog();
rg = f.leftGB();
print "seq left GB:", rg;
print;
if rg.isLeftGB():
print "is left GB";
else:
print "is not left GB";
threads = 2;
rg = f.parLeftGB(threads); # 2 threads
print "par left GB:", rg;
print;
if rg.isLeftGB():
print "is left GB";
else:
print "is not left GB";
#sys.exit();
rg = f.twosidedGB();
print "seq twosided GB:", rg;
print;
if rg.isLeftGB():
print "twosided GB is left GB";
else:
print "twosided GB is not left GB";
if rg.isRightGB():
print "twosided GB is right GB";
else:
print "twosided GB is not right GB";
if rg.isTwosidedGB():
print "is twosided GB";
else:
print "is not twosided GB";
rg = f.parTwosidedGB(threads);
print "par twosided GB:", rg;
print;
if rg.isLeftGB():
print "twosided GB is left GB";
else:
print "twosided GB is not left GB";
if rg.isRightGB():
print "twosided GB is right GB";
else:
print "twosided GB is not right GB";
if rg.isTwosidedGB():
print "is twosided GB";
else:
print "is not twosided GB";
rg = f.rightGB();
print "seq right GB:", rg;
print;
if rg.isRightGB():
print "is right GB";
else:
print "is not right GB";
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import PolyRing, QQ
from jas import terminate
from jas import startLog
# polynomial examples: factorization
cr = PolyRing(QQ(),"x",PolyRing.lex );
print "Ring cr: " + str(cr);
r = PolyRing(cr,"y,z",PolyRing.lex );
print "Ring: " + str(r);
print;
[one,x,y,z] = r.gens();
#f = z * ( y + 1 )**2 * ( x**2 + x + 1 )**3;
#f = z * ( y + 1 ) * ( x**2 + x + 1 );
#f = ( y + 1 ) * ( x**2 + x + 1 );
#f = ( y + z**2 ) * ( x**2 + x + 1 );
#f = x**4 * y + x**3 + z + x + z**2 + y * z**2;
## f = x**3 + ( ( y + 2 ) * z + 2 * y + 1 ) * x**2 \
## + ( ( y + 2 ) * z**2 + ( y**2 + 2 * y + 1 ) * z + 2 * y**2 + y ) * x \
## + ( y + 1 ) * z**3 + ( y + 1 ) * z**2 + ( y**3 + y**2 ) * z + y**3 + y**2;
f = ( x + y * z + y + z + 1 ) * ( x**2 + ( y + z ) * x + y**2 + z**2 );
#f = ( x + y * z + y + z + 1 ) * ( x**2 + ( y + z ) * x + y**2 + 1 );
#f = ( x + y ) * ( x - y);
print "f = ", f;
print;
startLog();
t = System.currentTimeMillis();
G = r.factors(f);
t = System.currentTimeMillis() - t;
print "#G = ", len(G);
#print "factor time =", t, "milliseconds";
g = one;
for h, i in G.iteritems():
print "h**i = (", h, ")**" + str(i);
h = h**i;
g = g*h;
#print "g = ", g;
if cmp(f,g) == 0:
print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
print "factor time =", t, "milliseconds,", "isFactors(f,g): ", cmp(f,g);
print;
#startLog();
terminate();
| Python |
import sys;
from jas import Ring, PolyRing, ParamIdeal, QQ, ZM, RR
from jas import startLog, terminate
# Boolean coefficient boolean GB
# see S. Inoue and A. Nagai "On the Implementation of Boolean Groebner Bases" in ASCM 2009
# Z_2 regular ring coefficent example
r = PolyRing(RR(ZM(2),3),"a,x,y",PolyRing.lex);
print "r = " + str(r);
#print len(r.gens())
[s1,s2,s3,a,x,y] = r.gens();
one = r.one();
print "one = " + str(one);
print "s1 = " + str(s1);
print "s2 = " + str(s2);
print "s3 = " + str(s3);
print "a = " + str(a);
print "x = " + str(x);
print "y = " + str(y);
#brel = [ a**2 - a, x**2 - x, y**2 - y ];
brel = [ x**2 - x, y**2 - y ];
#print "brel = " + str(brel[0]) + ", " + str(brel[1]) + ", " + str(brel[2]);
print "brel = " + str(brel[0]) + ", " + str(brel[1]);
pl = [ ( one + s1 + s2 ) * ( x*y + x + y ), s1 * x + s1, a * y + a, x * y ];
pl = pl + brel;
startLog();
f = ParamIdeal(r,list=pl);
print "Ideal: " + str(f);
gb = f.regularGB();
print "boolean GB: " + str(gb);
#ss = gb.stringSlice();
#print "regular string slice: " + str(ss);
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import SolvableRing
from edu.jas.application import Ideal
# U_t, dim 2 and WA_1 example
rs1 = """
# solvable polynomials, U_t, dim_2 and Weyl algebra A_1:
Rat(D,X,a,b) G|2|
RelationTable
(
( b ), ( a ), ( a b + %s a )
( X ), ( D ), ( D X + 1 )
)
""";
rs1c = """
# solvable polynomials, Weyl algebra A_1:
Rat(D,X) G
RelationTable
(
( X ), ( D ), ( D X + 1 )
)
""";
rs2 = """
# solvable polynomials, U_t, dim_2 and Weyl algebra A_1:
Rat(a,b,D,X) G|2|
RelationTable
(
( b ), ( a ), ( a b + %s a )
( X ), ( D ), ( D X + 1 )
)
""";
rs2c = """
# solvable polynomials, U_t, dim_2:
Rat(a,b) G
RelationTable
(
( b ), ( a ), ( a b + %s a )
)
""";
ps = """
(
( a - X^%s ),
( b - D X + %s )
)
""";
for t in (2,3,5,7,11,13,17,19,23,27,31,37,43):
#for t in (5,7):
r1 = SolvableRing( rs1 % t );
r1c = SolvableRing( rs1c );
#print "SolvableRing: " + str(r1);
#print "SolvableRing: " + str(r1c);
#print;
it = r1.ideal( ps % (t,t) );
#print "SolvableIdeal: " + str(it);
#print;
# compute I_{\phi_t} \cap WA_1^opp
x = it.leftGB();
print "seq left x:", x;
y = Ideal(x.pset).intersect(r1c.ring);
len = y.list.size();
print "seq left y: ", y;
print "seq left y len: ", len;
#print;
#-------------------------------------
r2 = SolvableRing( rs2 % t );
r2c = SolvableRing( rs2c % t );
#print "SolvableRing: " + str(r2);
#print "SolvableRing: " + str(r2c);
#print;
ikt = r2.ideal( ps % (t,t) );
#print "SolvableIdeal: " + str(ikt);
print;
# compute ker(\phi_t)
x = ikt.leftGB();
print "seq left x:", x;
y = Ideal(x.pset).intersect(r2c.ring);
len = y.list.size();
print "seq left y: ", y;
print "seq left y len: ", len;
#print;
#-------------------------------------
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate
# Nabashima, ISSAC 2007, example F7
# integral function coefficients
r = Ring( "IntFunc(a, b) (z,y,x) G" );
print "Ring: " + str(r);
print;
ps = """
(
( x^3 - { a } ),
( y^4 - { b } ),
( x + y - { a } z )
)
""";
#startLog();
f = r.paramideal( ps );
print "ParamIdeal: " + str(f);
print;
gs = f.CGBsystem();
gs = f.CGBsystem();
gs = f.CGBsystem();
gs = f.CGBsystem();
print "CGBsystem: " + str(gs);
print;
bg = gs.isCGBsystem();
if bg:
print "isCGBsystem: true";
else:
print "isCGBsystem: false";
print;
#sys.exit();
gs = f.CGB();
print "CGB: " + str(gs);
print;
bg = gs.isCGB();
if bg:
print "isCGB: true";
else:
print "isCGB: false";
print;
terminate();
#------------------------------------------
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import SolvableRing
from jas import startLog, terminate
from edu.jas.application import Ideal
# U_sl_2 and WA_1 example
rs1 = """
# solvable polynomials, U_sl_2 and Weyl algebra A_1:
Rat(D,X,e,f,h) G|3|
RelationTable
(
( f ), ( e ), ( e f - h ),
( h ), ( e ), ( e h + 2 e ),
( h ), ( f ), ( f h - 2 f ),
( X ), ( D ), ( D X + 1 )
)
""";
rs1c = """
# solvable polynomials, Weyl algebra A_1:
Rat(D,X) G
RelationTable
(
( X ), ( D ), ( D X + 1 )
)
""";
rs2 = """
# solvable polynomials, U_sl_2 and Weyl algebra A_1:
Rat(e,f,h,D,X) G|2|
RelationTable
(
( f ), ( e ), ( e f - h ),
( h ), ( e ), ( e h + 2 e ),
( h ), ( f ), ( f h - 2 f ),
( X ), ( D ), ( D X + 1 )
)
""";
rs2c = """
# solvable polynomials, U_sl_2:
Rat(e,f,h) G
RelationTable
(
( f ), ( e ), ( e f - h ),
( h ), ( e ), ( e h + 2 e ),
( h ), ( f ), ( f h - 2 f )
)
""";
ps = """
(
( e - X ),
( f + D^2 X ),
( h - 2 D X )
)
""";
startLog();
r1 = SolvableRing( rs1 );
r1c = SolvableRing( rs1c );
#print "SolvableRing: " + str(r1);
#print "SolvableRing: " + str(r1c);
print;
it = r1.ideal( ps );
print "SolvableIdeal: " + str(it);
print;
# compute I_{\phi_t} \cap WA_1^opp
x = it.leftGB();
print "seq left x:", x;
y = Ideal(x.pset).intersect(r1c.ring);
len = y.list.size();
print "seq left y: ", y;
print "seq left y len: ", len;
print;
#-------------------------------------
r2 = SolvableRing( rs2 );
r2c = SolvableRing( rs2c );
#print "SolvableRing: " + str(r2);
#print "SolvableRing: " + str(r2c);
print;
ikt = r2.ideal( ps );
print "SolvableIdeal: " + str(ikt);
print;
# compute ker(\phi_t)
x = ikt.leftGB();
print "seq left x:", x;
y = Ideal(x.pset).intersect(r2c.ring);
len = y.list.size();
print "seq left y: ", y;
print "seq left y len: ", len;
print;
#-------------------------------------
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import Ring
from jas import Ideal
from jas import terminate
from jas import startLog
# polynomial examples: gcd
#r = Ring( "Mod 1152921504606846883 (x,y,z) L" );
#r = Ring( "Rat(x,y,z) L" );
#r = Ring( "C(x,y,z) L" );
r = Ring( "Z(x,y,z) L" );
print "Ring: " + str(r);
print;
[one,x,y,z] = r.gens();
a = r.random();
b = r.random();
c = abs(r.random());
#c = 1;
#a = 0;
f = x * a + b * y**2 + one * z**7;
print "a = ", a;
print "b = ", b;
print "c = ", c;
print "f = ", f;
print;
ac = a * c;
bc = b * c;
print "ac = ", ac;
print "bc = ", bc;
print;
t = System.currentTimeMillis();
g = r.gcd(ac,bc);
t = System.currentTimeMillis() - t;
print "g = ", g;
#print "gcd time =", t, "milliseconds";
d = r.gcd(g,c);
if cmp(c,d) == 0:
print "gcd time =", t, "milliseconds,", "isGcd(c,d): true" ;
else:
print "gcd time =", t, "milliseconds,", "isGcd(c,d): ", cmp(c,d);
print;
#d = g / c;
#m = g % c;
#print "d = ", d;
#print "m = ", m;
#print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring, PolyRing, RF, ZZ, ZM
from jas import Ideal
from jas import startLog
from jas import terminate
#startLog();
# Lewis example
# integral function coefficients
#r = Ring( "IntFunc(a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3,e1,e2,e3) (t1,t2,t3) G" );
#r = Ring( "RatFunc(a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3,e1,e2,e3) (t1,t2,t3) G" );
r = PolyRing( RF(PolyRing(ZZ(),"a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3,e1,e2,e3",PolyRing.lex)), "t1,t2,t3", PolyRing.grad );
#r = PolyRing( RF(PolyRing(ZM(163),"a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3,e1,e2,e3",PolyRing.lex)), "t1,t2,t3", PolyRing.grad );
print "Ring: " + str(r);
print;
ps = """
(
( { a1 } * t1^2 * t2^2 + { b1 } * t1^2 + { 2 c1 } * t1 * t2 + { d1 } * t2^2 + { e1 } ),
( { a2 } * t2^2 * t3^2 + { b2 } * t2^2 + { 2 c2 } * t2 * t3 + { d2 } * t3^2 + { e2 } ),
( { a3 } * t1^2 * t3^2 + { b3 } * t1^2 + { 2 c3 } * t1 * t3 + { d3 } * t3^2 + { e3 } )
)
""";
#a1 = e2 + s22
#+ s27
#- s25
#- 2e * s2 + 2e * s7 - 2s2 * s7
f = r.ideal( ps );
print "ParamIdeal: " + str(f);
print;
sys.exit();
startLog();
rg = f.GB();
#rg = f.GB();
print "GB:", rg;
print;
bg = rg.isGB();
print "isGB:", bg;
print;
#startLog();
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import PolyRing, QQ, ZM
from jas import terminate
from jas import startLog
# polynomial examples: squarefree: characteristic p, finite
#r = PolyRing(QQ(),"x, y, z",PolyRing.lex)
r = PolyRing(ZM(5,field=True),"x, y, z",PolyRing.lex)
print "Ring: " + str(r);
print;
[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;
f = a**10 * b**5 * c;
print "a = ", a;
print "b = ", b;
print "c = ", c;
print "f = ", f;
print;
t = System.currentTimeMillis();
F = r.squarefreeFactors(f);
t = System.currentTimeMillis() - t;
print "factors:";
for g in F.keys():
i = F[g];
print "g = %s**%s" % (g,i);
print
print "factor time =", t, "milliseconds";
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
from java.lang import System
from java.lang import Integer
from jas import PolyRing, AN, QQ
from jas import Ideal
from jas import terminate
from jas import startLog
# polynomial examples: factorization over Q(i)
#r = Ring( "AN[ (i) (i^2 + 1) ] (x) L" );
#r = Ring( "AN[ (a) (4 a^2 + 1) ] (x) L" );
#r = Ring( "AN[ (a) (a^4 + 2 a^2 - 4 a + 2) ] (x) L" );
#print "Ring: " + str(r);
#print;
Qr = PolyRing(QQ(),"i",PolyRing.lex);
print "Qr = " + str(Qr);
[e,a] = Qr.gens();
print "e = " + str(e);
print "a = " + str(a);
imag = a**2 + 1;
print "imag = " + str(imag);
Qi = AN(imag,field=True);
print "Qi = " + str(Qi.factory());
[one,i] = Qi.gens();
print "one = " + str(one);
print "i = " + str(i);
b = i**2 + 1;
print "b = " + str(b);
c = 1 / i;
print "c = " + str(c);
#Qix = AN(i**2 + 1);
#print "Qix = " + str(Qix.factory());
print;
r = PolyRing(Qi,"x",PolyRing.lex)
print "r = " + str(r);
[one,i,x] = r.gens();
print "one = " + str(one);
print "i = " + str(i);
print "x = " + str(x);
#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) + 3 * x**(2*11) - x**(11);
#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;
#f = x**8 - 40 * x**6 + 352 * x**4 - 960 * x**2 + 576;
#f = 362408718672000 * x**9 + 312179013226080 * x**8 - 591298435728000 * x**6 - 509344705789920 * x**5 - 1178946881112000 * x**2 - 4170783473878580 * x - 2717923400363451;
#f = 292700016000 * x**8 + 614670033600 * x**7 - 417466472400 * x**6 - 110982089400 * x**5 + 1185906158780 * x**4 - 161076194335 * x**3 + 204890011200 * x**2 - 359330651400 * x - 7719685302;
#f = x**10 - 212 * x**9 - 1760 * x**8 + 529 * x**7 - 93699 * x**6 - 726220 * x**5 + 37740 * x**4 + 169141 * x**3 + 24517680 * x**2 - 9472740;
#f = x**4 + 1;
#f = x**3 - x**2 + x - 1;
#f = x**8 + 4 * x**6 + 8 * x**4 - 8 * x**2 + 4;
f = x**6 - 5 * x**4 + 5 * x**2 + 4;
# ==
f = ( x**3 + 2 * i * x**2 - 3 * x - 4 * i ) * ( x**3 - 2 * i * x**2 - 3 * x + 4 * i );
#f = ( x**3 + ( 2 * i ) * x**2 - ( 3 ) * x - ( 4 * i ) ) * ( x**3 - ( 2 * i ) * x**2 - ( 3 ) * x + ( 4 * i ) );
#f = x**16 + 272 * x**12 - 7072 * x**8 + 3207424 * x**4 + 12960000;
#f = x**16 + 16 * x**12 + 96 * x**8 + 256 * x**4 + 256;
#f = x**24 + 272 * x**20 - 7072 * x**16 + 3207424 * x**12 + 12960000 * x**8;
print "f = ", f;
print;
startLog();
t = System.currentTimeMillis();
#G = r.squarefreeFactors(f);
G = r.factors(f);
t = System.currentTimeMillis() - t;
print "#G = ", len(G);
#print "factor time =", t, "milliseconds";
g = one;
for h, i in G.iteritems():
print "h**i = (", h, ")**" + str(i);
h = h**i;
g = g*h;
#print "g = ", g;
if cmp(f,g) == 0:
print "factor time =", t, "milliseconds,", "isFactors(f,g): true" ;
else:
print "factor time =", t, "milliseconds,", "isFactors(f,g): ", cmp(f,g);
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys
from java.lang import System
from jas import PolyRing, ZM, QQ, RF
from jas import terminate
from jas import startLog
# polynomial examples: factorization over Z_p
p = 5;
cr = PolyRing(ZM(p,field=True),"u",PolyRing.lex );
print "Ring cr: " + str(cr);
[one,u] = cr.gens();
fu = (u**2+u+1)**p;
print "fu = ", fu;
t = System.currentTimeMillis();
G = cr.squarefreeFactors(fu);
t = System.currentTimeMillis() - t;
#print "G = ", G; #.toScript();
print "factor time =", t, "milliseconds";
for h, i in G.iteritems():
print "h**i = (", h, ")**" + str(i);
h = h**i;
print;
qcr = RF(cr);
print "Ring qcr: " + str(qcr.factory());
#not ok#r = PolyRing(cr,"x",PolyRing.lex );
r = PolyRing(qcr,"x",PolyRing.lex );
print "Ring r: " + str(r);
#qr = RF(r);
#print "Ring qr: " + str(qr.factory());
print;
[one,u,x] = r.gens();
print "one = " + str(one);
print "u = " + str(u);
print "x = " + str(x);
#f = x**3 - u;
#f = (x - u)**3;
#f = (x - u**3)**3;
#f = (x - u**9)**3;
#f = x**p - u;
#f = (x - u)**p;
p2 = p * 2;
fu = (u**2+u+1)**p;
#f = x**p + 1/fu;
f = x**p + fu;
#f = x**p2 - fu * x**p - fu;
#f = x**p2 + x**p + 1;
#f = x**p2 + 1;
print "f = ", f;
print;
startLog();
t = System.currentTimeMillis();
G = r.squarefreeFactors(f);
#G = r.factorsAbsolute(f);
#G = None;
t = System.currentTimeMillis() - t;
#print "G = ", G; #.toScript();
print "factor time =", t, "milliseconds";
for h, i in G.iteritems():
print "h**i = (", h, ")**" + str(i);
h = h**i;
print;
gu = u**2+u+1;
#g = (x + 1/gu);
g = (x + gu);
print "g = ", g;
g = g**p;
print "g**p = ", g;
print;
terminate();
| Python |
#
# 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, startLog, noThreads
from jas import QQ, ZM, RF, AN
# polynomial examples: ideal radical decomposition, modified from example 8.16 in GB book
# noThreads(); # must be called very early
prime = 5;
cf = ZM(prime);
#cf = QQ();
ca = PolyRing(cf,"a",PolyRing.lex);
#print "ca = " + str(ca);
[ea,aa] = ca.gens();
print "ea = " + str(ea);
print "aa = " + str(aa);
print;
#!#roota = aa**prime + 2;
roota = aa**2 + 2;
print "roota = " + str(roota);
Q3a = AN(roota,field=True);
print "Q3a = " + str(Q3a.factory());
## Q3a = RF(ca);
#print Q3a.gens();
[ea2,aa2] = Q3a.gens();
print "ea2 = " + str(ea2);
print "aa2 = " + str(aa2);
print;
#cr = PolyRing(QQ(),"t",PolyRing.lex);
cr = PolyRing(Q3a,"t",PolyRing.lex);
print "coefficient Ring: " + str(cr);
rf = RF(cr);
print "coefficient quotient Ring: " + str(rf.ring.toScript());
r = PolyRing(rf,"x,y",PolyRing.lex);
print "Ring: " + str(r);
#print;
[one,a,t,x,y] = r.gens();
#print one,a,t,x,y;
print "one = " + str(one);
print "a = " + str(a);
print "t = " + str(t);
print "x = " + str(x);
print "y = " + str(y);
print;
#sys.exit();
#f1 = x**prime - t;
#f2 = y**prime - t;
##f1 = x**4 + t;
##f2 = y**4 + t;
f1 = x**3 + t;
f2 = y**3 + t;
#f2 = f2**2;
f3 = (y-x);
f3 = f3**prime;
print "f1 = ", f1;
print "f2 = ", f2;
#print "f3 = ", f3;
print;
F = r.ideal( list=[f1,f2] );
print "F = ", F;
print;
startLog();
t = System.currentTimeMillis();
R = F.radicalDecomp();
#R = F.primeDecomp();
t = System.currentTimeMillis() - t;
print "R = ", R;
print;
print "decomp time =", t, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring
from jas import PolyRing
from jas import Ideal
from jas import startLog
from jas import terminate
from jas import ZZ, QQ, ZM, DD, RF, CC
#r = Ring( "Mod 19 (B,S,T,Z,P,W) L" );
#r = Ring( "Mod 1152921504606846883 (B,S,T,Z,P,W) L" ); # 2^60-93
#r = Ring( "Quat(B,S,T,Z,P,W) L" );
#r = Ring( "Z(B,S,T,Z,P,W) L" );
#r = Ring( "C(B,S,T,Z,P,W) L" );
#r = Ring( "IntFunc(e,f)(B,S,T,Z,P,W) L" );
#r = Ring( "Z(B,S,T,Z,P,W) L" );
#r = Ring( "Q(B,S,T,Z,P,W) L" );
#print "Ring: " + str(r);
#print;
#r = PolyRing(ZZ(),"B,S,T,Z,P,W",PolyRing.lex);
#r = PolyRing(QQ(),"B,S,T,Z,P,W",PolyRing.lex);
#r = PolyRing(CC(),"B,S,T,Z,P,W",PolyRing.lex);
#r = PolyRing(DD(),"B,S,T,Z,P,W",PolyRing.lex);
#r = PolyRing(ZM(19),"B,S,T,Z,P,W",PolyRing.lex);
#r = PolyRing(ZM(1152921504606846883),"B,S,T,Z,P,W",PolyRing.lex); # 2^60-93
#rc = PolyRing(ZZ(),"e,f",PolyRing.lex);
#rc = PolyRing(QQ(),"e,f",PolyRing.lex);
#r = PolyRing(rc,"B,S,T,Z,P,W",PolyRing.lex);
rqc = PolyRing(ZZ(),"e,f",PolyRing.lex);
print "Q-Ring: " + str(rqc);
print "rqc.gens() = ", [ str(f) for f in rqc.gens() ];
print;
[pone,pe,pf] = rqc.gens();
r = PolyRing(RF(rqc),"B,S,T,Z,P,W",PolyRing.lex);
print "Ring: " + str(r);
print;
# sage like: with generators for the polynomial ring
print "r.gens() = ", [ str(f) for f in r.gens() ];
print;
[one,e,f,B,S,T,Z,P,W] = r.gens();
#[one,B,S,T,Z,P,W] = r.gens();
#[one,I,B,S,T,Z,P,W] = r.gens();
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;
#all ok:
f1 = f1 + e;
#f7 = f7 + e * f6**0;
#f7 = f7 + 5959345574908321469098512640906154241024000000**2 * f6;
#f7 = f7 + 35555./332 * f1;
F = [ f1, f2, f3, f4, f5, f6, f7 ];
#F = [ f1, f2, f3, f4, f5, f6 ];
#print "F = ", [ str(f) for f in F ];
I = r.ideal( "", list=F );
print "Ideal: " + str(I);
print;
#sys.exit();
rg = I.GB();
print "seq Output:", rg;
print;
terminate();
sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
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: zero dimensional ideals radical decomposition
#r = Ring( "Rat(x) L" );
#r = Ring( "Q(x) L" );
r = PolyRing(QQ(),"x,y,z",PolyRing.lex);
print "Ring: " + str(r);
print;
[one,x,y,z] = r.gens();
f1 = (x**2 - 5)**2;
f2 = (y**2 - 3)**3 * (y**2 - 5);
f3 = z**3 - x * y;
print "f1 = ", f1;
print "f2 = ", f2;
print "f3 = ", f3;
print;
F = r.ideal( list=[f1,f2,f3] );
print "F = ", F;
print;
startLog();
t = System.currentTimeMillis();
R = F.radicalDecomp();
t = System.currentTimeMillis() - t;
print "R = ", R;
print;
print "decomp time =", t, "milliseconds";
print;
print "F = ", F;
print;
#startLog();
terminate();
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import Ring
from jas import Ideal
# logic example from Kreutzer JdM 2008
r = Ring( "Mod 2 (a,f,p,u) G" );
print "Ring: " + str(r);
print;
ks = """
(
( a^2 - a ),
( f^2 - f ),
( p^2 - p ),
( u^2 - u )
)
""";
ps = """
(
( p f + p ),
( p u + p + u + 1 ),
( a + u + 1 ),
( a + p + 1 )
)
""";
k = r.ideal( ks );
p = r.ideal( ps );
f = k.sum( p );
print "Ideal: " + str(f);
print;
rg = f.GB();
print "Output:", rg;
print;
| Python |
#
# jython examples for jas.
# $Id$
#
import sys;
from jas import Ring, PolyRing, Ideal
from jas import QQ, ZZ
from jas import startLog, terminate
# example: Algebraic Statistics
# Drton, Sturmfels, Sullivant, example 2.1.3
#r = PolyRing(QQ(),"l1,l2",PolyRing.grad);
r = PolyRing(QQ(),"l1,l2",PolyRing.lex);
print "Ring: " + str(r);
print;
print one,l1,l2;
u0 = 3; u1 = 5; u2 = 7; u12 = 11;
f1 = (u1+u12)*(l1+l2+2)*(l1+1)*(l1+l2+1)\
+ (u12)*l1*(l1+1)*(l1+l2+1)\
- (u2+u12)*l1*(l1+l2+2)*(l1+l2+1)\
- (u0+u1+u2+u12)*l1*(l1+l2+2)*(l1+1) ;
f2 = (u2+u12)*(l1+l2+2)*(l2+1)*(l1+l2+1)\
+ (u12)*l2*(l2+1)*(l1+l2+1)\
- (u1+u12)*l2*(l1+l2+2)*(l1+l2+1)\
- (u0+u1+u2+u12)*l2*(l1+l2+2)*(l2+1) ;
print f1;
print f2;
print
h = l1*l2*(l1+1)*(l2+1)*(l1+l2+1)*(l1+l2+2);
print h;
print
F = r.ideal(list=[f1,f2]);
print F;
print
H = r.ideal(list=[h]);
print H;
print
G = F.GB();
print G;
print
#startLog();
Q = G.sat(H);
print Q;
print
#D = Q.radicalDecomp();
#print D;
#print
R = Q.realRoots();
print R;
print
print;
#startLog();
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
## \begin{PossoExample}
## \Name{Hawes2}
## \Parameters{a;b;c}
## \Variables{x;y[2];z[2]}
## \begin{Equations}
## x+2y_1z_1+3ay_1^2+5y_1^4+2cy_1 \&
## x+2y_2z_2+3ay_2^2+5y_2^4+2cy_2 \&
## 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, ZM
from jas import Ideal
from jas import startLog
from jas import terminate
#startLog();
# Hawes & Gibson example 2
# rational function coefficients
#r = Ring( "ModFunc 17 (a, c, b) (y2, y1, z1, z2, x) G" );
r = PolyRing( PolyRing(ZM(17),"a, c, b",PolyRing.lex), "y2, y1, z1, z2, x", PolyRing.grad );
print "Ring: " + str(r);
print;
ps = """
(
( x + 2 y1 z1 + { 3 a } y1^2 + 5 y1^4 + { 2 c } y1 ),
( x + 2 y2 z2 + { 3 a } y2^2 + 5 y2^4 + { 2 c } y2 ),
( 2 z2 + { 6 a } y2 + 20 y2^3 + { 2 c } ),
( 3 z1^2 + y1^2 + { b } ),
( 3 z2^2 + y2^2 + { b } )
)
""";
f = r.ideal( ps );
print "Ideal: " + str(f);
print;
rg = f.GB();
print "GB:", rg;
print;
bg = rg.isGB();
print "isGB:", bg;
print;
terminate();
#sys.exit();
| Python |
#
# jython examples for jas.
# $Id$
#
from jas import Ring
from jas import Ideal
from edu.jas.gb import Katsura;
# katsura examples
knum = 4
tnum = 2;
#r = Ring( "Mod 19 (B,S,T,Z,P,W) L" );
#r = Ring( "Mod 1152921504606846883 (B,S,T,Z,P,W) L" ); # 2^60-93
#r = Ring( "Quat(B,S,T,Z,P,W) L" );
#r = Ring( "Z(B,S,T,Z,P,W) L" );
#r = Ring( "C(B,S,T,Z,P,W) L" );
#r = Ring( "Rat(B,S,T,Z,P,W) L" );
#print "Ring: " + str(r);
#print;
k = Katsura(knum);
r = Ring( k.varList("Rat","G") );
print "Ring: " + str(r);
print;
ps = k.polyList();
f = Ideal( r, ps );
print "Ideal: " + str(f);
print;
rg = f.parGB(tnum);
for th in range(tnum,0,-1):
rg = f.parGB(th);
#print "par Output:", rg;
#print;
rg = f.GB();
#print "seq Output:", rg;
print;
# rg = f.distGB(2);
#print "dist Output:", rg;
#print;
#f.distClient();
| Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.