# understanding logarithmic scale in a graph

I plotted the function $$1000\sin{\frac{x}{1000}}$$ on desmos and set it to the logarithmic scale but I am having trouble understanding the result which looks like this:

Why does the graph go linear for the first part and the become so condensed right after that?

Also if I set X axis as linear and Y axis as logarithmic the why does this shape appear?

• This is not a function where it makes sense to use log scales. You have just made a big, slooow sine wave. Your program cannot show you much on log scale here, it is transitioning near 1000 from barely changing to so scrunched you see nothing. The picture is inaccurate because the scale and downsampling to resolution force weird visuals, nothing more. Apr 17 at 1:49
• $\sin (x)$ is approximately $x$ for values near $0$. The linear portion reflects that. The condensed portion should be oscillating between $\pm 1000$ so the graph doesn't reflect what the function is doing. I expect there is some loss of detail due to the extremely large scale. Apr 17 at 1:49
• @CyclotomicField The function takes negative values, so I assume the program is actually plotting its absolute value in log-scale. Apr 17 at 11:50

If you have a graph $$y=f(x)$$, then its log-log plot is the plot of $$(X, Y)$$ with $$X=\log_{10}x$$ and $$Y=\log_{10}y$$. So, in terms of $$X$$ and $$Y$$, you are essentially plotting $$Y=\log_{10}f(10^X).$$

So, consider the following graph of $$y = f(x)$$ with $$f(x) = 1000\sin\left(\frac{x}{1000}\right)$$.

Parts of the graph corresponding to $$f(x) \leq 0$$ is drawn as dotted curves, because they do not appear in its log-log-plot counterpart. Now, let's see how this graph would look like in log-log plot:

As you can see,

1. Parts of the graph $$y = f(x)$$ with negative values do not appear in its log-log plot, because the logarithm of a negative value is not a real number.

2. The initial "linear" part comes from the graph of $$y = f(x)$$ with small positive $$x$$ and $$y$$. In this regime, the asymptotic relation $$\sin(a) \approx a$$ for $$|a| \ll 1$$ tells that $$f(x) \approx 1000 \cdot \frac{x}{1000} = x$$ for small positive $$x$$, hence $$Y = \log_{10}f(10^{X}) \approx \log_{10}(10^{X}) = X$$ for large negative $$X$$.

3. When $$X$$ is large, its change in small values corresponds to larger changes in the values of $$x$$. So, originally equally sized intervals in $$x$$-domain will look more and more compressed in $$X$$-domain, explaining that the peaks in the log-log plot becomes narrower as $$X$$ grows.

For more dramatic comparison, below depicts the graph of $$y = f(x)$$ for $$0 \leq x \leq 30000\pi$$,

and its log-log plot counterpart,

Below is a transition from the usual plot to its log-log plot:

• Well this does answer my first part but what about when only y is in log scale and x is linear? Apr 17 at 5:21

First of all, that function takes negative values, so I assume that what your program actually plots is its absolute value, $$|f(x)|$$, or rather $$\log |f(x)|$$ because of the log scale on the $$y$$-axis.

The shape in the second plot looks correct to me: when $$f(x) \to 0$$, $$\log f(x) \to -\infty$$, so the logarithmic plot approaches $$-\infty$$ as a vertical asymptote when $$x$$ is equal to a solution of $$f(x)=0$$, i.e., $$x = k1000\pi$$ for $$k\in\mathbb{Z}$$.

@Sangchul Lee's answer already explains why the first plot has a left part that is essentially the identity function (since $$f(x)\approx x$$ for small values of $$x$$) and a right part that oscillates wildly between $$\log 1000$$ and $$\log 0 = -\infty$$.

However, the ragged lower edge in the right part of the first plot reflects the approximations in the floating-point arithmetic used to compute the function, instead of the true behavior of the function. It is probably incorrect, and I would not trust it at all. Note that the diagonal edge of that red triangle corresponds to about $$10^{-16}x$$. Seeing (relative) errors of the order of $$10^{-16}$$ is a clear indication of floating-point inaccuracies: $$2.2 \times 10^{-16}$$ is the machine precision of the most common floating point format, IEEE754's float64 (also known as "double precision").

In the correct plot, you would see a whole red half-strip that goes down to $$-\infty$$, not just a triangle; this comes from the fact that $$|f(x)|$$ oscillates between the values $$0$$ and $$1000$$ many times.