Solving Overdetermined System Using Pseudoinverse

The system of linear equations becomes overdetermined system if there are more equations than unknowns. It usually does not have solutions.

From the Solving System of Linear Equations, the system of linear equations can be written in the matrix form as:

AX = B
Where:
A is m x n matrix of coefficients.
X is n x 1 matrix of unknowns.
B is m x 1 matrix of constant terms.

So, the system becomes overdetermined when m > n.
To solve this kind of system, we need to find X such that the residual vector

R = B – AX

is as small as possible.

The solution X given be the least squares method minimizes ||R||2 = ||BAX||2. This solution is Least-Squares Solution.

Least-Squares Solution with Pseudoinverse

From:
AX = B
When m > n, so:
ATAX = ATB
Then
X = (ATA)-1ATB
(ATA)-1AT is called pseudo inverse of A

 

Solving with MathPACK Solver

MathPACK Solver provides inv or pinv function finding invert matrix. If the input matrix to the function, is not squared matrix, the pseudo invert will be returned from the function.

Function Signature

U = inv(A);
U = pinv(A);

Example

Find the least-squares solution of the following system of equations:
x1 – x2 = 2
x1 + x2 = 4
2x1 + x2 = 8


    »A = [1,-1; 1, 1; 2, 1]; 

    »B = [2; 4; 8]; 
    »X = pinv(A)*B 
    X = 
        3.2857 
        1.1429 
So, the values of unknown x1 and x2 are:
x1 = 3.2857
x2 = 1.1429
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply