How do I avoid significant rounding error in evaluating $$\frac{\ln(x) - \sin(\pi x) }{1-x}$$
This function causes error as $x\to 1$. How can this be avoided? I tried using taylor's expansion but I am not getting a nice closed form. Please help
How do I avoid significant rounding error in evaluating $$\frac{\ln(x) - \sin(\pi x) }{1-x}$$
This function causes error as $x\to 1$. How can this be avoided? I tried using taylor's expansion but I am not getting a nice closed form. Please help
We can do the two terms in the numerator separately.
$$\frac{\log(x)}{1-x} \approx -1+\frac 12(x-1)-\frac 13(x-1)^2+\frac 14(x-1)^3+\ldots$$ from the usual Taylor series for $\log(1+x)$
$\sin(\pi x)$ goes to zero, canceling the zero in the denominator. The limit of the second term as $x \to 1$ is $\pi.\ \ $ We can just use the Taylor series, defining $y=1-x$ and expanding around $y=0$ $$\frac {\sin(\pi x)}{1-x}=\frac{\sin(\pi(1-y))}y=\frac {\sin(\pi y)}y\approx \pi-\frac 16(\pi y)^2+\frac 1{120}(\pi y)^4+\ldots$$