What happens to $\frac{\tan\left(\sin x\right)-\sin\left(\tan x\right)}{x^4}$ near $0$

calculusreal-analysis

When I was drawing some interesting graph of functions, I found a strange phenomenon. A function $f(x)=\tan(\sin x)-\sin(\tan x)$ is well defined on $\mathbb{R}-\left\{\left(\frac{1}{2}+n\right)\pi:n\in \mathbb{Z}\right\}$, and it has oscillation near $x=\left(\frac{1}{2}+n\right)\pi$ by the $\sin(\tan x)$ term. It doesn't oscillate near $0$.

And since
$$\lim_{x\rightarrow0}\frac{\tan(\sin x)-\sin(\tan x)}{x^4}=0$$
by taylor expansion, a function defined by
$$g(x)=\begin{cases}\frac{\tan(\sin x)-\sin(\tan x)}{x^4}\quad&\mathrm{if}\quad x\neq 0,\, \left(\frac{1}{2}+n\right)\pi\\0&\mathrm{if}\quad x=0\end{cases}$$

is continuous in it's domain. I guessed that $g$ may oscillate at $x=\left(\frac{1}{2}+n\right)\pi$ and not at $x=0$. However, when I plot the graph of $g$ using Desmos or GeoGebra, there's a strange oscillation near $x=0$. Here is the graph.

graph of the function

The similar phenomenon occurs for $x^5$, $x^6$ instead of $x^4$, and I can't understand why it occurs. I tried to investigate sign of $g'$ and get a supremum of $g$ near $0$, but both didn't give me useful information because of complicated calculation. Why this strange oscillation occurs near $0$? Or it's just a numerical error? Any ideas will be appreciated.

Best Answer

This is underflow. You are taking the difference between two functions and dividing by $x^4\approx 10^{-16}$. If either of your first numbers has been rounded off by $10^{-20}$, that will cause the error around $0.0001$ that you saw.
Floating point numbers almost always have tiny errors because they are approximated by nearby numbers whose denominator can only be a power of $2$. These errors don't usually matter, down in the 20th decimal place. You have managed to make the errors significant.

Related Question