Why does WolframAlpha give me an ugly graph for the input "(cos x-1)/x^2 when x=0.01"?

118 Views Asked by At

The function $\dfrac{\cos x-1}{x^2}$ is differentiable everywhere except for $x=0$. However, when I give WolframAlpha the input "(cos x-1)/x^2 when x=0.01", it gives me an ugly graph as follows:

enter image description here

What is the point of this graph for $x$ values between $-5.7\times 10^{10}$ to $5.7\times 10^{10}$ while I am asking for the value of $\dfrac{\cos x-1}{x^2}$ when $x=10^{-2}$?

Also, the graph seems to contradict the following:

  1. The function $\dfrac{\cos x-1}{x^2}$ is differentiable everywhere except for $x=0$.
  2. The function $\dfrac{\cos x-1}{x^2}$ is an even function (whose graph should be symmetrical with respect to the $y-$axis.
2

There are 2 best solutions below

0
On BEST ANSWER

The answer might be more complicated that the following. But this is my best guess.

In order for Wolfram Alpha to make a figure, it must sample a finite number of points $(x,f(x))$ and interpolate between those. The function you have, has a lot of ripples. Thus, given the large domain $x$-axis for the figure and the fact only a finite number of points is sampled, the most probable thing is that the samples are not able to capture the behavior of the function.

For example, your function crosses zero every time $\cos(x)=1$ which happens every $2\pi n$ for any integer $n$. However, if the domain is $[-5.7\times 10^{10},5.7\times 10^{10}]$ with length $11.4\times 10^{10}$ units, and you sample, say $10^{10}$ points (which is just too much), you would be sampling every $11.4$ units, most of the time skipping a lot of stuff between, including a zero crossing. Moreover, the sampling period will not be a multiple of $2\pi$ in general, so that samples will catch very irregular values of the function. Assuming that the domain points are not symmetric with respect to zero (even a little bit), you won't see any symmetry in the plot either due to this reason. Thus, the function does not look even.

The most probable thing is that wolfram is sampling with way less than $10^{10}$ points. I think you can even manually count the number of samples in your figure (with linear interpolation between those).

So, my guess is: wolfram may be using a small number of samples to generate that figure (compared with the order of the numbers in the domain). Thus, the figure is just a very bad depiction of what the function really looks like. Hence, the effect you are witnessing is just an artifact of bad plotting. Nothing related to differentiability, or the even character of the function.

Now, why wolfram decided to make such figure with that domain in the order of $10^{10}$? I think that will remain as a mystery. When I click in the wolfram link you provided, sometimes I see what you obtained. But other times I see the following, which doesn't look very bad since the $x$-axis only shows values of a more reasonable order. I don't know under what condition wolfram decides to show one figure or the other. enter image description here

TLDR: bad sampling.

0
On

Round-off error, related to this problem. Try to graph $[\sin (x)/x]^2/[1+\cos(x)]$, in which the ill-conditioned subtraction is removed, and see what happens.