How does choosing more stringent RelTol and AbsTol values in ode45 compare with choosing finer tspan integration time-steps?
조회 수: 13 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2020년 10월 9일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!