<< linsys Linear System of Equations

sci_gsl >> sci_gsl > Linear System of Equations > lsqod

lsqod

This function finds the least squares solution to the overdetermined system Ay = b where the matrix A has more rows than columns or number of equations is more than the number of unknowns.

Syntax

[y,res] = lsqod(A,b,c)

Parameters

y:

output Array containing the least squares solution to the overdetermined system.

res:

residual error.

b:

Array of constant terms present in the equations on RHS.

A:

Array containing the coefficients of unknowns in the equations. The number of elements in A must be equal to the product of number of unknowns and number of elements in b.

c:

Number of unknowns.

Description

This function finds the least squares solution to the overdetermined system Ay = b using QR decomposition method where the matrix A has more rows than columns or number of equations is more than the number of unknowns. This function factorizes the A into the QR decomposition A = QR. On output the diagonal and upper triangular part of the input matrix contain the matrix R. The columns of the lower triangular part of the matrix A contain the Householder vectors which encode the orthogonal matrix Q.

Examples

//  Find the least squares solution to the overdetermined system p-q=2, p+q=4, 2p+q=8
A=[1 -1 1 1 2 1]
b=[2 4 8]
c=2
[y,res] = lsqod(A,b,c)
disp(y)
disp(res)

Authors


Report an issue
<< linsys Linear System of Equations