MATLAB: need help understanding ode45 and what it does.

edited April 2010 in Science & Tech
I am using the MATLAB solver 'ode45' to write a program that solves a coupled system of 1st order odes. I am unclear as to how exactly ode45 works - I know it implements the Dormand-Prince method, so am I right in thinking that our solution has 4th order accuracy?
To ensure I obtain an answer of 6 decimal place accuracy using this method am I right in thinking 'AbsTol' (absolute tolerance) should be set to 5e-7? I am also unsure of what I should set 'RelTol' (relative tolerance) to(without knowing the answers first), and what stepsize I should use to achieve this result. (I know 'ode45' adjusts step size according to the parameters set in 'options' if you don't specify what step-size you want to take for the input variable.)
Much help would be appreciated. Thank you :)

Comments

  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited April 2010
    You're using a Runge-Kutta method for numerical integration and the Dormand-Prince method will only give you error as the difference between the 5th order solution and the 4th order solution. Decimal place accuracy is independent of order and has more to do with the size of the coefficients in your system as well as the integration step size. The ode45 solver will computer a step size appropriate for your problem based on your error tolerances.

    Your use of tolerance is incorrect. AbsTol forces the solver to evaluate solutions that are smaller than that tolerance (i.e. if you know your solution is going to be close to zero, you need to force the solver to evaluate terms of smaller magnitude than what MATLAB considers numerical zero.) The way you have it written, MATLAB will attempt to evaluate solutions to the system that appear to be zero but in actuality are larger than 5e-7. Relative tolerance is where you should set your constraints on precision but keep in mind that error is evaluated as RelTol * abs(y(i)) so if you have large solutions you need to shape RelTol such that when multiplied you get at least 1e-7 (for 6-place precision.) Odds are you will need to repeat your solution a few times to get your parameters set up correctly.
Sign In or Register to comment.