## Different result by hand-differentiaion vs MATLAB diff() function.

### yf (view profile)

on 5 Mar 2018
Latest activity Commented on by Stephen Cobeldick

on 5 Mar 2018

### Roger Stafford (view profile)

I differentiated the equation, ( K=(y^2 + 2*y + 2)/(y + 1)^2 ), by hand-differentiation and got result, ( -2/(y+1) ) while the result with MATLAB function, ( diff(K, y) ) was, (2*y + 2)/(y + 1)^2 - (2*(y^2 + 2*y + 2))/(y + 1)^3
I don't know why was it and what was the wrong I did.

### Roger Stafford (view profile)

on 5 Mar 2018
Edited by Roger Stafford

### Roger Stafford (view profile)

on 5 Mar 2018

Your "hand-differentiation" is not correct! The 'diff' answer is correct but can be simplified to an equivalent -2/(y+1)^3. (Perhaps the latter is what you meant to write?)

Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 5 Mar 2018
Hi Mr. Roger Stafford,
Thank you for your answer. I will think about it why is the different result in between the book and from the MATLAB. Thanks once again.
Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 5 Mar 2018
@yf: considering that Roger Stafford helped you to resolve this issue then you should accept this answer: this is the easiest way for you to show your appreciation to the volunteers who help you on this forum.
Stephen Cobeldick

on 5 Mar 2018