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?
Examples in this section provide sample Octave code for finding determinants and illustrating their uses and properties. 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
In practice, computing determinants using Laplace Expansion is computationally expensive. \(LU\)-factorization can be used to
improve efficiency, but may be numerically unstable. As a result, determinants are rarely used in computational practice.
Examples and exercises in this section are designed to illustrate theoretical properties and computational pitfalls
associated with determinants and should not be interpreted as templates for large-scale computational problems.
We will use the det function to find determinants in Octave.
Compute the determinant of each of the following matrices. If a matrix is singular, say so.
Illustrate part (b) of the above theorem using the second row of matrix \(A\), and constant \(k=4\).
We will use the following code to
illustrate the property.
% Define rows of matrix A
r_1=[2 -1 5];
r_2=[0 3 -4];
r_3=[-2 1 -1];
% Combine the rows to form matrix A
A=[r_1; r_2; r_3];
% Compute the determinant of A
det_A=det(A)
% Form matrix B by multiplying the second row of A by k=4
B=[r_1; 4*r_2; r_3];
% Compute the determinant of B
det_B=det(B)
% Compute 4*det(A)
det_A_times4=4*det(A)
For our next example, recall the following theorem, known as Cramer’s Rule.
?? Let \(A\) be a nonsingular \(n\times n\) matrix, and let \(\vec {b}\) be an \(n\times 1\) vector. Then the components of the solution vector \(\vec {x}\) of \(A\vec {x}=\vec {b}\) are given
by
\[x_i=\frac {\det {A_i(\vec {b})}}{\det {A}}\]
where \(A_i(\vec {b})\) is matrix \(A\) with its \(i^{th}\) column replaced by \(\vec {b}\).
Use Octave to solve the following system for \(x_1\) using Cramer’s rule.
% Define columns of matrix A
c_1=[1; -1; 0];
c_2=[2; 1; 3];
c_3=[-1; 1; 1];
% Combine the columns to form matrix A
A=[c_1 c_2 c_3];
% Define vector b
b=[-2; 3; 1];
% Form A_1 by replacing the first column of A with b
A_1=[b c_2 c_3];
% Find x_1
x_1=det(A_1)/det(A)
Determine whether each of the above matrices is singular in two different ways.
Use the det function
Use an alternative approach
Are the two methods used above in agreement? Click the arrow on the right to learn more.
Octave uses \(LU\)-decomposition to compute the determinant. This method is susceptible to rounding errors ( Reference).
Because of this, using the det function to determine singularity is generally not a good idea.
If \(A\) is non-singular, find \(A^{-1}\), and \(\det (A^{-1})\). Illustrate the relationship between \(\det (A)\) and \(\det (A^{-1})\) computationally.
Modify Example 7 to illustrate parts (a) and (c) of Theorem ??. (Use rows and coefficients of your choice.)
Modify the code of Example 10 to find \(x_2\) and \(x_3\).