matrices/script.rst
changeset 404 3117f104c577
parent 394 1a79f9ee7f5c
child 477 0406115dccd1
equal deleted inserted replaced
403:9858ca9e3f93 404:3117f104c577
    28 .. Author              : Anoop Jacob Thomas <anoop@fossee.in>
    28 .. Author              : Anoop Jacob Thomas <anoop@fossee.in>
    29    Internal Reviewer   : 
    29    Internal Reviewer   : 
    30    External Reviewer   :
    30    External Reviewer   :
    31    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    31    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    32 
    32 
       
    33 .. #[punch: please mark the exercises, using the syntax we decided upon.]
    33 
    34 
    34 ========
    35 ========
    35 Matrices
    36 Matrices
    36 ========
    37 ========
    37 {{{ show the welcome slide }}}
    38 {{{ show the welcome slide }}}
    39 Welcome to the spoken tutorial on Matrices.
    40 Welcome to the spoken tutorial on Matrices.
    40 
    41 
    41 {{{ switch to next slide, outline slide }}}
    42 {{{ switch to next slide, outline slide }}}
    42 
    43 
    43 In this tutorial we will learn about matrices, creating matrices using
    44 In this tutorial we will learn about matrices, creating matrices using
    44 direct data, by converting a list, matrix operations. Finding inverse
    45 direct data, by converting a list and matrix operations. Finding
    45 of a matrix, determinant of a matrix, eigen values and eigen vectors
    46 inverse of a matrix, determinant of a matrix, eigen values and eigen
    46 of a matrix, norm and singular value decomposition of matrices.
    47 vectors of a matrix, norm and singular value decomposition of
       
    48 matrices.
    47 
    49 
    48 {{{ creating a matrix }}}
    50 {{{ creating a matrix }}}
    49 
    51 
    50 All matrix operations are done using arrays. Thus all the operations
    52 All matrix operations are done using arrays. Thus all the operations
    51 on arrays are valid on matrices also. A matrix may be created as,
    53 on arrays are valid on matrices also. A matrix may be created as,
   156 
   158 
   157 Matrix name dot capital T will give the transpose of a matrix
   159 Matrix name dot capital T will give the transpose of a matrix
   158 
   160 
   159 {{{ switch to next slide, Frobenius norm of inverse of matrix }}}
   161 {{{ switch to next slide, Frobenius norm of inverse of matrix }}}
   160 
   162 
       
   163 .. #[punch: arange has not been introduced.]
       
   164 
   161 Now let us try to find out the Frobenius norm of inverse of a 4 by 4
   165 Now let us try to find out the Frobenius norm of inverse of a 4 by 4
   162 matrix, the matrix being,
   166 matrix, the matrix being,
   163 ::
   167 ::
   164 
   168 
   165     m5 = arange(1,17).reshape(4,4)
   169     m5 = arange(1,17).reshape(4,4)
   175 And here is the solution, first let us find the inverse of matrix m5.
   179 And here is the solution, first let us find the inverse of matrix m5.
   176 ::
   180 ::
   177 
   181 
   178     im5 = inv(m5)
   182     im5 = inv(m5)
   179 
   183 
       
   184 .. #[punch: we don't need to show this way of calculating the norm, do
       
   185 .. we? even if we do, we should show it in the "array style".
       
   186 .. something like:
       
   187 .. sqrt(sum(each * each))]
       
   188 
   180 And the Frobenius norm of the matrix ``im5`` can be found out as,
   189 And the Frobenius norm of the matrix ``im5`` can be found out as,
   181 ::
   190 ::
   182 
   191 
   183     sum = 0
   192     sum = 0
   184     for each in im5.flatten():
   193     for each in im5.flatten():
   185         sum += each * each
   194         sum += each * each
   186     print sqrt(sum)
   195     print sqrt(sum)
   187 
   196 
   188 {{{ switch to next slide, infinity norm }}}
   197 {{{ switch to next slide, infinity norm }}}
       
   198 .. #[punch: similarly for this section.]
   189 
   199 
   190 Now try to find out the infinity norm of the matrix im5. The infinity
   200 Now try to find out the infinity norm of the matrix im5. The infinity
   191 norm of a matrix is defined as the maximum value of sum of the
   201 norm of a matrix is defined as the maximum value of sum of the
   192 absolute of elements in each row. Pause here and try to solve the
   202 absolute of elements in each row. Pause here and try to solve the
   193 problem yourself.
   203 problem yourself.
   194 
   204 
       
   205 
   195 The solution for the problem is,
   206 The solution for the problem is,
   196 ::
   207 ::
   197 
   208 
   198     sum_rows = []
   209     sum_rows = []
   199     for i in im5:
   210     for i in im5:
   239 Let us find out the eigen values and eigen vectors of the matrix
   250 Let us find out the eigen values and eigen vectors of the matrix
   240 m5. We can do it as,
   251 m5. We can do it as,
   241 ::
   252 ::
   242 
   253 
   243     eig(m5)
   254     eig(m5)
       
   255 
       
   256 
       
   257 .. #[punch: has the tuple word been introduced?]
   244 
   258 
   245 Note that it returned a tuple of two matrices. The first element in
   259 Note that it returned a tuple of two matrices. The first element in
   246 the tuple are the eigen values and the second element in the tuple are
   260 the tuple are the eigen values and the second element in the tuple are
   247 the eigen vectors. Thus the eigen values are,
   261 the eigen vectors. Thus the eigen values are,
   248 ::
   262 ::
   298 .. 
   312 .. 
   299    Local Variables:
   313    Local Variables:
   300    mode: rst
   314    mode: rst
   301    indent-tabs-mode: nil
   315    indent-tabs-mode: nil
   302    sentence-end-double-space: nil
   316    sentence-end-double-space: nil
   303    fill-column: 75
   317    fill-column: 70
   304    End:
   318    End: