Message Boards Message Boards

How to improve solution accuracy between grid points while solving ODEs with NDSolve fixed grids

Posted 1 month ago

Hello,

I observe that while solving ODEs with NDSolve, using fixed grids, one can obtain very high accuracy at the grid points, but the accuracy is very poor between the grid points. This can be illustrated by the following code:

step=1/10;
step2=1/20;
sol=NDSolve[{u'[t]+u[t]==0,u[0]==1},u[t],{t,0,1},WorkingPrecision->40,Method->{"FixedStep", Method->{"ImplicitRungeKutta","DifferenceOrder"->20}}, StartingStepSize->step, MaxSteps->100000];
unum[tt_]:=(u[t]/.sol/.t->tt)[[1]];
uanal[t_]:=Exp[-t];
error=N[Table[{(i-1)*step2,unum[(i-1)*step2]/uanal[(i-1)*step2]-1},{i,1,20}],20];
ListPlot[error,PlotRange->All]

The plot reveals that at the grid points the relative error is about 10^-40, but between the grid points it is about 10^-7, i.e. it is much bigger.

Is there any way to improve the accuracy between the grid points? Any option to choose a better interpolation in the InterpolationFunction object?

Leslaw

POSTED BY: Leslaw Bieniasz

Try adding the option to NDSolve, InterpolationOrder -> All.

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract