# Graph plotted in W|A but not Mathematica

This Mathematica code gives me a blank graph but if I run it on W|A I get a result. Why?

Plot[-1/3*
Log[(Exp[-3] - Exp[-3*x]*(3/2*x + 1))/(Exp[-3*x] - 2*Exp[-3]) +
Exp[-3] + Exp[-3*x/Sqrt[Exp[1]] - 1/2]], {x, 0, 200000}]


This is what I get on W|A:

I suspect that W|A is a bit more forgiving in its interpretation of commands, and thus allows complex functions, whereas Mathematica expects a real function and thus has difficulty with a complex one. If you try Plot[Sqrt[x], {x, -2, 2}] in Mathematica you will not get the imaginary values for $x<0$.

Accordingly, this works for the posed problem:

Plot[Re[-1/3*
Log[(Exp[-3] - Exp[-3*x]*(3/2*x + 1))/(Exp[-3*x] - 2*Exp[-3]) +
Exp[-3] + Exp[-3*x/Sqrt[Exp[1]] - 1/2]]], {x, 0, 200000},
PlotRange -> All]


and

  Plot[Im[-1/3*
Log[(Exp[-3] - Exp[-3*x]*(3/2*x + 1))/(Exp[-3*x] - 2*Exp[-3]) +
Exp[-3] + Exp[-3*x/Sqrt[Exp[1]] - 1/2]]], {x, 0, 200000},
PlotRange -> All]

• Thanks but, why do I have to specify the Reel and Imaginary ? – Sebastien Comtois Jan 27 '16 at 18:07
• by the way, thanks for the edit on my question, i'm not used to this yet. – Sebastien Comtois Jan 27 '16 at 18:11

You should realize that your expression is complex-valued in the interval that you specified. Plot does not handle the plotting of complex numbers, so it returns unevaluated. Alpha, on the other hand, autonomously decides to plot the real and imaginary parts of your expression separately.

In order to get Mathematica to do the same, the easiest way is to use the ReIm function, which produces a list of the real and imaginary parts of its argument.

I also wonder if you noticed that your expression exhibits "interesting" behavior for small values of x, but is then asymptotic at large x, as shown by David above.

For instance, for small $x$ you can obtain:

expr = -1/3*
Log[(Exp[-3] - Exp[-3*x]*(3/2*x + 1))/(Exp[-3*x] - 2*Exp[-3]) +
Exp[-3] + Exp[-3*x/Sqrt[Exp[1]] - 1/2]];

Plot[Evaluate@ReIm@expr, {x, 0, 4}]


For large $x$, your expression has asymptotic behavior:

Limit[expr, x -> Infinity]


which is approximately $0.266012 - 1.0472 i$.

• Thank you really much. I love the graph, and the way you got it. Kind of new for me. Thanks – Sebastien Comtois Jan 27 '16 at 22:33