Displaying a more precise answer when using 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!

 채택된 답변

Roger Stafford
Roger Stafford 2016년 5월 1일

0 개 추천

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.

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by