Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This is an example, I plot a function and find it has a defect when x approximates 400.

Plot[Cos[.3 x] Exp[-0.01 x], {x, 0, 1000}, PlotRange -> All]

Mathematica graphics

Another example, we calculate the orbit of planet motion. As we know, the orbit of planet is ellipse when the total energy is negative. However, if we calculate it in a long time, the result will deviate from ellipse markedly - while Mathematica has no any warning or message here!

The code and result showed below:

M = 4; a = 700; (*a is the total time of this simulation*)
s = 
    NDSolve[{x''[t] == -((GM (x[t] + 1))/((x[t] + 1)^2 + y[t]^2)^1.5), 
             y''[t] == -((GM y[t])/((x[t] + 1)^2 + y[t]^2)^1.5), y[0] == 2, 
             x[0] == .3, x'[0] == .2, y'[0] == -.1}, {x, y}, {t, 0, a}, 
             MaxSteps -> 10^8];
ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, a}]

enter image description here

What I wonder is how to make sure Mathematica's result is exactly correct? When we find something special with Mathematica, how can we know it is a new thing, or just a wrong result of Mathematica?

share|improve this question
4  
3  
A good start is understanding proper use of Mathematica, how built-ins (and their options) work, etc. (e.g. PlotPoints, MaxRecursion and Method in your plot visualization example). The documentation is pretty good pointing out gotchas and their effects and ways to avoid them. –  rasher Jun 24 at 6:02
    
For me, a good approach would be also to use another, redundant, tool- for those extremely important results. –  VividD Jun 24 at 10:37

1 Answer 1

up vote 3 down vote accepted

Simply increase PlotPoints:

Plot[Cos[.3 x] Exp[-0.01 x], {x, 0, 1000}, 
 PlotRange -> {{300, 500}, {-0.05, 0.05}}, ImageSize -> 600, PlotPoints -> 2000]

enter image description here

Increasing PlotPoints would also draw a smooth ellipse in your orbit example

share|improve this answer
    
I am sorry, but this does not attempt to answer the question. –  Sektor Jun 24 at 12:49
1  
@Sektor - I am sorry too, but my tip attempts to answer the question. Using Plot and ParametricPlot YOU have to decide how many PlotPoints you want or need. When you use Table and then ListLinePlot with the above example you get the same smooth image, i.e. the numerics are correct. –  eldo Jun 24 at 13:02
1  
@Sektor - I now answer the question: "How to make sure Mathematica's result is exactly correct?" Answer: With pencil and paper like in the good all days :) –  eldo Jun 24 at 13:15
1  
I think this answers the issue that caused the question (+1). The title of the question is too broad to allow a better answer. –  Jens Jun 24 at 17:40
1  
@VividD I think your opinion is appropriate. –  S.Lai Jun 25 at 9:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.