New version page

Matlab’s Loss is Nobody’s Gain

Upgrade to remove ads

This preview shows page 1-2-17-18-19-35-36 out of 36 pages.

Save
View Full Document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience

Upgrade to remove ads
Unformatted text preview:

Matlab’s Loss is Nobody’s Gain Created Aug. 1998, revised July 31, 2004http://www.cs.berkeley.edu/~wkahan/MxMulEps.pdf Page 1/36 Matlab’s Loss is Nobody’s Gain Prof. W. KahanMathematics Dept. &Elect. Eng. & Computer Sci. Dept.University of CaliforniaBerkeley CA 94720-1776 Abstract: Matlab has become the software package most widely used by engineers and scientists for their numerical computations. Part of its appeal arose from its early availability on Intel x86-based IBM PCs and their clones, the hardware most widely used by engineers and scientists for their numerical computations nowadays. Almost all these users are unaware of enhanced accuracy Matlab used to enjoy on PCs but lost in its latest releases, versions 5.x , under Windows. Offered here is a function mxmuleps that, when run on various versions of Matlab on various computers, tells which ones have enhanced accuracy, whose benefits are illustrated by examples. Also addressed are pervasive misunderstandings about how much that lost accuracy was worth. Contents: Introduction page 2What eps means 3The Fused Multiply-Accumulate ( FMAC ) Instruction 4How mxmuleps works 5The Program mxmuleps.m 7Example 1 . The Fibonacci Numbers 8The Program fibon.m 9Two dilemmas 12Example 2 . The Zeros of a Real Quadratic 13Example 3. Iterative Refinement for Linear Systems 16Ill-scaled well-conditioned 3-by-3 systems 17Ill-conditioned n-by-n Pascal systems 19Treacherous Mathematics 22How Much is Accuracy Worth? 24Graph showing Accuracy need not be Transitive 25Pejorative regions in the space of all data 26Better accuracy reduces risk 27Example 4. A Simple Geometry Problem 28A Proposal for Modest Modifications to Matlab 30Ruminations and Conclusions 31For Further Reading 32Acknowledgments 32Appendix: The Program divulge.m 33 This document was created with FrameMaker404Matlab’s Loss is Nobody’s Gain Created Aug. 1998, revised July 31, 2004http://www.cs.berkeley.edu/~wkahan/MxMulEps.pdf Page 2/36 Matlab’s Loss is Nobody’s Gain Introduction: A Matlab function mxmuleps has been programmed to reveal Matlab’s roundoff threshold for matrix multiplication. This is smaller than eps , the roundoff threshold for almost all other expressions evaluated by Matlab, on certain machines whose extra-precise internal registers carry more sig. bits than Matlab stores in the double ( 8-byte ) format it uses for its floating-point variables. Earlier versions of Matlab used these extra bits during matrix multiplication whenever they were available; Matlab 5.x continues to do so only on 680x0-based Apple Macintoshes, and later versions of Matlab may not support these machines. On the ubiquitous Intel Pentium-based PCs and their clones running under Microsoft Windows  , Matlab now eschews use of extra precision that would enhance the accuracy of its results on these machines. Why Matlab 5.x abandoned the extra accuracy is a question not answered in this note, which first explains how mxmuleps reveals whether Matlab accumulates matrix multiplication to extra precision and then illustrates its benefits by examples, some of them surprising.Example 1 shows how difficult is the task of designing a benchmark to compare the accuracies of different computer systems. Two programs designed to compute the same integer-valued function of an integer argument, but one program rather more accurately than the second, are run on versions of Matlab some of which compute exponentials x^n rather more accurately than others. Can you guess which programs and which versions of Matlab will produce the best and which the worst results? Don’t bet on it.Example 2 is a program that normally benefits from arithmetic with greater precision but, when run on computers with a Fused Multiply-Accumulate ( FMAC ) instruction that commits fewer rounding errors than other computers do, gets disconcertingly worse results. However, revising the program to exploit an FMAC, when it is available, then produces impeccable results.Example 3 applies Iterative Refinement to offset the effects of certain numerical pathologies upon computed solutions of linear systems A · z = b . The process is reliable only if residuals A · x – b are accumulated extra-precisely; but this interpretation of experimental and theoretical results is obscured by misunderstandings of Backward Error-Analysis spawned by treacherous mathematics. A fair appraisal of accuracy’s worth is subtle; it reduces risks though they are not random. This is illustrated again by Example 4, a simple geometrical computation.Modest modifications are proposed to restore Matlab’s superior accuracy when it runs on Intel-based PCs and clones, even if results from other platforms remain no better than they are now, without detracting from Matlab’s speed. This proposal runs counter to a notion promulgated with Java  to the effect that all computers should deliver identical results; but that notion is inimical to both speed and accuracy so long as computer architectures remain diverse.An appendix presents a Matlab program divulge.m that divulges small divergencies among the arithmetic properties of different versions of Matlab on diverse platforms.Matlab’s Loss is Nobody’s Gain Created Aug. 1998, revised July 31, 2004http://www.cs.berkeley.edu/~wkahan/MxMulEps.pdf Page 3/36 What eps means: Matlab’s eps is the difference between 1 . 0 and the next larger floating-point number stored in the double ( 8-byte ) format Matlab uses for all its floating-point variables. Currently eps = 1/2 52 ≈ 2 . 2/10 16 for all computers on which Matlab runs; earlier versions of Matlab ran on computers with diverse arithmetics and consequently diverse values of eps . Currently all arithmetics on which Matlab runs conform to IEEE Standard 754 for Binary Floating-Point Arithmetic and


Download Matlab’s Loss is Nobody’s Gain
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Matlab’s Loss is Nobody’s Gain and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Matlab’s Loss is Nobody’s Gain 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?