2

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

pancini
  • 20,030
  • 2
    Hint: For $x$ close to $1$, $$\frac{\sin (\pi x)}{1-x}=\sum_{n\geq 0, \text{ even}} (-1)^{n/2}\frac{\pi^{n+1} (x-1)^n}{(n+1)!}$$ So your function has the Taylor expansion $$-\pi +(x-1)+\frac{1}{6} \left(\pi ^3-3\right) (x-1)^2+\frac{1}{3} (x-1)^3+\left(-\frac{1}{4}-\frac{\pi ^5}{120}\right) (x-1)^4+\frac{1}{5} (x-1)^5+O\left((x-1)^6\right)$$ around $1$ – Maximilian Janisch Feb 14 '20 at 00:08

1 Answers1

4

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$$

Ross Millikan
  • 383,099