Prev: Fitting ellipses with dispersion
Next: jpeg2000
From: Math Billy on 9 Apr 2010 13:31 I am using the MATLAB Ode45 Solver to write a computer programme. I am required to obtain a numerical answer to an O.D.E with an accuracy of 6 decimal places: however, I am rather confused about what I should set as the step-size(doesn't ode45 use a 4th order numerical method, so the global error is of O(h^4)? Also, I'm not certain what I should set as the absolute and relative tolerances - shouldn't the absolute tolerance be 5e-7? What about the relative tolerance though? Help would be much appreciated, thank you.
From: Jan Simon on 9 Apr 2010 15:23 Dear Math! > I am using the MATLAB Ode45 Solver to write a computer programme. I am required to obtain a numerical answer to an O.D.E with an accuracy of 6 decimal places: however, I am rather confused about what I should set as the step-size(doesn't ode45 use a 4th order numerical method, so the global error is of O(h^4)? The *local* error is O(h^4)! To control the global error you have to calculate the Wronski-matrix also, which is the sensitivity of the outputs to small variations of the inputs. Matlab's ODE45 cannot directly compute these matrix, but you can vary the inputs manually and compare the results: start e.g. with y0 and y0 + sqrt(eps). The global error can be giantic or tiny depending on the problem. E.g. if you calculate a double pendulum, the chaotic nature of the problem makes is impossible to gain "an accuracy of 6 decimal places"! For a single pendulum with friction, is is nearly impossible to get less than 15 decimal places... > Also, I'm not certain what I should set as the absolute and relative tolerances - shouldn't the absolute tolerance be 5e-7? What about the relative tolerance though? The ODE45 calculates the integral with a 4th and 5th order method. If the absolute and/or relative difference between the two methods exceeds the specified limits, the step size is reduced dynamically. In addition the next step size is estimated such that it is as big as possible (to reduce the accumulation of the rounding errors) and as small as needed (to reduce the local discretization errors). Setting the stepsize to a fixes value would decrease the accuracy of the result ever. If you have a reference solution, vary the absolute and relative error limits until your integration reaches the wanted accuracy of 6 decimals. Without such a "true" solution you can *sometimes* estimate it with a slow integration using tiny relative and absolute local error limits --- but as stated above: For a ill conditioned system the result does not necessarily converge. Good luck, Jan
From: Math Billy on 14 Apr 2010 07:04 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hpnuqo$oga$1(a)fred.mathworks.com>... > Dear Math! > > > I am using the MATLAB Ode45 Solver to write a computer programme. I am required to obtain a numerical answer to an O.D.E with an accuracy of 6 decimal places: however, I am rather confused about what I should set as the step-size(doesn't ode45 use a 4th order numerical method, so the global error is of O(h^4)? > > The *local* error is O(h^4)! To control the global error you have to calculate the Wronski-matrix also, which is the sensitivity of the outputs to small variations of the inputs. Matlab's ODE45 cannot directly compute these matrix, but you can vary the inputs manually and compare the results: start e.g. with y0 and y0 + sqrt(eps). > > The global error can be giantic or tiny depending on the problem. E.g. if you calculate a double pendulum, the chaotic nature of the problem makes is impossible to gain "an accuracy of 6 decimal places"! For a single pendulum with friction, is is nearly impossible to get less than 15 decimal places... > > > Also, I'm not certain what I should set as the absolute and relative tolerances - shouldn't the absolute tolerance be 5e-7? What about the relative tolerance though? > > The ODE45 calculates the integral with a 4th and 5th order method. If the absolute and/or relative difference between the two methods exceeds the specified limits, the step size is reduced dynamically. In addition the next step size is estimated such that it is as big as possible (to reduce the accumulation of the rounding errors) and as small as needed (to reduce the local discretization errors). Setting the stepsize to a fixes value would decrease the accuracy of the result ever. > > If you have a reference solution, vary the absolute and relative error limits until your integration reaches the wanted accuracy of 6 decimals. Without such a "true" solution you can *sometimes* estimate it with a slow integration using tiny relative and absolute local error limits --- but as stated above: For a ill conditioned system the result does not necessarily converge. > > Good luck, Jan Dear Jan Thank you for your reply but isn't a numerical method of order 4 supposed to mean that the local truncation error is proportional to h^5, i.e. of O(h^5)? Just wanting to clarify. Thanks again
|
Pages: 1 Prev: Fitting ellipses with dispersion Next: jpeg2000 |