5
$\begingroup$

This is what I mean (note the labels in the x axis):

infinity plot

The reason I'm looking at this problem is because I've always felt something was not right with truncated plots (e.g. of the exponential function, or functions with asymptotes) where the curve tends to infinity in one (or both) of the axes. I think it would be nice to have a plot that could contain the full range of a function, from $-\infty$ to $\infty$.

A log-log plot where the scale doesn't increase monotonically, but instead is symmetric about the origin, is close to a solution, and it can be obtained, for example, with matplotlib's "symlog" scaling option. However, such plots still need to be truncated somewhere. Ideally, to map an infinite range to a finite plot length, a sigmoid function is needed.

I could find a couple examples of this in practice, namely here and here (where I took the above image from).

At least the first of those uses the arctangent function to do the sigmoid scaling, but I wondered if there was a particular sigmoid function that is special, the same way the exponential function is the natural exponential curve. I didn't know exactly how to evaluate that, so I looked at these options and picked the one with the simplest mathematical representation: $\frac{x}{|x|+1}$.

Since the scaling was applied to both the x and y axes, this resulted in a nice plot for $f(x)=x$, as expected:

plot of y=x

but the plot for $f(x)=x^2$ wasn't as alike the original one near the extremes: plot of y=sqrt(x)

and particularly the plot for $f(x)=e^x$ had a peculiar shape I wished was closer to the original (i.e. plotted in a linear scale):

plot of y=exp(x)

It looks like the slope of the sigmoid function I chose eventually surpasses that of the exponential function, so instead of approaching infinity from the bottom (so we can see that $y$ grows faster than $x$), it approaches it from the left, making it look that at some point $x$ starts to grow faster than $y$.

I tried the other sigmoid functions mentioned in the image above, but they had the same effect, or worse, in the shape of the exponential. So my question is: is there a way to compress the infinite range of a function into a finite length of a plot that allows preserving the overall shape of the exponential function (and hopefully others too)?

Additionally, I'd appreciate if you could also tell me whether there is a "natural" sigmoid function, or at least what you would consider to be the best approximation of such a thing.

$\endgroup$
  • $\begingroup$ The error function gives a sigmoid shape $\endgroup$ – Ali Caglayan Jan 21 '15 at 16:43
  • $\begingroup$ @Alitzer, yes, that is one of the sigmoid functions in the image above (commons.wikimedia.org/wiki/File:Gjl-t%28x%29.svg), and therefore I did try it too (as mentioned in the second-to-last paragraph). $\endgroup$ – waldyrious Jan 21 '15 at 16:47
  • $\begingroup$ I think the purpose of a graph is to visualize the effect of a function. Do you feel any of those you've produced do a better job of that than just truncating? $\endgroup$ – Matthew Leingang Jan 21 '15 at 16:58
  • $\begingroup$ You won't be able to make the exponential look exponential using the same scaling on both axes, since of course the exponential function grows much faster in one direction than the other. $\endgroup$ – Kevin Carlson Jan 21 '15 at 17:10
2
$\begingroup$

I suspect there is no natural sigmoid function that will "preserve" in some sense your original function $f$.

In all generality, you want to "squeeze" the real line ($\mathbb{R}$) into an (open) interval of the form $(x_1,x_2)$. Let's try to squeeze both the $x$-axis and the $y$-axis so that we may fit one graph into a rectangle. Let this rectangle be, for simplicity, $(-a,a)\times(-b,b)$ where $a$ and $b$ are positive.

Let $D$ be the domain of $f$ and $R$ be its codomain (for the sake of simplicity, let's think of $R$ as $\mathbb{R}$)

To squeeze the $x$-axis we really need a function $\varphi:\ (-a,a)\longrightarrow D$, so that when we graph $f\circ\varphi$ we'll need to see what that thing does only on the interval $(-a,a)$.

To squeeze also the $y$-axis, we need another function $\psi:R\longrightarrow(-b,b)$. The end result is then \begin{equation} \tilde{f}:=\psi\circ f\circ\varphi \end{equation} Its graph will be contained in the rectangle $(-a,a)\times(-b,b)$.

The tricky part, as you pointed out, is finding the "right" sigmoid function(s). One can try various cocktails. If $D=R=\mathbb{R}$ for instance, one could take \begin{equation} \varphi(x):=k\tan\left(\frac{\pi}{2a}x\right)\qquad\psi(x):=\frac{2b}{\pi}\arctan(x/k) \end{equation} to do the job. Varying the parameter $k$ allows for trying to "match" the original function (for biggish $k$). It really depends on what characteristics of $f$ you want to study.

[EDIT: I personally like viewing functions "wrapped" on a sphere- but it's only an aesthetic approach. Here i posed a question about it.]

$\endgroup$
  • $\begingroup$ Functions such as $\tan$ are used in proofs to show the bijection $\Bbb R \to [0, 1]$. $\endgroup$ – Ali Caglayan Jan 21 '15 at 18:03
  • $\begingroup$ Marco, let's delete these comments to avoid cluttering. $\endgroup$ – Ali Caglayan Jan 21 '15 at 18:08
  • $\begingroup$ Thanks, I hope to be able to explore these pointers soon. As for wrapped representations, I was actually thinking about a toroidal surface using a similar scaling, and from my preliminary sketches, I suspect some interesting shapes will result from projecting the trigonometric functions on it. I'll link to them here when I get the time to play with that some more. $\endgroup$ – waldyrious Jan 27 '15 at 22:11

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.