# Function tending to $-\infty$ tends to $+\infty$ in picture given by Plot

I have problems with this function $$f(x) = e^{-x}+\ln(x+5\pi)$$.

I computed the following limit by hand: $$\lim\limits_{x\to-5\pi^+} f(x)=-\infty$$, which I think is correct.

But when I plot this function in Mathematica with the next command:

Plot[Exp[-x] + Log[x + 5*Pi], {x, -5*Pi, 0}]


I get the following:

What am I missing here ?

Edit: Also using the limit command gives the right answer to the limit I wrote ($$-\infty$$), but plot still looks to be wrong. :

Limit[Exp[-x] + Log[x + 5*Pi], x -> -5*Pi, Direction -> 1]

• Do not use the bugs tag unless another user has confirmed that what you observe is indeed a bug. – J. M.'s torpor May 4 '20 at 5:40
• I think not, because $Dom(f) = \] -5\pi, \ infty\[$ – joeren1020 May 4 '20 at 5:46
• You had limit -Infinity first before editing the question.. So I removed the comment. Mathematica says Limit[Exp[-x]+Log[x+5*Pi],x->-Infinity] is +Infinity – Nasser May 4 '20 at 5:46
• I see your point. Still can't figure out what is going wrong here. Maybe Mathematica is taking it as a complex number ? – joeren1020 May 4 '20 at 6:01
• Try the following and you'll know what's wrong: {Exp[5. Pi], Log[10.^(-10^6)], Log[10.^(-10^7)]}. The visualization with Plot remains a challenge though. – xzczd May 4 '20 at 6:10

The exponential function is just really large at at $$-5\pi$$ and the logarithm goes slowly towards $$-\infty$$ at $$-5\pi$$. It's really only a Problem of how to display that properly.

Let's plot the function before the singularity properly.

Plot[Exp[-x] + Log[x + 5*Pi], {x, -5*Pi, -5*Pi + 10^-8}, PlotPoints -> 200, PlotRange -> All]


If you look close enough before the singularity you can see that it does indeed tend towards $$-\infty$$.

Edit

To give an idea of how excruciatingly slow the logarithm goes to $$-\infty$$ look at

Table[{-i, Log[10^-i]}, {i, 0, 20}] // N // TableForm


We're already at $$10^{-20}$$ and yet the logarithm has only fallen to -46. A drop of -46 cannot really be seen when your x range is $$0$$ to $$15.7$$ and your y rang is $$0$$ to $$10^{6}$$

• Nice job there. I'm starting to understand what was going on there. It's really something to be aware of ! – joeren1020 May 4 '20 at 6:55
• I might be wrong but I think something similar happens when trying to plot the derivative of this funcion. This one doesn't contain any logarithm so far since $f'(x)=-e^{-x}+\frac{1}{x+5\pi}$ – joeren1020 May 4 '20 at 7:16
• @joeren While the two cases are similar in nature I would argue that the logarithm exhibits much slower convergence towards $-\infty$. Infact the logarithm does not only grow slower towards $-\infty$ than $1/x$ but also slower than the square root of $1/x$ or its cube root and so on. To make this mathematically precise $\log(x+5\pi)=\mathcal{o}(1/(x+5\pi)^n), a\to -5\pi$ for any $n \in \mathbb{R}^{+}$. – Max1 May 4 '20 at 14:53

Max1 has already given the correct answer. Here I just want to show a possible way to visualize when $$f(x)$$ becomes negative:

data = Table[With[{x = -5Pi + 10^(-10^k)}, {k, Exp[-x] + Log[x + 5 Pi]} // N[#, 16]&],
{k, 1, 8, 1/10}];

ListLinePlot[data, PlotRange->All, ScalingFunctions -> {"Reverse", None},
Ticks -> {{#, -5 Pi + 10^-Superscript[10, #]}&/@Range[8], Automatic}]


Some observations

Plot[Exp[-x] + Log[x + 5*Pi], {x, -6*Pi, -4 Pi},
PlotRange -> {{-6 Pi, -4 Pi}, All}, Exclusions ->None,
PlotPoints -> {100, {-5 Pi}},
Ticks -> {{-6 Pi, -5 Pi, -4 Pi}, Automatic}]


Below $$-5 \pi$$ it is complex valued, so one gets blank plot for x<-5 Pi, at exactly $$-5 \pi$$ it is $$-\infty$$ (singularity) and above $$-5 \pi$$ it is real and large value.

The above plot seems to me to reflect this.

data = Table[{x, N[Exp[-x] + Log[x + 5*Pi]]}, {x, -6 Pi, -4 Pi, Pi/10}];
MatrixForm[data]


I wanted to see how Maple handles this hard plot:

restart;
plot(exp(-x)+ln(x+5*Pi),x=-6*Pi..-4*Pi)


Humm... maybe I should send a bug report to Maple on this :) This really looks very strange result.

• It looks even weider there. Anyway, as Max1 pointed out, by plotting points really (really) close to the singularity the correct tendency (-Infinity) of the function shows up. In any case, it looks a little difficult to figure that out at first glance for somethings that seemed straightforward – joeren1020 May 4 '20 at 6:44