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?

  • 4
    $\begingroup$ Related, I believe: When I can assume that all decimal digits returned by Mathematica are provably correct? $\endgroup$
    – Mr.Wizard
    Commented Jun 24, 2014 at 5:45
  • 3
    $\begingroup$ 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. $\endgroup$
    – ciao
    Commented Jun 24, 2014 at 6:02
  • $\begingroup$ For me, a good approach would be also to use another, redundant, tool- for those extremely important results. $\endgroup$
    – VividD
    Commented Jun 24, 2014 at 10:37

1 Answer 1


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

  • $\begingroup$ I am sorry, but this does not attempt to answer the question. $\endgroup$
    – Sektor
    Commented Jun 24, 2014 at 12:49
  • 1
    $\begingroup$ @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. $\endgroup$
    – eldo
    Commented Jun 24, 2014 at 13:02
  • 1
    $\begingroup$ @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 :) $\endgroup$
    – eldo
    Commented Jun 24, 2014 at 13:15
  • 1
    $\begingroup$ I think this answers the issue that caused the question (+1). The title of the question is too broad to allow a better answer. $\endgroup$
    – Jens
    Commented Jun 24, 2014 at 17:40
  • 1
    $\begingroup$ @VividD I think your opinion is appropriate. $\endgroup$
    – S.Lai
    Commented Jun 25, 2014 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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