# jython examples for jas. # $Id$ # import sys from jas import Ring, PolyRing, QQ, GF from jas import startLog # example katsura, optimize term order # optimal is (u1, u2, u3, u4, u5, u6, u0, u7) # better is (u7,u6,u5,u4,u3,u2,u1,u0) #r = Ring( "Mod 13 (u0,u1,u2,u3,u4,u5,u6,u7) G" ); #r = Ring( "Rat (u7,u6,u5,u4,u3,u2,u1,u0) G" ); r = Ring("Mod 5 (u7,u6,u5,u4,u3,u2,u1,u0) G") print "Ring: " + str(r) print ps = """ ( u7*u7 + u6*u6 + u5*u5 + u4*u4 + u3*u3 + u2*u2 + u1*u1 + u0*u0 + u1*u1 + u2*u2 + u3*u3 + u4*u4 + u5*u5 + u6*u6 + u7*u7 - u0, u7*0 + u6*u7 + u5*u6 + u4*u5 + u3*u4 + u2*u3 + u1*u2 + u0*u1 + u1*u0 + u2*u1 + u3*u2 + u4*u3 + u5*u4 + u6*u5 + u7*u6 - u1, u7*0 + u6*0 + u5*u7 + u4*u6 + u3*u5 + u2*u4 + u1*u3 + u0*u2 + u1*u1 + u2*u0 + u3*u1 + u4*u2 + u5*u3 + u6*u4 + u7*u5 - u2, u7*0 + u6*0 + u5*0 + u4*u7 + u3*u6 + u2*u5 + u1*u4 + u0*u3 + u1*u2 + u2*u1 + u3*u0 + u4*u1 + u5*u2 + u6*u3 + u7*u4 - u3, u7*0 + u6*0 + u5*0 + u4*0 + u3*u7 + u2*u6 + u1*u5 + u0*u4 + u1*u3 + u2*u2 + u3*u1 + u4*u0 + u5*u1 + u6*u2 + u7*u3 - u4, u7*0 + u6*0 + u5*0 + u4*0 + u3*0 + u2*u7 + u1*u6 + u0*u5 + u1*u4 + u2*u3 + u3*u2 + u4*u1 + u5*u0 + u6*u1 + u7*u2 - u5, u7*0 + u6*0 + u5*0 + u4*0 + u3*0 + u2*0 + u1*u7 + u0*u6 + u1*u5 + u2*u4 + u3*u3 + u4*u2 + u5*u1 + u6*u0 + u7*u1 - u6, u7 + u6 + u5 + u4 + u3 + u2 + u1 + u0 + u1 + u2 + u3 + u4 + u5 + u6 + u7 - 1 ) """
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 ),
# 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 ) ) """
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)
# 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
# $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 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 )
# # 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
# # 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);
# # 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;
## \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);
# # 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();
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
print 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
# 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 [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
# # 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 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
# # 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
# # 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
# 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 ),
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
# 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
# # 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
# 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;
# 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();
# # 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
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
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)
# # 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
# 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
# # jython examples for jas. # $Id: nabeshima_cgbF2.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 F2 # integral function coefficients r = Ring("IntFunc(b, a) (x,y) G") 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)