# How to visualize infinity points on a DensityPlot3D?

You can see in such a function, there are some points in space in which the value of the function reaches infinity (Those empty areas in the on the x and y axis).

$$\frac{1}{xy},\delta(\mathbf{r}),...$$ The infinity region can be things other than just some points. It may be a disk or a line that in any point of that region, the value is infinity.

ONLY those infinity areas are of my interest! How to visualize that? for example Mathematica colors any region which has infinity value, red.

Can anyone help me?

You can apply a sigmoid function before plotting. It maps the whole interval of real numbers onto [-1,1] interval. A suitable choice is $\tanh(x)$:

DensityPlot[Tanh[1/(x y)], {x, -5, 5}, {y, -5, 5}, MaxRecursion -> 5,
ColorFunction -> "LakeColors", PlotLegends -> Automatic, PlotRange -> {-1, 1}]


which generates: • This is a good way to remove those empty regions. But what I dreamed was, in the plot you pictured, two crossed red lines. Is there any way to achieve that? – AHB Aug 26 '16 at 11:54
• And! Will this sigmod function be dependable for any function inside it? Like dirac delta. – AHB Aug 26 '16 at 11:55
• It failed in 3D functions. :( – AHB Aug 26 '16 at 12:07
• @AHB I cannot test with DensityPlot3D because I have older version of MA. – yarchik Aug 26 '16 at 12:44
• @AHB Do you mean it fails for $\delta(\vec r)$ ? – yarchik Aug 26 '16 at 14:16

Compactify the function with a coordinate transformation $$u=1/x$$ with such a transformation "$x\rightarrow\infty \Leftrightarrow u \rightarrow0$":

DensityPlot[u*v, {u, 1/-5, 1/5}, {v, 1/-5, 1/5},PlotLegends -> Automatic]


Which generates: This is a nice trick to work with infinity in numerics; the only downside is that the legend and the axes are in respect to the transformed coordinates, but with axis label this should be resolvable.

• Are you sure you compactify this way? Where does zero go? – yarchik Aug 26 '16 at 13:11
• Yes you got me; "compactify" might be to strong: sure you get rid of one singularity at $\infty$ and get yourself a new one at $0$. But If your function does not have nulls in the region you are interested in it works. If you have $0$ and $\infty$ you have to use something else like you proposed but if you only have $\infty$ I think working with a coordinate transform like this one gives easier to interpret results: I mean if you look at the $\tanh[f]$ in that case those discontinuities on the axes are certanly an artifact of $\tanh$ and not a feature of $1/(xy)$. – N0va Aug 26 '16 at 13:20
• Sorry to be so pedantic, the discontinuities on the axes are also present in the original function. Fix for instance $y=y_0=1/c$. In this case we have f(x)=$c/x$. And this function is $-\infty$ at $x\rightarrow -0$ and $\infty$ for $x\rightarrow+0$. It is just a remark, each transformation has its strong and weak sides. – yarchik Aug 26 '16 at 14:15