Kernel: SageMath (stable)
Linear Algebra with Sagemath
See the following for a more thorough and likely better tutorial:
http://linear.ups.edu/html/fcla.html (Rob Beezer's book on Linear Algebra)
http://www.gregorybard.com/Sage.html (Greg Bard's book on Sagemath for undergraduates)
This worksheet is just more specialized for our 308 class
What's with the QQ?
In math, there are different number systems. We call them rings https://en.wikipedia.org/wiki/Ring_(mathematics). Linear algebra over different rings give you different answers. In this class, we'll use QQ for exact answer and RR for inexact ones.
What is Sage?
A computer algebra system built on top of Python.
Echelon Forms
In [44]:
In [45]:
Out[45]:
[ 1 2 -1 3]
[ 0 1 -1 2]
[ 0 0 1 1]
In [46]:
Out[46]:
In [47]:
In [48]:
Out[48]:
Solving Linear System
In [0]:
In [49]:
In [50]:
In [51]:
Out[51]:
In [52]:
Out[52]:
In [53]:
Out[53]:
(-1, 1, 0, 0)
In [54]:
Out[54]:
Vector space of degree 4 and dimension 1 over Rational Field
Basis matrix:
[ 1 -3/2 -1/2 1/2]
The general solution is then .
Use RDF - real double field - for inexact computations
In [55]:
Out[55]:
In [56]:
Out[56]:
In [57]:
Out[57]:
(0.7454769517982468, -2.224701702449103, 1.8640870570327306, 0.8131141695930252, -0.7342450326911023)
In [58]:
Out[58]:
(0.7454769517982468, -2.224701702449103, 1.8640870570327306, 0.8131141695930252, -0.7342450326911023)
Here's how to check linearly independence/span
In [59]:
In [0]:
In [60]:
Out[60]:
[
(1, 1/2, -1/2)
]
In [61]:
Out[61]:
(0, 0, 0)
In [62]:
Out[62]:
Vector space of degree 3 and dimension 2 over Rational Field
Basis matrix:
[ 1 0 9/5]
[ 0 1 3/5]
In [63]:
Out[63]:
False
In [0]: