What happens if I set both RelTol and AbsTol for ODE45 and/or both TolX and Tolfun for FSOLVE?
3 views (last 30 days)
Show older comments
I'm solving an eigenvalue problem via a combination of ODE45 and FSOLVE, and I'm not sure what happens if I set both RelTol and AbsTol for the former and both TolX and Tolfun for the latter. Do these functions refine steps, etc. until both requirements are satisfied or only one of them?
0 Comments
Answers (1)
Torsten
on 26 Jan 2025
Edited: Torsten
on 26 Jan 2025
Do these functions refine steps, etc. until both requirements are satisfied or only one of them?
Both.
Read about error control for ode45 here
and for fsolve here
But you should start with the default settings - a reasonable specification is sometimes subtle, especially if two solvers interact.
3 Comments
Torsten
on 26 Jan 2025
I might add that I ran some experiments (by solving the equation x^2-1=0 with various values of TolX and TolFun) -- and the results suggest it's either/or, but I'd like to be sure.
I agree (see the text in italics):
From the documentation:
TolFun — Termination tolerance on function value
1e-4 (default) | nonnegative scalar
Termination tolerance on the function value, specified as the comma-separated pair consisting of 'TolFun' and a nonnegative scalar. Iterations end when the current function value differs from the previous value by less than TolFun, relative to the initial function value.
TolX — Termination tolerance on x, the current point
1e-4 for fminbnd and fminsearch, eps for fzero, 10*eps*norm(c,1)*length(c) for lsqnonneg (default) | nonnegative scalar
Termination tolerance on x, the current point, specified as the comma-separated pair consisting of 'TolX' and a nonnegative scalar. Iterations end when the current point differs from the previous point by less than TolX, relative to the size of x.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!