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.

  • 2
    $\begingroup$ That must be an issue with the softwares since $$g(x) = \frac{1}{{30}}x^3 + \frac{{29}}{{756}}x^5 + \cdots $$ near $x=0$. I used another software to plot $g(x)$ and it looks perfectly fine for $|x|<\frac{1}{2}$ say. $\endgroup$
    – Gary
    Nov 1, 2021 at 4:53
  • $\begingroup$ Which software could plot this well? I want to see the graph. Both Desmos and GeoGebra doesn't work. $\endgroup$
    – sungwpark
    Nov 1, 2021 at 5:00

2 Answers 2


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.


What software/hardware are you using? The problem is when you are doing a "small/small" type of computation on computers, there tend to be a lot of error, as the floating point arithmetic is never precise. In fact, a large part of numerical analysis is about how to handle this problem.

If you use a math software that's more symbolic in nature, you'll be able to see a smooth curve.

E.g., if you type "plot((tan(sin(x))-sin(tan(x)))/(x^4), (x,-1,1))" to https://sagecell.sagemath.org/ and hit evaluate, you'll see Plot

I guess Mathematica will do the same, but I don't have a license for it now.

But if you try to zoom in, try "plot((tan(sin(x))-sin(tan(x)))/(x^4), (x,-0.01,0.01))", you'll see a similar pattern (which really shows the limit of numerical computation):


And WolframAlpha isn't doing any better.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.