Docsity

Iterative Refinement-Numerical Analysis-MATLAB Code, Exercises of Mathematical Methods for Numerical Analysis and Optimization

Partial preview of the text

Download Iterative Refinement-Numerical Analysis-MATLAB Code and more Exercises Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

function [res] = CHIP(rnd,r,x) % This program is used by Iterative Refinement (Algorithm 7.4) % to round or chop to a specific number of digits. if x == 0 w = 0; else ee = fix(log10(abs(x))); if abs(x) > 1 ee = ee + 1; end; if rnd == 1 w = round(x10^(r-ee))10^(ee-r); else w = fix(x10^(r-ee))10^(ee-r); end; end; res = w ;

docsity.com