7
$\begingroup$

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:

plot

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]
$\endgroup$
5
  • $\begingroup$ Do not use the bugs tag unless another user has confirmed that what you observe is indeed a bug. $\endgroup$ May 4, 2020 at 5:40
  • $\begingroup$ I think not, because $Dom(f) = \] -5\pi, \ infty\[$ $\endgroup$
    – joeren1020
    May 4, 2020 at 5:46
  • $\begingroup$ 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 $\endgroup$
    – Nasser
    May 4, 2020 at 5:46
  • $\begingroup$ I see your point. Still can't figure out what is going wrong here. Maybe Mathematica is taking it as a complex number ? $\endgroup$
    – joeren1020
    May 4, 2020 at 6:01
  • $\begingroup$ 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. $\endgroup$
    – xzczd
    May 4, 2020 at 6:10

3 Answers 3

10
$\begingroup$

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]

enter image description here

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

Log

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}$

$\endgroup$
3
  • $\begingroup$ Nice job there. I'm starting to understand what was going on there. It's really something to be aware of ! $\endgroup$
    – joeren1020
    May 4, 2020 at 6:55
  • $\begingroup$ 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}$ $\endgroup$
    – joeren1020
    May 4, 2020 at 7:16
  • 1
    $\begingroup$ @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}^{+}$. $\endgroup$
    – Max1
    May 4, 2020 at 14:53
3
$\begingroup$

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}]

enter image description here

$\endgroup$
2
$\begingroup$

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}]

Mathematica graphics

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]

Mathematica graphics

I wanted to see how Maple handles this hard plot:

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

Mathematica graphics

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

$\endgroup$
1
  • $\begingroup$ 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 $\endgroup$
    – joeren1020
    May 4, 2020 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.