# 213 - A7 - Invertible Equivalents

## 635 days ago by Professor213

Invertible Equivalents - this sheet takes a given (invertible) matrix $A$ and describes several of the equivalent conditions on $A$.

Students should open this sage worksheet and work through the interactive cells below. Consider what Sage's conclusion in each case means.  For small problems, try to work the problems also by hand to verify sage's conclusion.  Answer (individually) the green questions posed in this worksheet.  Note, that there are a few cells that pertain to stuff in chapter 3.  Ignore these for now.

Finally, when you are finished with it all, go back through the sheet with a much larger value for n.  Recompute all cells and see if the conclusions make sense conceptually. Discuss...

John Travis

Mississippi College

The user will first select the size for the $NxN$ matrix $A$ which will be used for the remainder of this page.

%hide %auto N=2 print html("<font size=+2 color=blue>Enter N below. Click 'Update' twice to change the size. </font>") print html("<br>If so, note that you will have to also re-evaluate the other cells below.") @interact def _(Size_of_System=(2..10), auto_update=False): global N N = Size_of_System html('The size of your square system will be $%s$'%str(N)+' by $%s$'%str(N),) # show(html("<font size=+2 color=blue>The size of your square system will be</font>")+str(N)+"$x$"+str(N))

Enter N below. Click 'Update' twice to change the size.
If so, note that you will have to also re-evaluate the other cells below.
Size_of_System

## Click to the left again to hide and once more to show the dynamic interactive window

Now, enter the matrix $A$ below.  You can also have the computer select one with rational entries at random.  If you changed n above, you will likely need to reevaluate this cell first.  This will require that you click on "hide" and then "Shift-Enter" or just quit the sheet and start over from the top.

print html("<font size=+2 color=blue>Enter your data below. You can tab to navigate between cells. Click Update when you are finished.</font> <br><br> <font size=-1 color=blue> If you want a random matrix, click the box and then update and then go on to the remainder of the page</font><p>") @interact def _(Input_Matrix=zero_matrix(QQ,N,N),auto_update=False,Make_it_random=False): global A if Make_it_random: A = random_matrix(QQ,N,N, num_bound=20, den_bound=4) else: A = Input_Matrix if A.det()==0: print html("<font size=+1 color=red>Matrix is Singular. Please pick another!</font>") print html("<font size=+2 color=blue>Using the matrix</font>") html(A)

Enter your data below. You can tab to navigate between cells. Click Update when you are finished.

If you want a random matrix, click the box and then update and then go on to the remainder of the page

Input_Matrix
Make_it_random

## Click to the left again to hide and once more to show the dynamic interactive window

print "Here is the matrix you are using." print "Cut-and-paste works well with this output." html(A)
 Here is the matrix you are using. Cut-and-paste works well with this output. $\left(\begin{array}{rrrr} 3 & -\frac{7}{4} & -13 & 2 \\ 12 & -8 & -\frac{1}{2} & 6 \\ -\frac{1}{2} & -\frac{9}{2} & 1 & -1 \\ \frac{1}{4} & -17 & 20 & -5 \end{array}\right)$ Here is the matrix you are using. Cut-and-paste works well with this output. 
print "Save your Matrix to a File so that you can use the same one next time" filename = 'MyMatrix' filename_for_saving = SAGE_TMP+filename+'.sobj' print filename_for_saving save(A,filename_for_saving)
 Save your Matrix to a File so that you can use the same one next time /home/sageserver/.sage/temp/travis-PowerEdge-T430/19123MyMatrix.sobj Save your Matrix to a File so that you can use the same one next time /home/sageserver/.sage/temp/travis-PowerEdge-T430/19123MyMatrix.sobj
 Reload your Matrix from the file... /home/sageserver/.sage/temp/travis-PowerEdge-T430/19123MyMatrix Traceback (click to the left of this block for traceback) ... IOError: [Errno 2] No such file or directory: '/home/sageserver/.sage/temp/travis-PowerEdge-T430/19123MyMatrix.sobj' Reload your Matrix from the file... /home/sageserver/.sage/temp/travis-PowerEdge-T430/19123MyMatrix Traceback (most recent call last): File "", line 1, in File "_sage_input_19.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("cHJpbnQgIlJlbG9hZCB5b3VyIE1hdHJpeCBmcm9tIHRoZSBmaWxlLi4uIgpmaWxlbmFtZSA9ICdNeU1hdHJpeCcKZmlsZW5hbWVfZm9yX2xvYWRpbmcgPSBTQUdFX1RNUCtmaWxlbmFtZQpwcmludCBmaWxlbmFtZV9mb3JfbG9hZGluZwpBID0gbG9hZChmaWxlbmFtZV9mb3JfbG9hZGluZykKQQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in File "/tmp/tmpCLaShh/___code___.py", line 6, in A = load(filename_for_loading) File "sage/structure/sage_object.pyx", line 1015, in sage.structure.sage_object.load (/home/sageserver/sage-7.5/src/build/cythonized/sage/structure/sage_object.c:12745) IOError: [Errno 2] No such file or directory: '/home/sageserver/.sage/temp/travis-PowerEdge-T430/19123MyMatrix.sobj'

Theorem 5

A matrix is nonsingular provided $Ax=b$ has exactly one solution for any $b$.

%auto show(html("<font size=+2 color=blue>Click on Update to get a new vector b</font>")) @interact def _(auto_update=False): b = random_matrix(QQ,N,1, num_bound=20, den_bound=4) print html("<font size=+2 color=blue>For the vector $b =$</font>") show(b) x = A.inverse()*b print html("<font size=+2 color=blue>the solution is only $x =$</font>") show(x)

Click on Update to get a new vector b

## Click to the left again to hide and once more to show the dynamic interactive window

Assignment:  Let sage give you vectors for b and the resulting solutions for x.  Compute all your work on paper to turn in when I get back.

• For two different 2x2 problems, compute by hand Ax to verify that Ax = b.
• For a 3x3 problem (go back to the top and change n and then change the matrix A, show your work in solving Ax = b yielding a unique solution.

Theorem 7

A matrix is nonsingular provided it is row equivalent (and column equivalent) to the identity matrix.

show(html("<font size=+2 color=blue>Applying row reduction to A yields</font>")) show(A.rref()) show(html("<font size=+2 color=blue>Applying row reduction to $A^T$ yields</font>")) show(A.transpose().rref()) show(html("<font size=+2 color=blue>Since each of these is the identity, the equivalences are shown.</font>"))
 Applying row reduction to A yieldsApplying row reduction to $A^T$ yieldsSince each of these is the identity, the equivalences are shown. Applying row reduction to A yieldsApplying row reduction to yieldsSince each of these is the identity, the equivalences are shown.

Assignment:

• For a 2x2 problem, set up $[A,I]$ and do rref to get $[I, A^{-1}]$.  See that the place where $A$ was is now the identity matrix.
• Do the same for the problem's transpose.

A matrix is nonsingular provided the columns of $A$ span $R^n$.  Thus, any vector b$\in R^n$ is in the span of the columns of $A$.

For the interactive cell below, note $A(2)$ refers to column 2 of the matrix $A$ for example.

%auto pretty_print(html("<font size=+2 color=blue>Click on Update to get a new vector b</font>")) @interact def _(auto_update=False): b = random_matrix(QQ,N,1, num_bound=20, den_bound=4) # html('$b = %s$'%str(b),) # this needs to be output so that the column vector b looks good and not text # show(b) x = A\b At = A.transpose() # need to figure out how to write x1*A1 + x2*A2 + ... + xn*An = b combo = '$b = %s$'%str(latex(b)) # pretty_print(html( " $=$ ")) combo = combo + ' $=$ ' for col in range(N-1): # pretty_print(html('$%s \cdot$'%str(x[col])+'$A_{%s} +$'%(str(col)),)) combo = combo + '$%s \cdot$'%str(latex(x[col]))+'$A_{%s} +$'%(str(latex(col))) # pretty_print(html('$%s \cdot$'%str(x[N-1])+'$A_{%s}$'%(str(N-1)),)) combo = combo + '$%s \cdot$'%str(latex(x[N-1]))+'$A_{%s}$'%(latex(str(N-1))) pretty_print(html(combo)) # It would be nice to accumujlate these html strings above and print them all in one string

Click on Update to get a new vector b

## Click to the left again to hide and once more to show the dynamic interactive window

Theorem 6

A matrix is nonsingular provided $A^{-1}$ exists.

print html("<p><font size=+2 color=blue>$A^{-1} =$</font>") show(A.inverse())
 $A^{-1} =$   

Theorem 7

A matrix is nonsingular provided $A^T$ is invertible.

print html("<p><font size=+2 color=blue>$A^{-T} =$</font>") show(A.transpose().inverse())
 $A^{-T} =$   

Chapter 3

A matrix is nonsingular provided its determinant is nonzero.

pretty_print(html('The matrix A has determinant det(A) = '+str((A.det())) ) ) #html(" $=$ "+str( A.det().n() )) # pretty_print(html('$=%s$ '%str(A.det())+' $\\approx$ $%s$'%str(A.det().n())))
 The matrix A has determinant det(A) = -45603/32 The matrix A has determinant det(A) = -45603/32

A matrix is nonsingular provided $Ax=0$ has only the trivial solution $x=0$.  That is, $Null(A)=\left\{{0 }\right\}$.

b = matrix(N,1,0) x = A\b show(x)

Save this for Chapter 3...

A matrix is nonsingular provided $A$ has no zero eigenvalues.

print html("<font size=+2 color=blue>The eigenvalues for $A$ =</font>") eig = A.eigenvalues() all_nonzero = True for k in range(N): if eig[k]==0: all_nonzero = False show(eig[k]) if all_nonzero: print html("<font size=+2 color=blue><b>They are all nonzero.</b></font>")
 The eigenvalues for $A$ = They are all nonzero. The eigenvalues for = They are all nonzero.

The matrix A can be expressed as a finite product of elementary matrices.

This one should be harder to determine (and render) and especially so for larger N.

# future additional feature to be determined later