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

4 views (last 30 days)
yf on 5 Mar 2018
Commented: Stephen23 on 5 Mar 2018
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.
Please help. Thank you.
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Roger Stafford on 5 Mar 2018
Edited: Roger Stafford 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?)
##### 5 CommentsShowHide 4 older comments
Stephen23 on 5 Mar 2018
yf's "Answer" moved here:
Hi Mr. Roger Stafford,
I found the problem now. the denominator in the solution manual is actually,
(y^2 + 2*y + 1)^2 = ( (y + 1)^2 )^2
hence is,
(2*y + 2)/(y + 1)^2 - (2*(y^2 + 2*y + 2))/(y + 1)^3 = -2*(y + 1)/(y+1)^4 = -2/(y+1)^3
I made mistake on this point.
Thank you so much for you answer and help.

Sign in to comment.

### Categories

Find more on Mathematics in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by