Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: m308_software
Views: 191
Kernel: SageMath (stable)

Linear Algebra with Sagemath

See the following for a more thorough and likely better tutorial:

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

A = matrix(QQ,[ [1, 2, -1, 3], [0, 1, -1, 2], [0, 0, 1, 1] ])
A
[ 1 2 -1 3] [ 0 1 -1 2] [ 0 0 1 1]
show(A)
B = A.rref()
show(B)

Solving Linear System

### Problem 1 <http://kevinlui.org/m308exams/au17_midterm1sol.pdf>
A = matrix(QQ,[ [1, 2, -1, 3], [0, 1, -1, 2], [0, 0, 1, 1] ])
b = vector(QQ, [1, 1, 0])
show(A)
show(b)
A.solve_right(b)
(-1, 1, 0, 0)
A.right_kernel()
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 x=(1,1,0,0)+s1(1,3/2,1/2,1/2)x=(-1,1,0,0)+s_1(1,-3/2,-1/2,1/2).