Mathematica Plots Wrong: How is it Possible?

In summary, Mathematica can plot a graph with a function that contains a square root of a negative number, even though the function is only defined for x <= 0. This is possible because when x > 0, the function can be rewritten using Euler's formula as 2Cos[Sqrt[x]], which is defined for all real values of x > 0.
  • #1
nikolafmf
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?
 
Physics news on Phys.org
  • #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.
 
  • Like
Likes 1 person

FAQ: Mathematica Plots Wrong: How is it Possible?

Why is Mathematica plotting my data inaccurately?

There could be several reasons for this. One possibility is that there is an error in the input data. Check to make sure that the data is correctly formatted and that there are no missing or incorrect values. Additionally, make sure that you are using the correct plot type for your data. Another possibility is that there is an issue with your code. Check for any typos or errors in your code that could be causing the incorrect plot.

Is it possible that my computer is causing the incorrect plots?

It is unlikely that your computer is causing the issue, as long as it meets the minimum requirements for running Mathematica. However, if your computer is running low on memory or processing power, it may have difficulty accurately plotting large or complex data sets. In this case, try closing other programs and freeing up memory before running the plot again.

Can incorrect plot settings cause my data to be plotted incorrectly?

Yes, incorrect plot settings can definitely affect the accuracy of your plot. Make sure that you have chosen the appropriate plot type and that all of the settings, such as axis labels and scaling, are correct for your data. You may also want to try adjusting the plot settings to see if it improves the accuracy of your plot.

How can I troubleshoot my incorrect plots in Mathematica?

Start by checking your input data and code for any errors. If everything appears to be correct, try simplifying your code or breaking it down into smaller parts to isolate the issue. You can also consult the Mathematica documentation or online forums for help with troubleshooting specific plot types or issues.

Is it possible to fix incorrect plots in Mathematica?

Yes, it is possible to fix incorrect plots in Mathematica. Once you have identified the issue, you can make the necessary changes to your data or code to correct the plot. You may also want to save your work periodically as you make changes, so that you can easily revert back if needed. It may also be helpful to consult with other Mathematica users or seek assistance from the Mathematica support team if you are having trouble fixing the issue on your own.

Similar threads

Replies
5
Views
2K
Replies
1
Views
1K
Replies
5
Views
2K
Replies
4
Views
648
Replies
1
Views
815
Replies
2
Views
1K
Replies
3
Views
1K
Back
Top