コード例 #1
0
# jython examples for jas.
# $Id$
#

import sys

from java.lang import System

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

# elementary integration

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

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

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

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

#f = ( x + 3 ) / ( x**2- 3 * x - 40 );
コード例 #2
0
#

import sys

from java.lang import System

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

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

#noThreads(); # must be called very early

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

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

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

#sys.exit();

#f1 = (x**2 - 5)**2;
#f1 = (y**10 - x**5)**3;
f1 = (x**2 + 2)**2
f2 = (y**2 - x)**5
# 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 = GF(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
コード例 #4
0
from jas import QQ, ZZ, GF, RF, startLog, terminate 

startLog();

# solvable module example

#mod=17; 
mod=32003; 
#mod=536870909; 
#mod=1152921504606846883;

coeff = GF(mod)
#coeff = QQ()

p = PolyRing( 
        RF(PolyRing(coeff,"b1,c1",PolyRing.lex)), 
        "E,D1,D2,D3",PolyRing.grad);
print "PolyRing: " + str(p);
print;

relations = [
 ( D3 ), ( D1 ), ( D1 * D3 -      c1 * E + b1      * E ),
 ( D3 ), ( D2 ), ( D2 * D3 -           E +           E ),
 ( D2 ), ( D1 ), ( D1 * D2 -      c1 * E + b1      * E )
];

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

rp = SolvPolyRing( 
         RF(PolyRing(coeff,"b1,c1",PolyRing.lex)),
コード例 #5
0
ファイル: arith.py プロジェクト: lukaszzdanikowski/randoop
c = CC( (2,),rn );
print "c:", c;
print;


r = Ring( "Q(x,y) L" );
print "Ring: " + str(r);
print;

# sage like: with generators for the polynomial ring
[x,y] = r.gens();
one = r.one();
zero = r.zero();

try:
    f = RF();
except:
    f = None;
print "f: " + str(f);

d = x**2 + 5 * x - 6;
f = RF(d);
print "f: " + str(f);

n = d*d + y + 1;
f = RF(d,n);
print "f: " + str(f);
print;

# beware not to mix expressions
f = f**2 - f;
コード例 #6
0
print "zm:   " + str(zm)
print "zm^2: " + str(zm * zm)
print "1/zm: " + str(1 / zm)
#print "zm.ring: " + str(zm.ring.toScript());
print

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

# sage like: with generators for the polynomial ring
#is automatic: [one,x,y] = r.gens();
zero = r.zero()

try:
    f = RF(r)
except:
    f = None
print "f: " + str(f)

d = x**2 + 5 * x - 6
f = RF(r, d)
print "f: " + str(f)

n = d * d + y + 1
f = RF(r, d, n)
print "f: " + str(f)
print

# beware not to mix expressions
f = f**2 - f
コード例 #7
0
#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
コード例 #8
0
## 2 z_2+6ay_2+20 y_2^3+2c \&
## 3 z_1^2+y_1^2+b \&
## 3z_2^2+y_2^2+b \&
## \end{Equations}
## \end{PossoExample}

import sys

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

# Hawes & Gibson example 2
# rational function coefficients

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

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

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

p6 = ((p5 / a) / b) / c
print "p6 = ", p6
コード例 #9
0
c = CC( (2,),rn );
print "c:", c;
print;


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

# sage like: with generators for the polynomial ring
#is automatic: [one,x,y] = r.gens();
zero = r.zero();

try:
    f = RF(r);
except:
    f = None;
print "f: " + str(f);

d = x**2 + 5 * x - 6;
f = RF(r,d);
print "f: " + str(f);

n = d*d + y + 1;
f = RF(r,d,n);
print "f: " + str(f);
print;

# beware not to mix expressions
f = f**2 - f;
コード例 #10
0
ファイル: factors_mod_ins.py プロジェクト: rjolly/jas
fu = (u**2+u+1)**p;
print "fu = ", fu;
print;

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);
コード例 #11
0
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)
コード例 #12
0
#
# jython examples for jas.
# $Id$
#

from java.lang import System

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

# polynomial examples: squarefree: characteristic p, infinite

r = PolyRing(RF(PolyRing(GF(5), "u, v", PolyRing.lex)), "x y z", PolyRing.lex)
print "r = " + str(r)

#automatic: [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():
コード例 #13
0
fu = (u**2 + u + 1)**p
print "fu = ", fu
print

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)
コード例 #14
0
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 );
コード例 #15
0
# 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 = GF(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;
コード例 #16
0
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 );
コード例 #17
0
c = CC((2, ), rn)
print "c:", c
print

r = Ring("Q(x,y) L")
print "Ring: " + str(r)
print

# sage like: with generators for the polynomial ring
[x, y] = r.gens()
one = r.one()
zero = r.zero()

try:
    f = RF()
except:
    f = None
print "f: " + str(f)

d = x**2 + 5 * x - 6
f = RF(d)
print "f: " + str(f)

n = d * d + y + 1
f = RF(d, n)
print "f: " + str(f)
print

# beware not to mix expressions
f = f**2 - f
コード例 #18
0
#
# jython examples for jas.
# $Id$
#

import sys

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

# Raksanyi & Walter example
# rational function coefficients

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

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

f = r.ideal(ps)
print "Ideal: " + str(f)
print
コード例 #19
0
from java.lang import System

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

# polynomial examples: factorization over Z_p(x)(sqrt{p}(x))[y]

Q = PolyRing(ZM(5), "x", PolyRing.lex)
print "Q     = " + str(Q)
[e, a] = Q.gens()
#print "e     = " + str(e);
print "a     = " + str(a)

Qr = RF(Q)
print "Qr    = " + str(Qr.factory())
[er, ar] = Qr.gens()
#print "er    = " + str(er);
#print "ar    = " + str(ar);
print

Qwx = PolyRing(Qr, "wx", PolyRing.lex)
print "Qwx   = " + str(Qwx)
[ewx, ax, wx] = Qwx.gens()
#print "ewx   = " + str(ewx);
print "ax    = " + str(ax)
print "wx    = " + str(wx)
print

#rootx = wx**5 - 2; # not working
コード例 #20
0
Q2 = AN(root,field=True);
print "Q2    = " + str(Q2.factory());
[one,w2] = Q2.gens();
#print "one   = " + str(one);
#print "w2    = " + str(w2);
print;

Qp = PolyRing(Q2,"x",PolyRing.lex);
print "Qp    = " + str(Qp);
[ep,wp,ap] = Qp.gens();
#print "ep    = " + str(ep);
#print "wp    = " + str(wp);
#print "ap    = " + str(ap);
print;

Qr = RF(Qp);
print "Qr    = " + str(Qr.factory());
[er,wr,ar] = Qr.gens();
#print "er    = " + str(er);
#print "wr    = " + str(wr);
#print "ar    = " + str(ar);
print;

Qwx = PolyRing(Qr,"wx",PolyRing.lex);
print "Qwx   = " + str(Qwx);
[ewx,wwx,ax,wx] = Qwx.gens();
#print "ewx   = " + str(ewx);
print "ax    = " + str(ax);
#print "wwx   = " + str(wwx);
print "wx    = " + str(wx);
print;
コード例 #21
0
import sys

from java.lang import System

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

# 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

#automatic: [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
コード例 #22
0
from jas import Ring
from jas import PolyRing
from jas import Ideal
from jas import ZM, QQ, AN, RF
from jas import terminate
from jas import startLog

# polynomial examples: factorization over Z_p(x)(sqrt3(x))[y]

Q = PolyRing(ZM(5),"x",PolyRing.lex);
print "Q     = " + str(Q);
[e,a] = Q.gens();
#print "e     = " + str(e);
print "a     = " + str(a);

Qr = RF(Q);
print "Qr    = " + str(Qr.factory());
[er,ar] = Qr.gens();
#print "er    = " + str(er);
#print "ar    = " + str(ar);
print;

Qwx = PolyRing(Qr,"wx",PolyRing.lex);
print "Qwx   = " + str(Qwx);
[ewx,ax,wx] = Qwx.gens();
#print "ewx   = " + str(ewx);
print "ax    = " + str(ax);
print "wx    = " + str(wx);
print;

#rootx = wx**5 - 2; # not working
コード例 #23
0
# polynomial examples: ideal prime decomposition
# TRANSACTIONS OF THE AMERICAN MATHEMATICAL SOCIETY
# Volume 296, Number 2. August 1986
# ON THE DEPTH OF THE SYMMETRIC ALGEBRA
# J. HERZOG M. E. ROSSI AND G. VALLA

#r = PolyRing(QQ(),"x,t,z,y",PolyRing.lex);
#r = PolyRing(QQ(),"x,y,t,z",PolyRing.lex);
#r = EF(QQ()).extend("x").polynomial("y,z,t").build(); #,PolyRing.lex);
#c = PolyRing(QQ(),"t,y",PolyRing.lex);

#c = PolyRing(ZM(32003,0,True),"t",PolyRing.lex);
#c = PolyRing.new(GF(32003),"t",PolyRing.lex);
c = PolyRing(ZZ(), "t", PolyRing.lex)
r = PolyRing(RF(c), "z,y,x", PolyRing.lex)
print "Ring: " + str(r)
print

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

f1 = x**3 - y**7
f2 = x**2 * y - x * t**3 - z**6
f3 = z**2 - t**3
#f3 = z**19 - t**23;