0
$\begingroup$

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:

enter image description here

$\endgroup$
2
$\begingroup$

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]
$\endgroup$
  • $\begingroup$ Thanks but, why do I have to specify the Reel and Imaginary ? $\endgroup$ – Sebastien Comtois Jan 27 '16 at 18:07
  • $\begingroup$ by the way, thanks for the edit on my question, i'm not used to this yet. $\endgroup$ – Sebastien Comtois Jan 27 '16 at 18:11
3
$\begingroup$

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

Mathematica graphics

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

Limit[expr, x -> Infinity]

Mathematica graphics

which is approximately $0.266012 - 1.0472 i$.

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

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.