# Solving sets of linear equations

The most common tasks in numerical linear algebra are solving a set of linear equations of the form .

Several types of linear systems

 (4.3)

exist:
1. There may exist a unique vector that solves (4.6). In that case, the system is called non-singular. An example of such a system is:

 (4.4)

which has a unique solution .
2. There may be an infinite number of possible vectors that solve (4.6). In that case, the system is called underdetermined. For example, the system

 (4.5)

has solutions , and many others.
3. There may not be a vector that solves (4.6). In that case, the system is called overdetermined. Examples of such systems are:

 (4.6)

and

 (4.7)

In MATLAB it is possible to determine the solution of a set of linear equations directly. For square or rectangular linear systems the method of first resort is the backslash operator. The solution of is implemented directly in MATLAB as:

>> x = A\b

You can find more information about this command with help mldivide.

Sometimes MATLAB gives one of the following warnings after the command A\b:

>> Warning: Matrix is close to singular or badly scaled.
 Results may be inaccurate. RCOND = ....
or

>> Warning: Matrix is singular to working precision.

We will not go into the exact meaning of this warning. However, if this warning appears, you should not trust the result that appears on the screen.

If none of these error messages appears, this does not mean yet that the result that appears on the screen is the real' solution of . Namely, in case of overdetermined systems, a solution to this equation does not exist. MATLAB, however, will give the least squares solution'.
Therefore, it is important to check the value of given by MATLAB by typing in A*x, and comparing the result to the value of . If , then a solution to the equations does not exist, and MATLAB has given the least squares 'solution'. If you do find , you know that MATLAB has given a solution. However, there may still be more solutions. To find the general solution, you will have to use a different method, for example use the method explained below.

You can also use the command A\b for symbolic matrices. A warning will be shown if the solution does not exist.

Subsections

Esteur 2010-03-22