Stable construction of a Givens rotation
ID: stable-construction-of-a-givens-rotation
For finite real numbers , a Givens rotation that annihilates is defined mathematically byHere
hypot means an evaluation of the Euclidean norm of designed to avoid unnecessary range failures in floating-point arithmetic. The zero case selects the identity matrix, avoiding division by zero. If , then ; if , then . Thus the retained component is nonnegative, including when . In exact arithmetic, and .Computing the square root of
a*a + b*b directly can fail even when the final norm is representable. In binary64 floating-point arithmetic, makes the squares overflow, whereas is finite. With the squares round to zero, although is representable. A range-safe hypot avoids these intermediate failures.The simple divisions still need care when is a subnormal number: rounding can cause large relative errors. For the smallest positive binary64 subnormal number , taking rounds to ; dividing by that rounded value gives , which is not an orthogonal matrix. For nonzero finite inputs, compute the coefficients before rescaling the norm:At least one scaled component has absolute value one, and . This construction keeps the coefficients meaningful even when rounding is severe. It cannot make an unrepresentably large finite, preserve an arbitrarily tiny against underflow, or repair inputs already rounded to zero. The row updates themselves can also overflow if their exact results exceed the available range.
LAPACK's
DLARTG uses scaling for numerical stability but a different sign convention: for it chooses and ; for it returns . Its block still has the lower-left minus sign. Do not combine its returned coefficients with an assumed nonnegative .[ref]DLARTG (LAPACK 3.12.1) by Edward Anderson. DLARTG, LAPACK 3.12.1, Purpose: block, signed R, scaling and zero-input cases; implementation lines 137–159
New to topics? Read the docs here!