As you will find, there is no solution to the equation \(A \xb = \bb\text{.}\) This unfortunate circumstance is mostly the fault of the matrix, \(A\text{,}\) which is too simple, its columns (and rows) are all the same. Now try
>> b = ones(4,1)
>> x = [ 1 0 0 0]'
>> A*x
So the system \(A \xb = \bb\) does have a solution. Still unfortunately, that is not the only solution. Try
>> x = [ 0 1 0 0]'
>> A*x
We see that this \(x\) is also a solution. Next try
>> x = [ -4 5 2.27 -2.27]'
>> A*x
This \(x\) is a solution! It is not hard to see that there are endless possibilities for solutions of this equation.
In most (but not all!) engineering applications we would want to have exactly one solution. The following two theorems tell us exactly when we can and cannot expect this.
Which matrix is singular and which is non-singular? Finally, attempt to solve all the possible equations \(A \xb = \bb\text{:}\)
>> x = A1 \ b1
>> x = A1 \ b2
>> x = A2 \ b1
>> x = A2 \ b2
As you can see, equations involving the non-singular matrix have one and only one solution, but equation involving a singular matrix are more complicated.
Recall that the residual for an approximate solution \(x\) of an equation \(f(x) =0\) is defined as \(r = \|f(x)\|\text{.}\) It is a measure of how close the equation is to being satisfied. For a linear system of equations we define the residual vector of an approximate solution \(\xb\) by
\begin{equation*}
\rb = A \xb - \bb\text{.}
\end{equation*}
If the solution vector \(\xb\) were exactly correct, then \(\rb\) would be exactly the zero vector. The size (norm) of \(\rb\) is an indication of how close we have come to solving \(A \xb = \bb\text{.}\) We will refer to this number as the scalar residual or just the residual of the approximation solution:
\begin{equation*}
r = \| A \xb - \bb \|\text{.}
\end{equation*}
By hand, find all the solutions (if any) of the following linear system using the augmented matrix and Gaussian elimination (following exactly the algorithm in the notes):
Write a well-commented MATLAB function program mysolvecheck with input a number n that makes a random \(n \times n\) matrix \(A\) and a random vector \(\bb\text{,}\) solves the linear system \(A \xb = \bb\text{,}\) calculates the scalar residual \(r = \|A \xb - \bb\|\text{,}\) and outputs that number as \(r\text{.}\)
Write a well-commented MATLAB script program that calls mysolvecheck 10 times each for \(n =\) 5, 10, 20, 40, 80, and 160, then records and averages the results and makes a log-log plot of the average \(r\) vs. \(n\text{.}\) Once your program is running correctly, increase the maximum \(n\) (by factors of \(2\)) until the program stops running within 5 minutes.