How do you deal with very large and very small numbers for ode45?

4 views (last 30 days)
Hi there,
I am using the ODE45 function in matlab and am having to do some calculations where the time scale is on the order of 10^-15s (femto seconds) but the period of oscillations are of the order of femto seconds too.
The problem is is that when I start putting this in to the ODE45 routine, it never finishes and I have to ctrl-c it.
I am new to modelling so if there are any good techniques to keep in mind that would be great if you could point them out.
Thanks Martin

Accepted Answer

Jan
Jan on 30 Jan 2013
Edited: Jan on 30 Jan 2013
The simplest solution would be to scale the time by a factor of 1e15. This must be considered in the function to be integrated also, but it is very easy to calculate the corresponding derivatives to the time.
But there could be other problems, e.g. if you want to observe a timespan of e.g. 1 sec. Then oscillations in the magnitude of 1e-15 will require about 30'000 years of processing time, when ODE45 can solve the dynamics with 2000 steps per second.
  1 Comment
Martin
Martin on 30 Jan 2013
Thanks, I thought about that when I realised the ode45 was going to have to do so many loops going from t0=0 to tf=10 seconds in steps of the order 1e15! I'll try it, again thanks!

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!