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,

채택된 답변

Walter Roberson
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.
  댓글 수: 2
Noob
Noob 2020년 10월 9일
Hi Walter,
Ok, thanks so much for your answer.
Have a great day / night.
Noob
Noob 2020년 10월 9일
편집: Noob 2020년 10월 9일
Hi Walter,
For smooth functions cos(t) and sin(t), I currently notice that adjusting RelTol and AbsTol has absolutely no effect on the solutions, say for y(t) = sin(t). The solutions stay the same, even if I made the tolerances more stringent.
Is this to be expected?
(However, choosing finer tspan time-steps brings back finer solutions, which seems desirable for my needs.)
Thanks,

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by