# Singular          ##### 7.5.3.0. centralizer
Procedure from library `central.lib` (see central_lib).

Usage:
centralizer(F, D[, N]); F poly/ideal, D int, N optional int

Return:
ideal, generated by computed elements

Purpose:
computes subalgebra generators of centralizer(F) up to degree D

Note:
In general, one cannot compute the whole centralizer(F).
Hence, one has to specify a termination condition via arguments D and/or N.
If D is positive, only centralizing elements up to degree D will be found.
If D is negative, the termination is determined by N only.
If N is given, the computation stops if at least N elements have been found.
Warning: if N is given and bigger than the actual number of generators,
the procedure may not terminate.
Current ordering must be a degree compatible well-ordering.

Example:
 ```LIB "central.lib"; ring AA = 0,(x,y,z),dp; matrix D=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^2-2*z; // a central polynomial f; ==> 4xy+z2-2z // 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=z ==> c=y ==> c=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=z ==> cc=y ==> cc=x inCentralizer(cc, f); // check the result ==> 1 poly g = z^2-2*z; // some non-central polynomial // find generators of the centralizer of g of degree <= 2: c = centralizer(g, 2); c; ==> c=z ==> c=xy inCentralizer(c, g); // check the result ==> 1 // find at least one generator of the centralizer of g: centralizer(g,-1,1); ==> _=z // find at least two generators of the centralizer of g: cc = centralizer(g,-1,2); cc; ==> cc=z ==> cc=xy inCentralizer(cc, g); // check the result ==> 1 ``` 