Givens rotation

Unlike the elementary operation of row-addition, a Givens rotation changes both of the rows addressed by it.

To understand how it is a rotation, one may denote the elements of one target row by

As with row-addition, algorithms often choose this angle so that one specific element becomes zero, and whatever happens in remaining columns is considered acceptable side-effects.

by the same angle, but here these named elements occur in the matrix as

In this case the effect on the four elements affected by both rotations is more complicated; a Jacobi rotation is such a conjugate action to the end of zeroing the two off-diagonal elements among these four.

The main use of Givens rotations in numerical linear algebra is to transform vectors or matrices into a special form with zeros in certain coefficients.

This effect can, for example, be employed for computing the QR decomposition of a matrix.

One advantage over Householder transformations is that they can easily be parallelised, and another is that often for very sparse matrices they have a lower operation count.

A Givens rotation is represented by a matrix of the form where c = cos θ and s = sin θ appear at the intersections ith and jth rows and columns.

Explicit calculation of θ is rarely necessary or desirable.

Instead we directly seek c and s. An obvious solution would be However, the computation for r may overflow or underflow.

An alternative formulation avoiding this problem (Golub & Van Loan 1996, §5.1.8) is implemented as the hypot function in many programming languages.

The following Fortran code is a minimalistic implementation of Givens rotation for real numbers.

If the input values 'a' or 'b' are frequently zero, the code may be optimized to handle these cases as presented here.

Furthermore, as Edward Anderson discovered in improving LAPACK, a previously overlooked numerical consideration is continuity.

The IEEE 754 copysign(x,y) function, provides a safe and cheap way to copy the sign of y to x.

Given the following 3×3 Matrix: two iterations of the Givens rotation (note that the Givens rotation algorithm used here differs slightly from above) yield an upper triangular matrix in order to compute the QR decomposition.

Q is now formed using the transpose of the rotation matrices in the following manner: Performing this matrix multiplication yields: This completes two iterations of the Givens Rotation and calculating the QR decomposition can now be done.

Another method can extend Givens rotations to complex matrices.

Let A be a matrix for which it is desired to make the ji element be zero using the rows and columns i and j>i.

The phases of the ii and jj elements of D can be chosen so as to make the ii and ji elements of the product matrix D A be real.

Then a Givens rotation G can be chosen using the i and j>i rows and columns so as to make the ji element of the product matrix G D A be zero.

Givens rotations are represented by the exterior product of the basis vectors.

[clarification needed] When rotations are performed in the right order, the values of the rotation angles of the final frame will be equal to the Euler angles of the final frame in the corresponding convention.

transforms the basis of the space into a frame with angles roll, pitch and yaw

This is similar to the extrinsic rotation equivalence for Euler angles.

The following table shows the three Givens rotations equivalent to the different Euler angles conventions using extrinsic composition (composition of rotations about the basis axes) of active rotations and the right-handed rule for the positive sign of the angles.

The subindexes of the angles are the order in which they are applied using extrinsic composition (1 for intrinsic rotation, 2 for nutation, 3 for precession) As rotations are applied just in the opposite order of the Euler angles table of rotations, this table is the same but swapping indexes 1 and 3 in the angles associated with the corresponding entry.

An entry like zxy means to apply first the y rotation, then x, and finally z, in the basis axes.

All the compositions assume the right hand convention for the matrices that are multiplied, yielding the following results.