Q:

Table of values of nDeriv(f(x),x,x) vs. f'(x) gives different results??

$$f(x)=\cos(e^x)$$
So, I work out that:
$$f'(x)=-\sin(e^x)(e^x)=-e^x\sin(e^x)$$
For fun and amusement, I wanted to verify this is the actual derivative, 
So, using a Ti84+, I tried to enter both of these functions and compare the table of values.
But, when I do 2nd-->table, I get diverging values once x>5 
Any idea what's going on?  I tried adding ()'s to ensure proper order of operations.
Is this a glitch in the internal algorithm for estimating derivatives?
Thanks!

A:

For values of $x$ greater than about $2$, these functions start looking pretty wild. When the TI84+ does nDeriv it is calculating the slope of the secant line through two points on the graph:
$$
f'(x) = \frac{f(x+\varepsilon) - f(x -\varepsilon)}{2\varepsilon}
$$
Specific to this problem, the default value of $\varepsilon$ that the calculator uses is $10^{-3}$. Considering how wildly $\cos(e^x)$ starts to oscillate, with this value of $\varepsilon$ the calculator will start giving false derivative values.
The function nDerive does take an optional fourth argument of a specific value of $\varepsilon$ if you want to try to change it and get more accurate results, but for the function $\cos(e^x)$ it doesn't look good.
Also, just as a general note, since the TI84+ does use the secant method to find the numerical derivative, it will return a value even if the function is non-differentiable at that point.
Edit: After running a few tests, letting $\varepsilon = 10^{-8}$ keeps nDeriv of $\cos(e^x)$ and its actual derivative of $-e^x\sin(e^x)$ in agreement up to $x=17$.
seq(nDeriv(cos(e^X), X, A, 1E-8), A, 1, 20) -> L1
seq(-(e^X)(sin(e^X)), X, 1, 20) -> L2

