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

Mathematica 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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook