Mathematica plots wrong

  • #1
114
0
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?
 

Answers and Replies

  • #2
1,015
70
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.
 
  • Like
Likes 1 person

Related Threads on Mathematica plots wrong

Replies
4
Views
4K
Replies
1
Views
3K
  • Last Post
Replies
1
Views
1K
Replies
3
Views
4K
Replies
1
Views
3K
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
4
Views
2K
Replies
1
Views
793
Top