Skip to main content

Section 6.3 Systems with free variables

When the rank of matrix \(A\) is less than the number of variables, the system has free variables. In a Linear Algebra course, we would move the free variables to the right, and solve the rest of the system. But Matlab sets free variables to \(0\) and then solves the system as described in Section 6.2.

Note for Octave users: this is one of rare cases when Octave behavior is different, as explained below. This will not make a difference for homework. (In my opinion, Octave has a better approach than Matlab.)

Use Matlab to solve the system

\begin{equation*} \begin{pmatrix}1\amp 2 \amp 3 \\ 4 \amp 5 \amp 6\end{pmatrix}x= \begin{pmatrix} 10 \\ 11 \end{pmatrix} \end{equation*}
Solution
A = [1 2 3; 4 5 6];
b = [10; 11];
disp(A\b)

The displayed solution is [-4.5; 0; 4.8333].

In geometric terms, the system in Example 6.3.1 describes the intersection of two planes in 3-dimensional space. This intersection is a line. The solution that Matlab picks is the point where this line cross one of coordinate planes.

There is another logical choice of solution in a problem like this: one could pick the point on the line that is closest to the origin \((0, 0, 0)\text{,}\) that is the solution of smallest norm. This is the approach that Octave uses: when given Example 6.3.1 it would produce [-4.5556; 0.1111; 4.7778]. One can get this solution with Matlab by using pinv(A)*b, which results in [-4.5556; 0.1111; 4.7778]. This approach takes longer because it involves computing the pseudoinverse of \(A\) which is a subject of MAT 532.

Compare the system

\begin{equation*} \begin{pmatrix}1\amp 2 \amp 3 \\ 4 \amp 5 \amp 6 \\ 7 \amp 8 \amp 9 \end{pmatrix}x= \begin{pmatrix} 10 \\ 11 \\ 12 \end{pmatrix} \end{equation*}

to Example 6.3.1. Does it have the same solution?

Solution

This new system has one more equation, but it is redundant: if you multiply the second line by 2 and subtract the first line, the result is the 3rd line. So, this system is mathematically equivalent to the previous one. Yet, the Matlab solution is different.

A = [1 2 3; 4 5 6; 7 8 9];
b = [10; 11; 12];
disp(A\b)

The result is [-25.3333; 41.6667; -16.0000], quite different from what we got in Example 6.3.1. Matlab did not even recognize this as a system with a free variable.

What explains the result of Example 6.3.2? When solving it, we get a warning message: “Matrix is close to singular or badly scaled. Results may be inaccurate.” This means the result of this computation are likely to be influenced by inevitable round-off errors in computer arithmetics, which is the subject of next section.