Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Math 208 Interactive Notebooks © 2024 by Soham Bhosale, Sara Billey, Herman Chau, Zihan Chen, Isaac Hartin Pasco, Jennifer Huang, Snigdha Mahankali, Clare Minerath, and Anna Willis is licensed under CC BY-ND 4.0
License: OTHER
Image: ubuntu2204
Chapter 5: Determinants
By: Soham Bhosale
The determinant of a matrix is a single numerical value which is used when calculating the inverse or when solving systems of linear equations. Let's look at some basic examples first.
The determinants of 2x2 matrices can be generated using a special formula
Let's apply to an example matrix
Now we are going to look at some interesting properties of Determinants.
The first property of determinants we are going to look at is regarding multiplying determinants. Multiplying matrices and computing arithmetic operations requires a lot of computation. However, the relationship between the determinant of the product of matrices and the product of their individual determinants, it more simple.
And
This property holds commutatively as well!
After seeing this neat property of multiplying determinants, it may be tempting to assume that adding determinants work the same way. Namely, that the determinant of the sum of two matrices is the same as the sum of their individual determinants. In math notation, . However, this property is not true. Here's an example of when it is not true.
However, there are some instances where this property does hold true. Here is an example:
Determinants of matrices can be calculated using something called the cofactor expansion method.
Here is the formula:
Where are the cofactors of .
We can represent this using an example to see how sage calculates it
Elementary Matrices
Instead of using cofactor expansion to compute the determinant. It is more efficient to convert the matrix to echleon form using row operations and then multiply the terms along the diagnonal
First, let's see how elementary matrices change a matrix (row-operations)
Remember the three elementary operations are
Interchanging two rows
Multiplying a row by a constant c
Adding a mulitple of one row to another
Affect of Elementary Matrices on the Determinant
Here is the affect of elementary matrices on the Determinant. This table from the textbook does a great job summarizing it.
Elementary Matrix Switching Rows
The determinant of the matrix produced by interchanging two rows of the original matrix is -det(B)
Multiplying a row by a constant multiplies the determinant by that constnant c
Now here is a function I wrote that represents the recursive nature of finding determinants using cofactor expansion
Some more properties!
Determinant of the inverse of a matrix A is
has the same Determinant As A
Inverses from Determinants
In the textbook, we learn that If A is an invertible matrix, then
Cramer's Rule
Cramer's rule is a formula using determinants that can be used to find the solution to Ax = b where A is an n x n matrix and b is a vector.
If A = [] and b is in , then let denote the matrix A after replace with b
Determinants Can Also Represent Area
Let T:
Example Problems
A functionality that computers provide is the ability to compute fast. Thus we can use this to our advantage to find examples of certain examples or counterxamples of matrices. Here are some practice problems from the book representing this
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In [17], line 2
1 # Exercise 4 (c): Fill in entries for A and B to find a counterexample.
----> 2 A = Matrix(ZZ, [[_, _, _], [_, _, _], [_, _, _]])
3 B = Matrix(ZZ, [[_, _, _], [_, _, _], [_, _, _]])
5 A.determinant() - B.determinant() == (A-B).determinant()
, in sage.matrix.constructor.matrix()
641 """
642 immutable = kwds.pop('immutable', False)
--> 643 M = MatrixArgs(*args, **kwds).matrix()
644 if immutable:
645 M.set_immutable()
, in sage.matrix.args.MatrixArgs.matrix()
666 break
667 else:
--> 668 M = self.space(self, coerce=convert)
669
670 # Also store the matrix to support multiple calls of matrix()
, in sage.structure.parent.Parent.__call__()
901 return mor._call_(x)
902 else:
--> 903 return mor._call_with_args(x, args, kwds)
904
905 raise TypeError(_LazyString("No conversion defined from %s to %s", (R, self), {}))
, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_with_args()
180 print(type(C), C)
181 print(type(C._element_constructor), C._element_constructor)
--> 182 raise
183
184
, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_with_args()
170 return C._element_constructor(x)
171 else:
--> 172 return C._element_constructor(x, **kwds)
173 else:
174 if len(kwds) == 0:
, in MatrixSpace._element_constructor_(self, entries, **kwds)
835 def _element_constructor_(self, entries, **kwds):
836 """
837 Construct an element of ``self`` from ``entries``.
838
(...)
943 False
944 """
--> 945 return self.element_class(self, entries, **kwds)
, in sage.matrix.matrix_integer_dense.Matrix_integer_dense.__init__()
307 ma = MatrixArgs_init(parent, entries)
308 cdef Integer z
--> 309 for t in ma.iter(coerce, True):
310 se = <SparseEntry>t
311 z = <Integer>se.entry
, in iter()
532 x = next(it)
533 if convert and self.need_to_convert(x):
--> 534 x = self.base(x)
535 if sparse:
536 yield make_SparseEntry(i, j, x)
, in sage.structure.parent.Parent.__call__()
899 if mor is not None:
900 if no_extra_args:
--> 901 return mor._call_(x)
902 else:
903 return mor._call_with_args(x, args, kwds)
, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_()
161 print(type(C), C)
162 print(type(C._element_constructor), C._element_constructor)
--> 163 raise
164
165 cpdef Element _call_with_args(self, x, args=(), kwds={}):
, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_()
156 cdef Parent C = self._codomain
157 try:
--> 158 return C._element_constructor(x)
159 except Exception:
160 if print_warnings:
, in sage.rings.integer.Integer.__init__()
708 return
709
--> 710 raise TypeError("unable to coerce %s to an integer" % type(x))
711
712 def __reduce__(self):
TypeError: unable to coerce <class 'sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense'> to an integer