213 - A23 - Invertible Equivalents

47 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 pretty_print(html("<font size=+2 color=blue>Enter N below. Click 'Update' twice to change the size. </font>")) pretty_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 pretty_print(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.

pretty_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: pretty_print(html("<font size=+1 color=red>Matrix is Singular. Please pick another!</font>")) pretty_print(html("<font size=+2 color=blue>Using the matrix</font>")) show(A) 
       

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.
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/42640MyMatrix.sobj
Save your Matrix to a File so that you can use the same one next time
/home/sageserver/.sage/temp/travis-PowerEdge-T430/42640MyMatrix.sobj
print "Reload your Matrix from the file..." filename = 'MyMatrix' filename_for_loading = SAGE_TMP+filename print filename_for_loading A = load(filename_for_loading) A 
       
Reload your Matrix from the file...
/home/sageserver/.sage/temp/travis-PowerEdge-T430/42640MyMatrix
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/42640MyMatrix.sobj'
Reload your Matrix from the file...
/home/sageserver/.sage/temp/travis-PowerEdge-T430/42640MyMatrix
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_23.py", line 10, in <module>
    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 <module>
    
  File "/tmp/tmpnfSYd6/___code___.py", line 6, in <module>
    A = load(filename_for_loading)
  File "sage/misc/persist.pyx", line 151, in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2705)
IOError: [Errno 2] No such file or directory: '/home/sageserver/.sage/temp/travis-PowerEdge-T430/42640MyMatrix.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): global b,x b = random_matrix(QQ,N,1, num_bound=20, den_bound=4) pretty_print(html("<font size=+2 color=blue>For the vector $b =$</font>")) show(b) x = A.inverse()*b pretty_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

A*x-b 
       

                                
                            

                                

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 yields
Applying row reduction to  yields
Since each of these is the identity, the equivalences are shown.
                                
                            
Applying row reduction to A yields
Applying row reduction to  yields
Since 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.

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


                                
                            


                                

Theorem 7

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

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


                                
                            


                                

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) = -9528005431/48
                                
                            
The matrix A has determinant det(A) = -9528005431/48
                                

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) show("b =",b) x = A\b show("x = ",x) 
       

                                
                            

                                

Save this for Chapter 5...

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

pretty_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: pretty_print(html("<font size=+2 color=blue><b>They are all nonzero.</b></font>")) 
       
The eigenvalues for  =
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