The identity (a+b)2=(a2+2ab+b2) represents a perfect square.
Consider the expression x2+18x.
If we halve the coefficient of x and add its square to this expression, we get
x2+18x+81.
But,
x2+18x+81=x2+2(x)(9)+(9)2
=(x+9)2, a perfect square.
Thus, we have to add 81 to the expression (x2+18x) so that the resultant is a perfect square.
Similarly, 4 must be added to x2+4x so that the sum is a perfect square as shown below:
x2+4x+4=x2+2(x)(2)+(2)2
=(x+2)2
And, 121 must be added to x2+22x to make the resultant a perfect square.
x2+22x+121=(x+11)2