# Singular

##### 7.7.8.0. lpSubstitute
Procedure from library `fpaprops.lib` (see fpaprops_lib).

Usage:
lpSubstitute(f,s1,s2[,G]); f letterplace polynomial, 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
- G is a groebner basis,
- the current ring has a sufficient degbound (can be calculated with lpCalcSubstDegBound())

Example:
 ```LIB "fpaprops.lib"; //////// EXAMPLE A //////// ring r = 0,(x,y,z),dp; def R = makeLetterplaceRing(4); setring R; ideal G = x(1)*y(2); // optional poly f = 3*x(1)*x(2)+y(1)*x(2); ideal s1 = x(1), y(1); ideal s2 = y(1)*z(2)*z(3), x(1); // the substitution probably needs a higher degbound int minDegBound = lpCalcSubstDegBounds(f,s1,s2); ==> // ** int division with `/`: use `div` instead in line >> maxDegBound = \ maxDegBound + maxDegBound/2;<< setring r; def R1 = makeLetterplaceRing(minDegBound); setring R1; // the last parameter is optional lpSubstitute(imap(R,f), imap(R,s1), imap(R,s2), imap(R,G)); ==> y(1)*z(2)*z(3)*y(4)*z(5)*z(6) //////// EXAMPLE B //////// ring r = 0,(x,y,z),dp; ==> // ** redefining r (ring r = 0,(x,y,z),dp;) def R = makeLetterplaceRing(4); ==> // ** redefining R (def R = makeLetterplaceRing(4);) setring R; poly f = 3*x(1)*x(2)+y(1)*x(2); poly g = z(1)*x(2)+y(1); poly h = 7*x(1)*z(2)+x(1); ideal I = f,g,h; ideal s1 = x(1), y(1); ideal s2 = y(1)*z(2)*z(3), x(1); int minDegBound = lpCalcSubstDegBounds(I,s1,s2); ==> // ** redefining minDegBound (int minDegBound = lpCalcSubstDegBounds(I,s1\ ,s2);) ==> // ** int division with `/`: use `div` instead in line >> maxDegBound = \ maxDegBound + maxDegBound/2;<< ==> // ** int division with `/`: use `div` instead in line >> maxDegBound = \ maxDegBound + maxDegBound/2;<< ==> // ** int division with `/`: use `div` instead in line >> maxDegBound = \ maxDegBound + maxDegBound/2;<< setring r; def R1 = makeLetterplaceRing(minDegBound); ==> // ** redefining R1 (def R1 = makeLetterplaceRing(minDegBound);) setring R1; ideal I = imap(R,I); ideal s1 = imap(R,s1); ideal s2 = imap(R,s2); for (int i = 1; i <= size(I); i++) { lpSubstitute(I[i], s1, s2); } ==> 3*y(1)*z(2)*z(3)*y(4)*z(5)*z(6)+x(1)*y(2)*z(3)*z(4) ==> z(1)*y(2)*z(3)*z(4)+x(1) ==> 7*y(1)*z(2)*z(3)*z(4)+y(1)*z(2)*z(3) ```