Estimate $\ln(x)$ using Taylor Polynomial accurate to specified precision

taylor expansion

The task is to estimate $\ln(x)$ using Taylor Polynomial expansion accurate to specified precision. After computing is done, the value compared to the number that WolframAlpha provides to check if the error estimation was made right. for $x \ge 0.5$ every series I try behave as expected, but for $x\le0.5$ there are problems
Expanding around $a=1$ gives below series valid for $x\in(0;2]$ $$\ln(x)=\sum_{n=1}^\infty \frac{(-1)^{n+1}(x-1)^n}{n}$$
Let's say I need to estimate $\ln(0.25)$ so that the absolute error would be $\le0.00005$ (correct to 4 decimal places). WolframAlpha says $\ln(0.25)=-1.38629436…$

I tried this iterative algorithm: https://www.mathworks.com/matlabcentral/answers/uploaded_files/38169/Part%20B.pdf which uses next polynomial term as error bound. Sadly this is not good enough and stops too early so the actual error is bigger than $0.00005$.

I also tried using Lagrange Error Bound as it represented here: http://math.feld.cvut.cz/mt/txte/3/txe4ea3c.htm at the end of the document it says that "on $(0,1/2)$, the Lagrange estimate is too generous." so for my value of $0.25$ taking as many terms as Lagrange Error Bound says, still does no good (I did check that).

So I decided to try this approach: http://math.colorado.edu/~nowi9933/Math2300F17/2300TPRemainderEstimateSol.pdf [page 4, section (d)]

using $\ln(1+x)$ series valid for $|x|\le1$ $$\ln(1+x)=\sum_{n=1}^\infty \frac{(-1)^{n+1}(x)^n}{n}$$
with Lagrange Error Bound $$\frac{(0.25)^{n+1}}{n+1} \le 0.00005$$
Solving it gives $n\ge5$ terms. And this is also not enough as adding 5 terms gives $ln(x)\approx-1.2984375$ last term being $-0.0474609375$
Above calculations were made with a program in python and though IEEE754 floating point format has its flaws its not the problem in the program but in the math part. I'm quiet surprised that there is almost no information regarding that issue on the internet. I understand that one way wolfram must be getting the value is just adding terms as much as it can, but I need some trustworthy error bounding method. Is there some key point I am missing about this?

Best Answer

A more efficient technique is to avoid Maclaurin/Taylor series (since they tend to converge slowly if not suitably accelerated) and use Beuker-like integrals instead. You are just interested in a tight approximation for $-2\log 2$, and

$$ \int_{0}^{1}\frac{x^m(1-x)^m}{1+x}\,dx $$ for any $m\in\mathbb{N}$ is a number of the form $q_m \pm 2^m\log(2)$ with $q_m\in\mathbb{Q}$, and also an element of $\left(0,\frac{1}{4^m}\right)$. By choosing $m=6$ we get that $\color{red}{\frac{19519}{21860}}$ is a lower bound for $\log(2)$ within an error $<4\cdot 10^{-6}$ and we are done. Even better, we may consider $$ \int_{0}^{1}\frac{P_6(2x-1)}{x+1}\,dx $$ with $P_n$ being a Legendre polynomial, to derive that $\color{red}{\frac{62307}{89890}}$ is an approximation for $\log(2)$ within an error $<7\cdot 10^{-10}$.