Numerical methods for computing angles between linear subspaces

Abstract
Assume that two subspaces F and G of a unitary space are defined as the ranges (or null spaces) of given rectangular matrices A and B. Accurate numerical methods are developed for computing the principal angles θ k ( F , G ) {\theta _k}(F,G) and orthogonal sets of principal vectors u k ∈ F {u_k} \in F and v k ∈ G , k = 1 , 2 , ⋯ , q = dim ⁡ ( G ) ≦ dim ⁡ ( F ) {v_k} \in G,k = 1,2, \cdots ,q = \dim (G) \leqq \dim (F) . An important application in statistics is computing the canonical correlations σ k = cos ⁡ θ k {\sigma _k} = \cos {\theta _k} between two sets of variates. A perturbation analysis shows that the condition number for θ k {\theta _k} essentially is max ( κ ( A ) , κ ( B ) ) \max (\kappa (A),\kappa (B)) , where κ \kappa denotes the condition number of a matrix. The algorithms are based on a preliminary QR-factorization of A and B (or A H {A^H} and B H {B^H} ), for which either the method of Householder transformations (HT) or the modified Gram-Schmidt method (MGS) is used. Then cos θ k \cos \;{\theta _k} and sin θ k \sin \;{\theta _k} are computed as the singular values of certain related matrices. Experimental results are given, which indicates that MGS gives θ k {\theta _k} with equal precision and fewer arithmetic operations than HT. However, HT gives principal vectors, which are orthogonal to working accuracy, which is not generally true for MGS. Finally, the case when A and/or B are rank deficient is discussed.