hanekawa

post

[NA] Intro to Computer Arithmetic

NA

Why do we need to care about computer arithmetic? Finite precision arithmetic can introduce unwanted errors. Number representation in computers is in a finite way: sign indicator, exponent, mantissa. Types of truncation: chopping and rounding (more accurate). Some basic concepts: roundoff error, significant digit, machine epsilon. Error propagation through both multiplication and division are just keeping epsilon level, while through addition/subtraction would possibly get into trouble. E.g., a-b, when a and b have the same sign and similar magnitudes. In this case, the exact result of the operation (subtraction) is a very small number, which takes the denominator of the relative error, while the numerator of the relative error is most likely in the level of machine epsilon. If their absolute difference is smaller than machine epsilon, the relative error would be a large number. (loss of accuracy) There are ways to avoid this, which requires a clever algorithm design. For the same example, a-b trouble, we can easily multiply (a+b)/(a+b) and hopefully a^2-b^2 would help. This was used in solving quadratic equations, if a root meets this trouble, we usually rationalize the numerator (not denominator like usual algebra).