Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica plots wrong

  1. Jun 30, 2014 #1
    I said to Mathematica to plot a graph as this:

    Plot[Exp[-Sqrt[-x]] + Exp[Sqrt[-x]] - 2 == 0, {x, -10, 40}].

    You can see that there is square root of -x, which should mean that the function is defined only for x<=0. But no, Mathematica would plot a curve also for positive values of x. How is this possible at all?
  2. jcsd
  3. Jun 30, 2014 #2
    Note that when x > 0, we have Exp[-Sqrt[-x]] + Exp[Sqrt[-x]] = Exp[-iSqrt[x]] + Exp[iSqrt[x]] = 2Cos[Sqrt[x]], which is defined and a real number for all real values of x > 0. The latter equality is a result of Euler's formula.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Mathematica plots wrong Date
Mathematica Cannot Plot This Function in Mathematica Feb 26, 2018
Is the integral for current correct? Jul 7, 2017
Mathematica Plot Real Portion (Contour Plot) Jun 21, 2017
Mathematica Add a rectangle to a plot to indicate range Jun 15, 2017
Mathematica Part of complex plot disappears [mathematica] Apr 19, 2017