How large should n be to guarantee the error in approximating ln(.5) with ln(1+x) centered at a = 0 is less than .0001? I am asked to find the number of terms such that the error of approximating ln(.5) < 0.001 using Taylor's inequality. I can do these using the remainder theorem from the alternating series test, but we are required to use Taylor's inequality.
I am struggling right now to find M such that
$ |f^{n+1}(x)| \le M$.
I have found the derivative
$|f^{n+1}(x)|= \frac{n!}{(1+x)^{n+1}}$. My problem is with finding M. I know that $x \in (-.5, 0)$, and the derivative (absolute value) is decreasing. If I plug -.5 into the derivative to get M, M seems to just blow up and isn't bounded.
Is there any other way to find M in this situation?
 A: Since $\ln(1+x)=x-x^2/2+x^3/3+\dots+\mathcal o(x^n)$, we just need to choose $n$ so that $1/2^n\lt1/10000$.  Since $2^{17}\gt10000$, $n=17$ will work.
For a better estimate, note that we actually have the $n$-th term equal to $(-1)^{n+1}x^n/n$ , and so we can get away with $n=13$.
A: Making it general, we have (for $|x|<1$)
$$\log(1+x)=\sum_{n=1}^\infty (-1)^{n+1}\,\frac {x^n} n=\sum_{n=1}^p (-1)^{n+1}\,\frac {x^n} n+\sum_{n=p+1}^\infty (-1)^{n+1}\,\frac {x^n} n$$ and you want to know $p$ such that
$$R_p=\frac {x^{p+1}}{p+1} \leq 10^{-k}$$ that is to say
$$(p+1) \geq x^{p+1} 10^k$$
In the real domain, the only analytical solution of the equation is
$$p=-\frac{W\left[-10^k \log (x)\right]}{\log (x)}-1$$ where $W(.)$ is Lambert function whicch is widely used (on the search bar here, just type Lambert and you will find $3392$ entries). For sure, after computing $p$, you will use $\lceil p\rceil$.
For $k=5$ and $x=\frac 12$, this will give $p=11.9183$, then $\lceil p\rceil=12$.
Let us check
$$R_{11}=\frac{1}{49152}\sim 2.03\times 10^{-5} > 10^{-5}$$
$$R_{12}=\frac{1}{106496}\sim 9.39\times 10^{-6} < 10^{-5}$$
If you do not have access to this function, you can use the expansion for large values of $t$ as given in the linked page
$$W(t)= L_1-L_2+\frac{L_2}{L_1}+\frac{L_2(L_2-2)}{2L_1^2}+\frac{L_2(2L_2^2-9L_2+6)}{6L_1^3}+\cdots$$ where $L_1=\log(t)$ and $L_2=\log(L_1)$.
From a coding point of view, there is big advantage to know in advance the number of terms to be added since, in the calculation loop, you will not have any more IF test (this is a very expensive operation).
Suppose that, for the same $x=\frac 12$, we want $k=100$. We should find $p=322.854$  then $\lceil p\rceil=323$. Checking again
$$R_{322}=4.81\times 10^{-100} >10^{-100}$$ $$ R_{323}=9.03\times 10^{-101} <10^{-100} $$
Welcome to the world of the magnificent Lambert function !
