MATLAB: Displaying a more precise answer when using diff()

diff()

Hi guys, I'm doing this in MATLAB
syms x
f = (cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(x)))))))))))))))));
c = sym('1');
diff(c)
And it gives me ans = 0. But I know the answer is not 0. How can I get a more exact answer? Specifically the answer to this derivative is 0.00178818.
Thank you!

Best Answer

In your code you have asked for the derivative of the constant 1, and of course its derivative will be zero. You need to find the expression for the derivative of f with respect to x and only then evaluate it for x = 1. That is, do diff(f,x) first, then find its numerical value at x = 1.
Related Question