Ejemplo n.º 1
0
# $Id: intprog4a.py 597 2006-02-12 11:16:09Z kredel $
#
# 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 )
Ejemplo n.º 2
0
# jython examples for jas.
# $Id: nabeshima_cgbF01.py 1977 2008-08-03 10:40:23Z kredel $
#

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);
Ejemplo n.º 3
0
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;
Ejemplo n.º 4
0
# jython for jas example integer programming.
# $Id: intprog.py 597 2006-02-12 11:16:09Z kredel $
#
# CLO2, p370
# 4 A + 5 B + C = 37
# 2 A + 3 B + D = 20
#
# max: 11 A + 15 B
#

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),(1,1,2,2,0,0) )")
print "Ring: " + str(r)
print

ps = """
( 
 ( z1^4 z2^2 - w1 ),
 ( z1^5 z2^3 - w2 ),
 ( z1 - w3 ),
 ( z2 - w4 )
) 
"""

f = Ideal(r, ps)
print "Ideal: " + str(f)
print
Ejemplo n.º 5
0
Archivo: syz.py Proyecto: rjolly/jas
#
# jython examples for jas.
# $Id$
#

from jas import Ring

# 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 = r.ideal( ps );
print "Ideal: " + str(f);
print;


#Katsura equations for N = 3:
Ejemplo n.º 6
0
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; 
Ejemplo n.º 7
0
#

import sys;

from jas import Ring
from jas import startLog

# example from rose (modified)

#r = Ring( "Mod 19 (U3,U4,A46) L" );
#r = Ring( "Mod 1152921504606846883 (U3,U4,A46) L" ); # 2^60-93
#r = Ring( "Quat(U3,U4,A46) L" );
#r = Ring( "Z(U3,U4,A46) L" );
#r = Ring( "C(U3,U4,A46) L" );

r = Ring( "Rat(A46,U3,U4) G" );
print "Ring: " + str(r);
print;

ps = """
(   
 ( U4^4 - 20/7 A46^2 ), 
 ( A46^2 U3^4 + 7/10 A46 U3^4 + 7/48 U3^4 - 50/27 A46^2 - 35/27 A46 - 49/216 ), 
 ( A46^5 U4^3 + 7/5 A46^4 U4^3 + 609/1000 A46^3 
 U4^3 + 49/1250 A46^2 U4^3 - 27391/800000 A46 U4^3 
 - 1029/160000 U4^3 + 3/7 A46^5 U3 U4^2 + 3/5 A46^6 
 U3 U4^2 + 63/200 A46^3 U3 U4^2 + 147/2000 A46^2 
 U3 U4^2 + 4137/800000 A46 U3 U4^2 - 7/20 A46^4 
 U3^2 U4 - 77/125 A46^3 U3^2 U4 - 23863/60000 A46^2 
 U3^2 U4 - 1078/9375 A46 U3^2 U4 - 24353/1920000 
  U3^2 U4 - 3/20 A46^4 U3^3 - 21/100 A46^3 U3^3 
Ejemplo n.º 8
0
#
# jython examples for jas.
# $Id$
#

import sys;

from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate


# ideal elimination example

r = Ring( "Rat(x,y,z) G" );
print "Ring: " + str(r);
print;

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

F1 = r.ideal( ps1 );
print "Ideal: " + str(F1);
print;
Ejemplo n.º 9
0
from jas import Ideal
from jas import startLog
from jas import terminate

#import rational;

# 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( "Z(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;

# sage like: with generators for the polynomial ring
print "r.gens() = ", [ str(f) for f in r.gens() ];
print;
#[e,f,B,S,T,Z,P,W] = r.gens();
[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;
Ejemplo n.º 10
0
# 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);
Ejemplo n.º 11
0
#

import sys;

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

# example from rose (modified)

#r = Ring( "Mod 19 (U3,U4,A46) L" );
#r = Ring( "Mod 1152921504606846883 (U3,U4,A46) L" ); # 2^60-93
#r = Ring( "Quat(U3,U4,A46) L" );
#r = Ring( "Z(U3,U4,A46) L" );
#r = Ring( "C(U3,U4,A46) L" );

r = Ring( "Rat(A46,U3,U4) L" );
print "Ring: " + str(r);
print;

ps = """
(   
 %s
 ( U4^4 - 20/7 A46^2 ), 
 ( A46^2 U3^4 + 7/10 A46 U3^4 + 7/48 U3^4 - 50/27 A46^2 - 35/27 A46 - 49/216 ), 
 ( A46^5 U4^3 + 7/5 A46^4 U4^3 + 609/1000 A46^3 
 U4^3 + 49/1250 A46^2 U4^3 - 27391/800000 A46 U4^3 
 - 1029/160000 U4^3 + 3/7 A46^5 U3 U4^2 + 3/5 A46^6 
 U3 U4^2 + 63/200 A46^3 U3 U4^2 + 147/2000 A46^2 
 U3 U4^2 + 4137/800000 A46 U3 U4^2 - 7/20 A46^4 
 U3^2 U4 - 77/125 A46^3 U3^2 U4 - 23863/60000 A46^2 
 U3^2 U4 - 1078/9375 A46 U3^2 U4 - 24353/1920000 
Ejemplo n.º 12
0
#
# 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 ),
Ejemplo n.º 13
0
rs = """
# polynomial ring:
Rat(x1,x2,x3,y1,y2) G|3|
""";

ps = """
(
 ( y1 + y2 - 1 ),
 ( x1 - y1^2 - y1 - y2 ),
 ( x2 - y1 - y2^2 ),
 ( x3 - y1 y2 )
)
""";

r = Ring( rs );
print "Ring: " + str(r);

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

g = i.GB();
print "seq GB:", g;



rsi = """
# polynomial ring:
Rat(x1,x2,x3) G
""";
Ejemplo n.º 14
0
from jas import Ring
from jas import startLog, terminate

#import rational;

# 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( "Z(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;

# 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();
#automatic: [one,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;
Ejemplo n.º 15
0
c = CC();
print "c:", c;
c = c.one();
print "c:", c;
c = CC((2,),(3,));
print "c:", c;
print "c^5:", c**5 + c.one();
print;

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;
Ejemplo n.º 16
0
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
[x] = r.gens()

one = r.one()

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
Ejemplo n.º 17
0
# $Id: hermite.py 2111 2008-09-06 19:32:49Z kredel $
#

import sys;

from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate

# hermite polynomial example
# H(0) = 1
# H(1) = 2 * x
# H(n) = 2 * x * H(n-1) - 2 * (n-1) * H(n-2)

r = Ring( "Z(x) L" );
print "Ring: " + str(r);
print;

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

one = r.one();
x2 = 2 * x;

N = 10;
H = [one,x2];
for n in range(2,N):
    h = x2 * H[n-1] - 2 * (n-1) * H[n-2];
    H.append( h );
Ejemplo n.º 18
0
#
# jython for jas example integer programming.
# $Id$
#
# CLO2, p370
# 4 A + 5 B + C = 37
# 2 A + 3 B + D = 20
#
# max: 11 A + 15 B
#

import sys;

from jas import Ring

r = Ring( "Rat(w1,w2,w3,w4,z1,z2) W( (0,0,0,0,1,1),(1,1,2,2,0,0) )" );
print "Ring: " + str(r);
print;


ps = """
( 
 ( z1^4 z2^2 - w1 ),
 ( z1^5 z2^3 - w2 ),
 ( z1 - w3 ),
 ( z2 - w4 )
) 
""";

f = r.ideal( ps );
print "Ideal: " + str(f);
Ejemplo n.º 19
0
## \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);
Ejemplo n.º 20
0
c = CC();
print "c:", c;
c = c.one();
print "c:", c;
c = CC((2,),(3,));
print "c:", c;
print "c^5:", c**5 + c.one();
print;

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
[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);
Ejemplo n.º 21
0
# 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 Q

#r = Ring( "Rat(x) L" );
r = Ring( "Q(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;
Ejemplo n.º 22
0
#
# jython examples for jas.
# $Id: syzy3.py 1268 2007-07-29 11:05:03Z kredel $
#

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.module import SyzygyAbstract
from edu.jas.vector import ModuleList
from edu.jas.module import ModGroebnerBaseAbstract
Ejemplo n.º 23
0
from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate

# Nabashima, ISSAC 2007, example F8
# modified, take care
# integral function coefficients

#r = Ring( "IntFunc(d, b, c, a) (w,z,y,x) G" );
#r = Ring( "IntFunc(b, c, a) (w,x,z,y) L" );
#r = Ring( "IntFunc(b, c) (z,y,w,x) L" );
#r = Ring( "IntFunc(b) (z,y,w,x) L" );
#r = Ring( "IntFunc(c) (z,y,w,x) L" );
r = Ring("IntFunc(c) (z,y,w,x) L")
print "Ring: " + str(r)
print

ps = """
(
 ( { 1 } x^2 + { 1 } y ),
 ( { 1 } w^2 + z ),
 ( ( x - z )^2 + ( y - w)^2 ),
 ( { 2 } x w - { 2 1 } y )
) 
"""

# ( { 1 } x^2 + { b } y ),
# ( { c } w^2 + z ),
# ( { a } x^2 + { b } y ),
Ejemplo n.º 24
0
        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;

[yp] = pr.gens();

one = pr.one();
p1 = one;
p2 = one - yp;

ps1 = psr.from(p1);
ps2 = psr.from(p2);

# rational function as power series:
ps3 = ps1 / ps2;
Ejemplo n.º 25
0
#

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;
Ejemplo n.º 26
0
from jas import Ring
from jas import startLog, terminate

#import rational;

# 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( "Z(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

# 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();
#automatic: [one,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
Ejemplo n.º 27
0
#

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;
Ejemplo n.º 28
0
## \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
# integral function coefficients

r = Ring( "IntFunc(a, c, b) (y2, y1, z1, z2, x) L" );
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);
Ejemplo n.º 29
0
# 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;
#
# jython examples for jas.
# $Id$
#

import sys;

from jas import Ring
from jas import startLog
from jas import terminate


# Nabashima, ISSAC 2007, example F4
# integral function coefficients

r = Ring( "IntFunc(a, b, c, d) (y, x) L" );
print "Ring: " + str(r);
print;

ps = """
(
 ( { a } x^3 y + { c } x y^2 ),
 ( x^4 y + { 3 d } y ),
 ( { c } x^2 + { b } x y ),
 ( x^2 y^2 + { a } x^2 ),
 ( x^5 + y^5 )
) 
""";

#startLog();
#
# jython examples for jas.
# $Id$
#

import sys

from jas import Ring
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
#
# jython examples for jas.
# $Id$
#

import sys;

from jas import Ring
from jas import startLog
from jas import terminate


# Nabashima, ISSAC 2007, example F1
# integral function coefficients

r = Ring( "IntFunc(a, b) (y,x) G" );
print "Ring: " + str(r);
print;

ps = """
(
 ( { a } x^4 y + x y^2 + { b } x ),
 ( x^3 + 2 x y ),
 ( { b } x^2 + x^2 y )
) 
""";

#startLog();

f = r.paramideal( ps );
print "ParamIdeal: " + str(f);
Ejemplo n.º 33
0
        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;
Ejemplo n.º 34
0
#
# jython examples for jas.
# $Id: mark.py 1429 2007-10-13 12:58:29Z kredel $
#

#import sys;

from jas import Ring
from jas import Ideal
from jas import startLog

# mark, d-gb diplom example

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

ps = """
( 
 ( z + x y**2 + 4 x**2 + 1 ),
 ( y**2 z + 2 x + 1 ),
 ( x**2 z + y**2 + x )
) 
""";

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

from edu.jas.ring import EGroebnerBaseSeq;
from edu.jas.ring import DGroebnerBaseSeq;
Ejemplo n.º 35
0
#
# jython examples for jas.
# $Id: nabeshima_cgbF6.py 1977 2008-08-03 10:40:23Z kredel $
#

import sys

from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate

# Nabashima, ISSAC 2007, example F6
# integral function coefficients

r = Ring("IntFunc(a, b,c, d) (x) L")
print "Ring: " + str(r)
print

ps = """
(
 ( x^4 + { a } x^3 + { b } x2 + { c } x + { d } ),
 ( 4 x^3 + { 3 a } x^2 + { 2 b } x + { c } )
) 
"""

#startLog();

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

from jas import Ring

# ? 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 = r.ideal( ps );
print "Ideal: " + str(f);
print;

rg = f.GB();
print "seq Output:", rg;
print;

from edu.jas.gbufd  import SyzygySeq;
#

import sys;

from jas import Ring
from jas import startLog
from jas import terminate


# Nabashima, ISSAC 2007, example F8
# modified, take care
# integral function coefficients


#r = Ring( "IntFunc(d, b, a, c) (y,x,w,z) L" );
r = Ring( "IntFunc(d, b, a, c) (y,x,w,z) G" );

#r = Ring( "IntFunc(d, b, c, a) (w,z,y,x) G" );
#r = Ring( "IntFunc(b, c, a) (w,x,z,y) L" );
#r = Ring( "IntFunc(b, c) (z,y,w,x) L" );
#r = Ring( "IntFunc(b) (z,y,w,x) L" );
#r = Ring( "IntFunc(c) (z,y,w,x) L" );
#r = Ring( "IntFunc(c) (z,y,w,x) G" );
print "Ring: " + str(r);
print;

ps = """
(
 ( { c } w^2 + z ),
 ( { a } x^2 + { b } y ),
 ( ( x - z )^2 + ( y - w)^2 ),
#
# jython examples for jas.
# $Id$
#

import sys

from jas import Ring
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
Ejemplo n.º 39
0
#
# jython examples for jas.
# $Id$
#

import sys

from jas import Ring
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
Ejemplo n.º 40
0
#
# 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
Ejemplo n.º 41
0
rs = """
# polynomial ring:
Rat(x1,x2,x3,y1,y2) G|3|
"""

ps = """
(
 ( y1 + y2 - 1 ),
 ( x1 - y1^2 - y1 - y2 ),
 ( x2 - y1 - y2^2 ),
 ( x3 - y1 y2 )
)
"""

r = Ring(rs)
print "Ring: " + str(r)

i = Ideal(r, ps)
print "Ideal: " + str(i)

g = i.GB()
print "seq GB:", g

rsi = """
# polynomial ring:
Rat(x1,x2,x3) G
"""

ri = Ring(rsi)
print "Ring: " + str(ri)
Ejemplo n.º 42
0
## \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("RatFunc(a, c, b) (y2, y1, z1, z2, x) L")
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)
Ejemplo n.º 43
0
# 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

k = Katsura(knum)
r = Ring(k.varList("Rat", "G"))
#r = Ring.new( k.varList("Mod 23","G") );
print "Ring: " + str(r)
print

ps = k.polyList()

f = r.ideal(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;
Ejemplo n.º 44
0
    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
#
# jython examples for jas.
# $Id$
#

import sys

from jas import Ring
from jas import startLog
from jas import terminate

# Nabashima, ISSAC 2007, example Ex-4.8
# integral function coefficients

r = Ring("IntFunc(a, b, c) (y,x) L")
print "Ring: " + str(r)
print

ps = """
(
 ( { a } x^2 + { b } y^2 ),
 ( { c } x^2 + y^2 ),
 ( { 2 a } x - { 2 c } y )
) 
"""

#startLog();

f = r.paramideal(ps)
print "ParamIdeal: " + str(f)
print
Ejemplo n.º 46
0
#
# The MAS DIIPEGB implementation contains an error because the output e-GB
# is not correct. Also the cited result from k-r contains this error.
# The polynomial
#
# ( 2 x * y^2 - x^13 + 2 x^11 -   x^9 + 2 x^7 - 2 x^3 ),
#
# is in the DIIPEGB output, but it must be
#
# ( 2 x * y^2 - x^13 + 2 x^11 - 3 x^9 + 2 x^7 - 2 x^3 ),
#
# Test by adding the polynomials to the input.
# Frist polynomial produces a different e-GB.
# Second polynomial reproduces the e-GB with the second polynomial.

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

ps = """
( 
 ( y**6 + x**4 y**4 - x**2 y**4 - y**4 - x**4 y**2 + 2 x**2 y**2 + x**6 - x**4 ),
 ( 2 x**3 y**4 - x y**4 - 2 x**3 y**2 + 2 x y**2 + 3 x**5 - 2 x** 3 ),
 ( 3 y**5 + 2 x**4 y**3 - 2 x**2 y**3 - 2 y**3 - x**4 y + 2 x**2 y )
) 
"""

f = r.ideal(ps)
print "Ideal: " + str(f)
print
Ejemplo n.º 47
0
import sys

from jas import Ring
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")
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)
Ejemplo n.º 48
0
# jython examples for jas.
# $Id: cgb_2.py 1977 2008-08-03 10:40:23Z kredel $
#

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();
Ejemplo n.º 49
0
# 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

#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 )
) 
"""
Ejemplo n.º 50
0
import sys

from jas import Ring
from jas import Ideal
from jas import startLog
from jas import terminate

# rational function coefficients
# IP (alpha,beta,gamma,epsilon,theta,eta)
# (c3,c2,c1) /G/
#r = Ring( "IntFunc(alpha,beta,gamma,epsilon,theta,eta)(c3,c2,c1) G" );
# ( { alpha } c1 - { beta } c1**2 - { gamma } c1 c2 + { epsilon } c3 ),
# ( - { gamma } c1 c2 + { epsilon + theta } c3 - { gamma } c2 ),
# ( { gamma } c2 c3 + { eta } c2 - { epsilon + theta } c3 )

r = Ring("IntFunc(a,b,g,e,t,eta)(c3,c2,c1) G")
print "Ring: " + str(r)
print

ps = """
(
 ( { a } c1 - { b } c1**2 - { g } c1 c2 + { e } c3 ),
 ( - { g } c1 c2 + { e + t } c3 - { g } c2 ),
 ( { g } c2 c3 + { eta } c2 - { e + t } c3 )
)
"""

f = r.paramideal(ps)
print "ParamIdeal: " + str(f)
print
Ejemplo n.º 51
0
#
# 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 )
)
""";
Ejemplo n.º 52
0
#
# jython examples for jas.
# $Id: pppj2006.py 1094 2007-05-24 20:56:35Z kredel $
#

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
Ejemplo n.º 53
0
# jython examples for jas.
# $Id: raksanyi_cr.py 1986 2008-08-03 16:20:57Z kredel $
#

import sys

from jas import Ring
from jas import ParamIdeal
from jas import startLog
from jas import terminate

# Raksanyi & Walter example
# integral/rational function coefficients

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

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

f = r.paramideal(ps)
print "ParamIdeal: " + str(f)
print
Ejemplo n.º 54
0
from jas import Ideal
from jas import startLog
from jas import terminate

# import rational;

# 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( "Z(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

# 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()

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