 LIB "central.lib";
ring AA = 0,(x,y,z),dp;
matrix D[3][3]=0;
D[1,2]=z; D[1,3]=2*x; D[2,3]=2*y;
def A = nc_algebra(1,D); setring A; // this algebra is U(sl_2)
poly f = 4*x*y+z^22*z; // a central polynomial
f;
==> 4xy+z22z
// find generators of the centralizer of f of degree <= 2:
ideal c = centralizer(f, 2);
c; // since f is central, the answer consists of generators of A
==> c[1]=z
==> c[2]=y
==> c[3]=x
inCentralizer(c, f); // check the result
==> 1
// find at least two generators of the centralizer of f:
ideal cc = centralizer(f,1,2);
cc;
==> cc[1]=z
==> cc[2]=y
==> cc[3]=x
inCentralizer(cc, f); // check the result
==> 1
poly g = z^22*z; // some noncentral polynomial
// find generators of the centralizer of g of degree <= 2:
c = centralizer(g, 2);
c;
==> c[1]=z
==> c[2]=xy
inCentralizer(c, g); // check the result
==> 1
// find at least one generator of the centralizer of g:
centralizer(g,1,1);
==> _[1]=z
// find at least two generators of the centralizer of g:
cc = centralizer(g,1,2);
cc;
==> cc[1]=z
==> cc[2]=xy
inCentralizer(cc, g); // check the result
==> 1
