# Singular

#### 7.10.3.6 lpSubstitute

Procedure from library `fpaprops.lib` (see fpaprops_lib).

Usage:
lpSubstitute(f,s1,s2[,G]); f poly, s1 list (ideal) of variables to replace, s2 list (ideal) of polynomials to replace with, G optional ideal to reduce with.

Return:
poly, the substituted polynomial

Assume:
- basering is a Letterplace ring
- s1 contains a subset of the set of variables
- s2 and s1 are of the same size
- G is a Groebner basis,
- the current ring has a sufficient degbound (which also can be calculated with lpCalcSubstDegBound())

Note:
the procedure implements the image of a polynomial f
under an endomorphism of a free algebra, defined by s1 and s2: variables, not present in s1, are left unchanged;
variable s1[k] is mapped to a polynomial s2[k].
- An optional ideal G extends the endomorphism as above to the morphism into the factor algebra K<X>/G.

Example:
 ```LIB "fpaprops.lib"; ring r = 0,(x,y,z),dp; def R = freeAlgebra(r, 4); setring R; ideal G = x*y; // optional poly f = 3*x*x+y*x; ideal s1 = x, y; ideal s2 = y*z*z, x; // i.e. x --> yzz and y --> x // the substitution probably needs a higher degbound int minDegBound = lpCalcSubstDegBound(f,s1,s2); minDegBound; // thus the bound needs to be increased ==> 9 setring r; // back to original r def R1 = freeAlgebra(r, minDegBound); setring R1; lpSubstitute(imap(R,f), imap(R,s1), imap(R,s2)); ==> 3*y*z*z*y*z*z+x*y*z*z // the last parameter is optional; above it was G= // the output will be reduced with respect to G lpSubstitute(imap(R,f), imap(R,s1), imap(R,s2), imap(R,G)); ==> 3*y*z*z*y*z*z ```