How does choosing more stringent RelTol and AbsTol values in ode45 compare with choosing finer tspan integration time-steps?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Noob
el 9 de Oct. de 2020
Hi,
So I modified my ode45 error tolerances, both RelTol and AbsTol, to be at 1e-10. 1e-14 or so seems to be the most stringent value. Can I further "add more accuracy", by choosing finer tspan time-steps, say, tspan = linspace(0,10, 20,000)? Or does adding finer time-steps just bring back more solutions, but with the same accuracy, and with the same error tolerances satisfied? For example, if I play with the simple differential equation xdot = cos(t), with initial condition x(0) = sin(0) = 0, I want to see how close the solution y = sin(t) can get to 0, near pi = 3.14...
However, adjusting the RelTol and AbsTol values to be more stringent doesn't seem to help; the time-steps still aren't fine enough, and t gets to about 3.143143143143143, and so y(t) = sin(t) is not actually very close to 0, for my needs. It is only when I add finer integration time-steps, in the tspan setting, does t get much closer to approximating pi, and thus y = sin(t) gets much closer to the value of 0.
Should I simply use a combination of both, i.e. choose stringent error tolerances as well as finer tspan timesteps, in order to get the most accurate solutions? My motivation for studying RelTol, AbsTol, and tspan time-steps is to eventually return to root-finding practice using Matlab's fsolve, so this is an important digression from multivariable root-finding.
Thanks,
0 comentarios
Respuesta aceptada
Walter Roberson
el 9 de Oct. de 2020
Adding finer time steps just brings back more solutions with the same accuracy.
ode45() does not typically evaluate at the exact locations given in the tspan, other than the first and last one. Instead, when it crosses a time listed in tspan and is satisfied that the step met accuracy conditions, then it synthesizes outputs for the tspan element. It would not have accepted the step unless it thought the results were within the tolerance, so it has no reason to subdivide the interval looking for a potentially more accurate solution.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!