# How can y=(x-1)^2+2(x-1)(x+2)+(x+2)^2 be differentiated in two different ways?

*print*Print*list*Cite

### 2 Answers

We have to find the derivative of y=(x-1)^2+2(x-1)(x+2)+(x+2)^2

Using the product rule and the chain rule:

y' = 2(x - 1)*1 + 2[(x - 1)*1 + (x + 2)*1] + 2( x + 2)*1

=> y' = 2x - 2 + 2x - 2 + 2x + 4 + 2x + 4

=> y' = 8x + 4

Else we can expand the expression:

y = (x-1)^2 + 2(x-1)(x+2) + (x+2)^2

=> (x - 1 + x + 2)^2

=> (2x + 1)^2

=> 4x^2 + 1 + 4x

y' = 8x + 4

**Therefore the derivative of y = (x-1)^2 + 2(x-1)(x+2) + (x+2)^2 is y' = 8x + 4**

Either we can differentiate each term of the sum, or we can notice that the expression is a complete square and we'll differentiate the complete square.

If we'll put (x-1) as a and (x+2) as b, and we'll re-write the expresison, we'll get a perfect square:

y=a^2 + 2ab + b^2

y = (a+b)^2

y = (x-1+x+2)^2

We'll combine like terms:

y = (2x+1)^2

Now, we'll differentiate both sides, with respect to x, using chain rule:

dy/dx = 2(2x+1)*(2x+1)'

dy/dx = 2(2x+1)*2

dy/dx = 4(2x+1)

We'll remove the brackets:

dy/dx = 8x + 4

The other method is to differentiate each term of the sum, with respect to x.

dy/dx = d(x-1)^2/dx + 2d[(x-1)(x+2)]/dx + d(x+2)^2/dx

dy/dx = 2(x-1)+ 2d(x^2+x-2)/dx + 2(x+2)

dy/dx = 2x - 2 + 2(2x+1) + 2x + 4

dy/dx = 4x + 2 + 4x + 2

dy/dx = 8x + 4

**Both methods will lead to the same result: dy/dx = 8x + 4.**