# Artifacts in Line Plot from InterpolatingFunction

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}]


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

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


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}]]


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]


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.

-
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.}? –  Ｊ. Ｍ. 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