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.

I have a periodic solution from an NDSolve that is producing an InterpolatingFunction. With the default plot settings, there is not enough PlotPoints/MaxRecursion to resolve the peaks in the function:

Plot[myfunc, {t, 0, tgalmax}]

enter image description here

OK, let's increase the PlotPoints, but now there are artifacts:

Plot[myfunc, {t, 0, tgalmax}, PlotPoints -> 10000]

enter image description here

I've also tried the same thing with a ListPlot (generating a table from the function), when I don't join the points, the function looks fine:

ListPlot[Table[{t, myfunc}, {t, 0, tgalmax, tgalmax/10000}]]

enter image description here

But when I join the points (using the same number of points), there are artifacts again:

ListPlot[Table[{t, myfunc}, {t, 0, tgalmax, tgalmax/10000}], Joined -> True]

enter image description here

Anyone know what's going on here?

Let me just add a few things I've tried: I've tried chancing the PerformanceGoal, the WorkingPrecision, MaxRecursion, all still produce the artifacts. Here is a link to the function (Mathematica save format) if you need to see the function itself.

share|improve this question
You could consider setting the InterpolationOrder->1 option in the NDSolve call. This will certainly remove any artifacts. –  Sasha Nov 16 '12 at 4:19
That seems to have done the trick...although I would have thought setting InterpolationOrder->0 in the ListPlot would have the same effect, but it doesn't seem to. –  Guillochon Nov 16 '12 at 4:29
What happens if you add the option setting Method -> {MaxBend -> 1.}? –  J. M. Nov 16 '12 at 5:25
Adding the MaxBend option actually makes the problem a bit worse. It does appear that the issue might be related to the very high-order interpolation returned by NDSolve, which is throwing the plotting routines for a loop. –  Guillochon Nov 16 '12 at 8:28
Plot[Re[Log[Cos[x]] - Log[Sin[x]]], {x, 0, 7}] ? –  belisarius Nov 16 '12 at 12:39
show 1 more comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer


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

Browse other questions tagged or ask your own question.