f04jgf

f04jgf © Numerical Algorithms Group, 2002.

Purpose

F04JGF Least-squares (if rank = n) or minimal least-squares (if rank < n) solution of m real equations in n unknowns, rank <= n, m >= n

Synopsis

[a,b,svd,sigma,irank,work,ifail] = f04jgf(a,b<,tol,ifail>)

Description

 
 The minimal least-squares solution of the problem Ax=b is the 
 vector x of minimum (Euclidean) length which minimizes the length
 of the residual vector r=b-Ax.
 
 The real m by n (m>=n) matrix A is factorized as
 
                                 (U)
                              A=Q(0)
 
 where Q is an m by m orthogonal matrix and U is an n by n upper 
 triangular matrix. If U is of full rank, then the least-squares 
 solution is given by
 
                               -1    T
                           x=(U   0)Q b.
 
 If U is not of full rank, then the singular value decomposition 
 of U is obtained so that U is factorized as
 
                                   T
                              U=RDP ,
 
 where R and P are n by n orthogonal matrices and D is the n by n 
 diagonal matrix
 
              D=diag((sigma) ,(sigma) ,...,(sigma) ),
                            1        2            n
 
 with (sigma) >=(sigma) >=...(sigma) >=0, these being the singular
             1         2            n                     
 values of A. If the singular values (sigma)   ,...,(sigma)  are 
                                            k+1            n    
 negligible, but (sigma)  is not negligible, relative to the data 
                        k                                        
 errors in A, then the rank of A is taken to be k and the minimal 
 least-squares solution is given by
 
                          ( -1  )( T  )  
                          (S   0)(R  0) T
                       x=P(0   0)(0  I)Q b,
 
 where S=diag((sigma) ,(sigma) ,...,(sigma) ).
                     1        2            k 
 
 The routine also returns the value of the standard error
 
              ____
             /  T 
            /  r r
 (sigma)=  /   --- ,     if m>k,
         \/    m-k
 
                                  T                            
        =  0,            if m=k, r r being the residual sum of 
                         squares and k the rank of A.
 

Parameters

f04jgf

Required Input Arguments:

a (:,:)                               real
b (:)                                 real

Optional Input Arguments:                       <Default>

tol                                   real     sqrt(eps)
ifail                                 integer  -1

Output Arguments:

a (:,:)                               real
b (:)                                 real
svd                                   logical
sigma                                 real
irank                                 integer
work (:)                              real
ifail                                 integer