# Using Lagrange Error with cos(x)

I attempted to solve this problem:

Determine the values of $$x$$ for which the function can be replaced by the Taylor polynomial if the error cannot exceed $$0.001$$.

$$f(x)=\cos(x)\approx 1-\frac{x^2}{2!}+\frac{x^4}{4!}$$

I thought this equation went to $$n=4$$, so when using Lagrange Error, I found the max of the fifth derivative ($$n+1=4+1=5$$). However, I found out it was wrong; actually, this equation went to $$n=5$$ and I should find the max of the sixth derivative for Lagrange Error. Why is that? It seems not to follow the $$n+1$$ rule for Lagrange Error.

It's valid to use an error term based on the fifth derivative here (and get some range of $$x$$ values that way).
However, you could also notice that the coefficient of $$x^5$$ in the Taylor expansion of $$\cos(x)$$ is $$0$$, and so you can also think of this Taylor expansion as going out to the fifth term (which is $$0 \cdot x^5$$) and use an error term based on the sixth derivative.
Both approaches will give you true bounds on $$x$$-values, but we expect the second approach to produce better results (that is, identify more values of $$x$$ for which the approximation is good enough), because the sixth-derivative error term tends to be smaller than the fifth-derivative error term.