I know diff
calculates the discreete derivative, or let's say the difference between consequitive components of a vector.
Not I define a variable
x=-4:1/10:4;
y=diff(diff(x));
Why the heck do I get 1.e-15*
and a row of vectors that are non zero? Matlab is being honest by displaying that somehow, in calculating x=-4:1/10:4;
it had rounded some digits and though while I execute y=(diff(x));
only and even though it displays all digits same, it some how shows that in it's core they are not stored as same quantities(because it rounded off -4+0.1 or some quantity as other than -3.9 ???). Now, how do I get the standard output? How do I get 0 when it is really zero, like in this case, and non zero whatever it may be like even like 1*e-...
, when it is actually non zero?
Note if that is not possible, how do I calculate real/actual diff(x,2)
, or atleast accurate sign and zero when diff is actually zero? and get the real discreete derivative for functions like cosine
instead of some misleading value?
I need to calculate inflection point using diff.