Using ODE113 in steps vs in one go

2 views (last 30 days)
David
David on 12 Sep 2013
I'm using the ODE solver ODE113 to solve the equation of motion of an ion moving in a time-dependent potential. I have tried two methods.
1) Firstly I split the time of the experiment up into chunks and solved the EOM for each chunk taking the initial conditions to be the solution to the previous chunk. This enabled me to print my solution to the screen as I found it. So something like this:
for t=dt:dt:t_f
[~,X] = ode113(@ode3,[t-dt,t],u0);
u0 = X(end,:);
end
2) Secondly I solved it in one go asking MATLAB to tell me the position of the ion at some specified times. So something like this:
[~,X] = ode113(@ode3,0:dt:t_f,u0);
The latter is quicker, but it also gives me a solution that is not very different but different enough to be significant for my purposes.
My question is, computation time aside, which method is more reliable/accurate?

Accepted Answer

Jan
Jan on 12 Sep 2013
Edited: Jan on 12 Sep 2013
Restarting the integrator requires a new initialization of the step-size control. Therefore running the complete interval at once will be more accurate.
Other integrators can reply the status of the step-size control, orders of the applied methods etc., such that restarting requires less warm up and less loss of performance and accuracy in consequence. But Matlab's integrators do not have this feature as far as I know. But you can easily expand the code, when you need this.
When you need to control the accuracy of the results, be sure to determine the sensitivity of the results for small variations of the inputs. This can be done either by external or internal differentiation. For the first one, the input is varied (no modifications of the integrator), for the second one the variation is applied in each step and multiplied (integrator must be modified).
By this way you can measure which solution is more accurate.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!