MATLAB: need help understanding ode45 and what it does.
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
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
0
Comments
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.