Re: How to change time stepsize for Integration

• To: mathgroup at smc.vnet.net
• Subject: [mg33973] Re: How to change time stepsize for Integration
• From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
• Date: Thu, 25 Apr 2002 02:59:43 -0400 (EDT)
• Organization: Universitaet Leipzig
• References: <aa5gkf\$c09\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi,

Mathematica's NDSolve[] has an stepsize control and you
can use a higher AccuracyGoal to force smaller step sizes.

>
> Can anyone help me on this one:
>
> Pends[init_, time_, {c_, w_, p_}] :=
>     Module[{},
>       pend = NDSolve[{x''[t] + c x'[t] + (1 + p Cos[w t])Sin[x[t]] == 0,
>             x[0] == init[[1]], x'[0] == init[[2]]}, {x}, {t, 0, time},
>           MaxSteps -> 200000];
>       xd[t_] := x[t] /. pend[[1]];
>       xdd[t_] := x'[t] /. pend[[1]];];
> c = 0.1; w = 0.30; p = 1.1;
>
> Pends[{1.37, 0}, 5000, {c, w, p}];
> plt = Plot[{t, xd[t], xdd[t]}, {t, 0, 500}];
>
> I want to reduce the time stepsize
> in my numerical integration with mathematica. Each time
> I try to get coordinates generated from the command
> Plot[ ......, {t, tmin, tmax}]; or
> Table[......, {t, tmin, tmax}];
>
> I always notice that in all these case time stepsize = 1.

This ist nonsense ! Mathematica use for the problem above
an averaged stepsize of 0.136597. All steps can be obtained by
time = xd[t][[0, 3, 1]];
timeStepSizes = Drop[RotateLeft[time] - time, -1];

> Is there anyway I can reduce the the timestep to say,
> time stepsize =0.001 in the above numerical integration using
> NDsolve.

Lower the MaxStepSize. But forcing a initial value solver
to use a lower step size will typical generate less
accurate results and run 100 x longer

The steps in Table[] and Plot[] have *nothing* to do
with the integration steps of NDSolve[]. For Plot[]
you must set the PlotPoints option, for Table[] you must
set the increment explicit

Table[......, {t, tmin, tmax,dt}]

Regards
Jens

```

• Prev by Date: Re: Re: Why these graphs differ?
• Next by Date: RE: Re: Pattern matching
• Previous by thread: Re: How to change time stepsize for Integration
• Next by thread: Help... Algorithm