Je bent je ingevulde velden bij deze pagina aan het verwijderen. Ben je zeker dat je dit wilt doen?
You are erasing your filled-in fields on this page. Are you sure that is what you want?
Nieuwe Versie BeschikbaarNew Version Available
Er is een update van deze pagina. Als je update naar de meest recente versie, verlies je mogelijk je huidige antwoorden voor deze pagina. Hoe wil je verdergaan ?
There is an updated version of this page. If you update to the most recent version, then your current progress on this page will be erased. Regardless, your record of completion will remain. How would you like to proceed?
The templates in this section provide sample Octave code for solving systems of equations. You can access our
code through the link at the bottom of each template. Feel free to modify the code and experiment to learn
more!
You can write your own code using Octave software or online Octave cells. To access Octave cells online, go to the Sage
Math Cell Webpage, select OCTAVE as the language, enter your code, and press EVALUATE.
To ”save" or share your online code, click on the Share button, select Permalink, then copy the address directly from the
browser window. You can store this link to access your work later or share this link with others. You will need to get a new
Permalink every time you modify the code.
Octave Tutorial
When solving systems by hand, you utilized Gauss-Jordan elimination to find rref. Having the reduced row echelon form
available made it easy to write out the solution(s) or determine that the system is inconsistent. We can find rref and the rank of
a matrix using Octave as follows.
% Define a matrix
A=[2 -1 3 -1; 1 0 2 1; 1 -1 1 -2]
% Third row of A
row_3=A(3,:)
% Second column of A
col_2=A(:,2)
% Second row third entry of A
a_23=A(2,3)
Suppose the graph of function \(f\) of the form \(f(x)=ax^3+bx^2+cx+d\) passes through points \((-2, 1)\), \((0, 4)\), \((1, -2)\) and \((4, 5)\). Set up a system of linear equations to find the
coefficients \(a\), \(b\), \(c\) and \(d\). Update the coefficients in the GeoGebra interactive below to sketch the graph.
You need to find coefficients \(a, b, c, d\) such that \(f(-2)=1\), \(f(0)=4\), \(f(1)=-2\), \(f(4)=5\). For more information about this topic, see Curve Fitting.
The following code generates a random \(20\times 3\) matrix \(A\) whose entries are integers \(-1\), \(0\), and \(1\), and a random \(20\times 1\) vector \(\vec {b}\) whose
components are integers \(-1\), \(0\), and \(1\).
% A is a randomly generated 20 by 3 matrix whose entries are -1, 0, 1.
A=randi([-1,1],20,3);
% b is a randomly generated column vector whose entries are -1, 0, 1.
b=randi([-1,1],20,1);
% Augmented matrix A_b
A_b=[A b];
% Reduced row-echelon form
rref_A_b=rref(A_b)
% Rank of A_b
rank(A_b)
Run the code several times to generate several random combinations of \(A\) and \(\vec {b}\) and find the rank and the reduced row-echelon
form of \([A | \vec {b}]\). Are you getting the answers you were expecting? Answer the following questions based on your theoretical
knowledge.
What are the possibilities for the rank of such \([A | \vec {b}]\)?
The rank can be any positive integer less than or equal to \(20\).The rank can be any positive integer less than or
equal to \(3\).The rank is always equal to \(4\).The rank can be any non-negative integer less than or equal to \(4\).
What are the possibilities for the number of solutions of such \([A | \vec {b}]\)?
This system always has a unique solution. This system may have no solutions, infinitely many solutions or a
unique solution. This system will always have infinitely many solutions. This system will always be infeasible.
There is a good chance that your experiments have led you to believe that \(\text {rank}[A | \vec {b}]=4\). Can you manually construct \([A | \vec {b}]\), satisfying the
condition of the problem, with a smaller rank? How many solutions does your system have? Why do you think it is so rare to
randomly generate a system \([A | \vec {b}]\) of rank less than \(4\)?
Further Considerations
Issues related to computational aspects of linear algebra are outside the scope of this text. However, we want the reader to be
aware of some potential problems that may arise.
The rref function utilizes a modified version of the Gauss-Jordan elimination algorithm ( Reference Link). For some matrices,
implementing this algorithm directly leads to round-off errors and other problems that are outside of the scope of this text. We
illustrate what can happen in the next example.
We will use a \(12\times 12\) Hilbert matrix to illustrate how the rref function can fail. You can learn more about Hilbert matrices
here.
% Use a 12 by 12 Hilbert matrix
A=hilb(12);
% Theoretical rank of A is 12, but the following computation shows a rank of 11
rank(A)
% rref of A should be the identity matrix, but the following result contains a row of zeros
rref(A)