Asymptotic for $x\ln(\sin(x))$ as $x\to 0$.

163 Views Asked by At

I need a non-singular way to evaluate $x\ln(\sin(x))$ as $x \to 0$. The limit is zero,but numerically I'm getting NaNs.

How can I find a rapidly computable approximation to $x\ln(\sin(x))$ as $x\to 0$? It appears from the graph that $-C\sqrt{x}$ might be a reasonable approximation, but I'm looking for something more formal.

4

There are 4 best solutions below

0
On

The behaviour as $x\to 0+$ is $$ x\log (\sin x) = x\log x - \frac{1}{6}x^3 + \mathcal{O}(x^5 ). $$ You can derive this by considering $$ \log \left( {\frac{{\sin x}}{x}} \right). $$ This function is analytic near $x=0$, so it can be approximated by power series.

5
On

You can replace $\sin x$ by $x$. But $x\ln(x)$ is asymptotic to... $x\ln x$, and nothing else.

There is no reason to get NaNs. Because even if $x$ is close to the smallest representable positive number, $|\ln x|$ is larger than $1$ and the product is representable.

Did you evaluate with negative $x$'s ?

0
On

A possible approach might be the following. Even if I have not checked any bounds of convergence for the error, which may actually be very loose and $x$ dependent.

Let $x>0$.

First notice that for $x\to 0$ your problem is equivalent to $x\log x$.

Let $y = 1+x$. Then $x\,\log x = (1-y)\log(1-y)$. On $(-1,1)$ you can write $$x\,\log x = -(1-y)\sum_{k=1}^\infty \frac{y^k}{k}\,.$$ It can be shown that such an expression tends to $0$ for $y\to 0$. So you can get $$x\,\log x = -x\sum_{k=1}^\infty \frac{(1-x)^k}{k}\,.$$ Note however that this is not a Taylor expansion around $x=0$. So that for the trunked sums, it is not true that the rest is of order $o(|x|^N)$.

You may eventually write $$x\,\log (\sin(x)) = -x\sum_{k=1}^\infty \frac{(1-\sin(x))^k}{k}\,.$$

0
On

As written, the numerical problem comes from the order of operations $$x \qquad \sin(x) \qquad \log(\sin(x))\qquad x\log(\sin(x))$$ Writing $$x\log(\sin(x))=x \log(x)+ x \log \left(\frac{\sin (x)}{x}\right)$$ you can use $$\log \left(\frac{\sin (x)}{x}\right)=\sum_{n=1}^\infty (-1)^n \frac{2^{2 n-2} \left(B_{2 n}+B_{2 n}(1)\right)}{n \,(2 n)!}\,x^{2n}$$

For $x \in (0,\frac \pi 2)$, using the summation up to $n=4$ that is to say $$\log \left(\frac{\sin (x)}{x}\right)= -\frac{x^2}{6}-\frac{x^4}{180}-\frac{x^6}{2835}-\frac{x^8}{37800}+O\left(x^{10}\right)$$ is extremely good (maximum error of $2.47 \times 10^{-4}$).

You could make it much better (maximum error of $1.30 \times 10^{-6}$) using the Padé approximant $$\log \left(\frac{\sin (x)}{x}\right)=-x^2\,\frac{\frac{1}{6}-\frac{761 }{57420}x^2+\frac{457 }{3617460}x^4} {1-\frac{36 }{319}x^2+\frac{23 }{9570}x^4 }$$