Math211.1.1

124 days ago by Jesse_Berwald

%hide %html Section 1.1 
       
Section 1.1
Section 1.1
%hide %html # 13 
       
# 13
# 13
%hide %html Note that "#" starts a comment which will not be evaluated by Sage. Thus, the matrix A is defined below, but everything on the same line after "#" is ignored. 
       
Note that "#" starts a comment which will not be evaluated by Sage. Thus, the matrix A is defined below, but everything on the same line after "#" is ignored.
Note that "#" starts a comment which will not be evaluated by Sage. Thus, the matrix A is defined below, but everything on the same line after "#" is ignored.
A = matrix(QQ,[[1,0,-3],[2,2,9],[0,1,5]]) # define non-augmented matrix A A 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr}
1 & 0 & -3 \\
2 & 2 & 9 \\
0 & 1 & 5
\end{array}\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr}
1 & 0 & -3 \\
2 & 2 & 9 \\
0 & 1 & 5
\end{array}\right)
b = vector(QQ, [8,7,-2]) # define b b 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(8,\,7,\,-2\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(8,\,7,\,-2\right)
C = A.augment(b) # augment b in order to row reduce the system C 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
1 & 0 & -3 & 8 \\
2 & 2 & 9 & 7 \\
0 & 1 & 5 & -2
\end{array}\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
1 & 0 & -3 & 8 \\
2 & 2 & 9 & 7 \\
0 & 1 & 5 & -2
\end{array}\right)
C.rref() # perform row operations ("reduced row echelon form", coming soon section 1.2!) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
1 & 0 & 0 & 5 \\
0 & 1 & 0 & 3 \\
0 & 0 & 1 & -1
\end{array}\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
1 & 0 & 0 & 5 \\
0 & 1 & 0 & 3 \\
0 & 0 & 1 & -1
\end{array}\right)
%hide %html Therefore, the solution vector is (5,3,-1). This should concur with your paper and pencil computations. 
       
Therefore, the solution vector is (5,3,-1). This should concur with your paper and pencil computations.
Therefore, the solution vector is (5,3,-1). This should concur with your paper and pencil computations.
%hide %html # 15. Instead of "rref", we'll proceed using the matrix's built-in elementary row operations. Note, each row operation below alters the matrix M "in place" 
       
# 15. Instead of "rref", we'll proceed using the matrix's built-in elementary row operations. Note, each row operation below alters the matrix M "in place"
# 15. Instead of "rref", we'll proceed using the matrix's built-in elementary row operations. Note, each row operation below alters the matrix M "in place"
M = matrix(QQ, [[1,-6,0,0,5],[0,1,-4,1,0],[-1,6,1,5,3],[0,-1,5,4,0]]) # M is the augmented matrix for the system in 15 M 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrr}
1 & -6 & 0 & 0 & 5 \\
0 & 1 & -4 & 1 & 0 \\
-1 & 6 & 1 & 5 & 3 \\
0 & -1 & 5 & 4 & 0
\end{array}\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrr}
1 & -6 & 0 & 0 & 5 \\
0 & 1 & -4 & 1 & 0 \\
-1 & 6 & 1 & 5 & 3 \\
0 & -1 & 5 & 4 & 0
\end{array}\right)
M.add_multiple_of_row(2,0,1) M # Typing ";M" is a shortcut to put a second command on the same line, and print M # The syntax above tells Sage to "add 1 times row0 to row2". Sage uses 0-based indexing for rows. 
       
M.add_multiple_of_row(3,1,1);M 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrr}
1 & -6 & 0 & 0 & 5 \\
0 & 1 & -4 & 1 & 0 \\
0 & 0 & 1 & 5 & 8 \\
0 & 0 & 1 & 5 & 0
\end{array}\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrr}
1 & -6 & 0 & 0 & 5 \\
0 & 1 & -4 & 1 & 0 \\
0 & 0 & 1 & 5 & 8 \\
0 & 0 & 1 & 5 & 0
\end{array}\right)
M.add_multiple_of_row(3,2,-1);M 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrr}
1 & -6 & 0 & 0 & 5 \\
0 & 1 & -4 & 1 & 0 \\
0 & 0 & 1 & 5 & 8 \\
0 & 0 & 0 & 0 & -8
\end{array}\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrr}
1 & -6 & 0 & 0 & 5 \\
0 & 1 & -4 & 1 & 0 \\
0 & 0 & 1 & 5 & 8 \\
0 & 0 & 0 & 0 & -8
\end{array}\right)
%hide %html The system is inconsistent. The last line requires that 0=-8 in order for a solution to exist. 
       
The system is inconsistent. The last line requires that 0=-8 in order for a solution to exist.
The system is inconsistent. The last line requires that 0=-8 in order for a solution to exist.
%hide %html #25 
       
#25
#25
%hide %html Define new variables g,h,k. The "domain=QQ" is Sage's way of saying make the variables rationals. You could also make them reals (decimals in this case) by typing "RR" instead of "QQ". This forces the row reductions to output decimal answers (which in my opinion are not as nice). 
       
Define new variables g,h,k. The "domain=QQ" is Sage's way of saying make the variables rationals. You could also make them reals (decimals in this case) by typing "RR" instead of "QQ". This forces the row reductions to output decimal answers (which in my opinion are not as nice).
Define new variables g,h,k. The "domain=QQ" is Sage's way of saying make the variables rationals. You could also make them reals (decimals in this case) by typing "RR" instead of "QQ". This forces the row reductions to output decimal answers (which in my opinion are not as nice).
var('g,h,k', domain=QQ) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(g, h, k\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(g, h, k\right)
%hide %html The parent() function is just telling us that Sage stores g as a symbolic representation (SR), as opposed to a real (RR) or rational (QQ). 
       
The parent() function is just telling us that Sage stores g as a symbolic representation (SR), as opposed to a real (RR) or rational (QQ).
The parent() function is just telling us that Sage stores g as a symbolic representation (SR), as opposed to a real (RR) or rational (QQ).
parent(g) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\text{SR}
\newcommand{\Bold}[1]{\mathbf{#1}}\text{SR}
S = matrix(SR,[[1,-4,7,g],[0,3,-5,h],[-2,5,-9,k]]) # !! Note the different system "SR". Needed for the symbolic computations using g,h, and k. !! S 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
1 & -4 & 7 & g \\
0 & 3 & -5 & h \\
-2 & 5 & -9 & k
\end{array}\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
1 & -4 & 7 & g \\
0 & 3 & -5 & h \\
-2 & 5 & -9 & k
\end{array}\right)
S.add_multiple_of_row(2,0,2);S # add 2*row0 to row2 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
1 & -4 & 7 & g \\
0 & 3 & -5 & h \\
0 & -3 & 5 & 2 \, g + k
\end{array}\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
1 & -4 & 7 & g \\
0 & 3 & -5 & h \\
0 & -3 & 5 & 2 \, g + k
\end{array}\right)
S.add_multiple_of_row(2,1,1);S 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
1 & -4 & 7 & g \\
0 & 3 & -5 & h \\
0 & 0 & 0 & 2 \, g + h + k
\end{array}\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr}
1 & -4 & 7 & g \\
0 & 3 & -5 & h \\
0 & 0 & 0 & 2 \, g + h + k
\end{array}\right)
# In order for S to be consistent, 2g+k+k = 0 must hold.