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 ?

Looking for reliable MATLAB assignment help? Our expert MATLAB tutors deliver high-quality, easy-to-understand solutions tailored to your academic needs. Whether you're studying at Monash University, the University of Sydney, UNSW, or the University of Melbourne, we provide trusted MATLAB assistance to help you excel. Contact us today for the best MATLAB solutions online and achieve academic success!

MATLAB Assignment Help Services

Personalized Tutoring: Get one-on-one guidance from our MATLAB experts. Whether you're tackling basic concepts or advanced algorithms, we provide clear, step-by-step explanations to help you master MATLAB with confidence.

Assignment Assistance: Struggling with tight deadlines or complex assignments? Our team offers end-to-end support, from problem analysis to code development and debugging, ensuring your assignments meet the highest academic standards.

Project Development: Need expert help with your MATLAB research project? We assist in designing and implementing robust solutions, covering project planning, data collection, coding, simulation, and result analysis.

Coursework Support: Enhance your understanding of MATLAB with our comprehensive coursework assistance. We help you grasp lecture concepts, complete lab exercises, and prepare effectively for exams.

Thesis and Dissertation Guidance: Incorporate MATLAB seamlessly into your thesis or dissertation. Our experts provide support for data analysis, modeling, and simulation, ensuring your research is methodologically sound and impactful.

Contact us on WhatsApp for MATLAB help

Contact us on Telegram for MATLAB solutions