(4 - 2 y1 + y1^2) (4 - 2 y2 + y2^2) How to convert the above form to the form below?
(3 + (-1 + y1)^2) (3 + (-1 + y2)^2) Defining a function that completes the square given a quadratic polynomial expression
Factoring the square of this polynomial?
CompleteTheSquare::notquad="The expression is not quadratic in the variables `1`"; CompleteTheSquare[expr_]:=CompleteTheSquare[expr,Variables[expr]] CompleteTheSquare[expr_,Vars_Symbol]:=CompleteTheSquare[expr,{Vars}] CompleteTheSquare[expr_,Vars:{__Symbol}]:=Module[{array,A,B,C,s,vars,sVars},vars=Intersection[Vars,Variables[expr]]; Check[array=CoefficientArrays[expr,vars],Return[expr],CoefficientArrays::poly]; If[Length[array]!=3,Message[CompleteTheSquare::notquad,vars];Return[expr]]; {C,B,A}=array;A=Symmetrize[A]; s=Simplify[1/2 Inverse[A] . B,Trig->False]; sVars=Hold/@(vars+s);A=Map[Hold,A,{2}]; Expand[A . sVars . sVars]+Simplify[C-s . A . s,Trig->False]//ReleaseHold] CompleteTheSquare[x^2+29x+1000,x] The post and code above can only complete the square for a single polynomial.
How to complete the square for each factor of a polynomial product?

CompleteTheSquare /@ expr$\endgroup$The expression is not quadratic in the variables {y1}$\endgroup$CompleteTheSquarefunction requires an additional parameter. $\endgroup$