Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

Relative and absolute tolerance definitions in Matlab solver

Date: 2022-07-19 10:46:08

I am trying to understand the following Matlab definitions for RelTol and AbsTol parameters: 

 

RelTol — This tolerance is a measure of the error relative to the size of each
solution component. Roughly, it controls the number of correct digits in all 
solution components, except those smaller than thresholds AbsTol(i).The default,
1e-3, corresponds to 0.1% accuracy.

AbsTol — AbsTol(i) is a threshold below which the value of the ith solution 
component is unimportant. The absolute error tolerances determine the accuracy 
when the solution approaches zero. 
  
I do not understand why AbsTol determines the accuracy when the solution approaches zero (indeed, if the solution of my problem is a circular orbit of 7000 km radius this does not meet it) and why RelTol controls the number of correct digits in all solution components, except those smaller than thresholds AbsTol(i). What are the actual expressions for determining each tolerance? I would like to get simpler and understandable definitions.

Expert Answer:

14
 

When you perform an optimization, you need to decide when to stop. One way to check for whether your solution is good enough is to check whether the solution is still changing significantly. There are two ways to measure how much a solution changes: relative change (i.e. % change), or absolute change.

It makes a lot of sense to check for relative change, since a change of 5 means something very different when the solution is around 1 than when it is around 100000. Thus, the optimization routine checks, at every iteration i whether abs(1-x(i)/x(i-1))<relTol, i.e. by what fraction the new solution has changed since the last iteration. Note that x can be an array of solutions if you're optimizing multiple parameters at the same time (the solution thus has "multiple components"). Of course, you want the condition to be fulfilled for all "solution components" before you stop optimizing further. 

The relative tolerance, however, becomes problematic when the solution is around zero, since x/0 is undefined. Thus, it makes sense to also look at the absolute change in value, and quit optimizing when abs(x(i)-x(i-1))<absTol. If you choose absTol small enough, it will only be relTol that counts for large solutions, while absTol only becomes relevant if the solution comes to lie around 0.

Since the solver stops when either of the two criterion is fulfilled, how close you get to a (locally) optimal solution is determined by absTol or relTol. For example, if relTol is 10%, you will never get much closer than 10% to the optimal solution, unless your solution is around zero, in which case the absTol criterion (of, say, 0.0001) is satisfied before the relTol criterion.

Why Matlabhelpers ?

Our Matlab assignment helpers for online MATLAB assignment help service take utmost care of your assignments by keeping the codes simple yet of high-quality. We offer the most reliable MATLAB solutions to students pursuing their Computer Science course from the Monash University, the University of Sydney, the University of New South Wales, the University of Melbourne; to name a few. Approach us today for best Matlab solutions online!

Our Comprehensive Matlab Assignment Help Services

Personalized Tutoring:Our team of MATLAB experts offers one-on-one tutoring sessions tailored to your specific needs. Whether you’re struggling with basic concepts or advanced algorithms, we provide clear, step-by-step guidance to help you understand and master MATLAB.

Assignment Assistance:Facing tight deadlines or complex assignments? We’re here to help! From initial problem analysis to code development and debugging, we offer full-spectrum support to ensure your assignments meet the highest standards.

Project Development: Need help with a research project? Our specialists can assist you in designing and implementing robust MATLAB solutions. We cover everything from project planning and data collection to coding, simulation, and result analysis.

Coursework Support: We provide comprehensive support for your coursework, helping you understand lectures, complete lab exercises, and prepare for exams. Our goal is to ensure you grasp the core principles and practical applications of MATLAB.

Thesis and Dissertation Guidance:Writing a thesis or dissertation? Our experts can assist you in incorporating MATLAB for data analysis, modeling, and simulation. We help you develop a strong methodological framework and ensure your research stands out.

whatsApp order on matlabhelpers.com

telegram order on matlabsolutions.com