Beispiel #1
0
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
Beispiel #2
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;
Beispiel #3
0
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;

print "p1:", p1;
print "p2:", p2;
print "ps1:", ps1;
print "ps2:", ps2;
# 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
f6 = 99 * W - 11 * B * S + 3 * B**2
f7 = 10000 * B**2 + 6600 * B + 2673
#all ok:
#f7 = f7 + e * f6**0;
#f7 = f7 + 5959345574908321469098512640906154241024000000**2 * f6;
#f7 = f7 + 35555./332 * f1;
Beispiel #5
0
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;
#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;
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;

[x,y,z] = r.gens();

one = r.one();
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;
Beispiel #7
0
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

[x, y, z] = r.gens()

one = r.one()
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
Beispiel #8
0
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 );

for n in range(0,N):
    print "H[%s] = %s" % (n,H[n]);

print;
Beispiel #9
0
# 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;
f6 = 99 * W - 11 *B * S + 3 * B**2;
f7 = 10000.0 * B**2 + 6600 * B + 2673;
#all ok:
#f7 = f7 + e * f6**0;
#f7 = f7 + 5959345574908321469098512640906154241024000000**2 * f6;
#f7 = f7 + 35555./332 * f1;
Beispiel #10
0
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
Beispiel #11
0
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
    #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;

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
Beispiel #13
0
# 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;
f6 = 99 * W - 11 *B * S + 3 * B**2;
f7 = 10000 * B**2 + 6600 * B + 2673;
#all ok:
#f7 = f7 + e * f6**0;
#f7 = f7 + 5959345574908321469098512640906154241024000000**2 * f6;
#f7 = f7 + 35555./332 * f1;
Beispiel #14
0
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;
f = RF(d);
print "f: " + str(f);

n = d*d + y + 1;
f = RF(d,n);
Beispiel #15
0
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
f = RF(d)
print "f: " + str(f)

n = d * d + y + 1
f = RF(d, n)
Beispiel #16
0
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;
Beispiel #17
0
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);
print "f: " + str(f);

n = d*d + y + 1;
f = RF(r,d,n);
print "f: " + str(f);
Beispiel #18
0
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();
Beispiel #19
0
# 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
f6 = 99 * W - 11 * B * S + 3 * B**2
f7 = 10000.0 * B**2 + 6600 * B + 2673
#all ok:
#f7 = f7 + e * f6**0;
#f7 = f7 + 5959345574908321469098512640906154241024000000**2 * f6;
#f7 = f7 + 35555./332 * f1;
Beispiel #20
0
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);
Beispiel #21
0
# 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
f6 = 99 * W - 11 * B * S + 3 * B ** 2
f7 = 10000 * B ** 2 + 6600 * B + 2673
# all ok:
# f7 = f7 + e * f6**0;
# f7 = f7 + 5959345574908321469098512640906154241024000000**2 * f6;
# f7 = f7 + 35555./332 * f1;