Updated session 4 day 1.
authorSantosh G. Vattam <vattam.santosh@gmail.com>
Wed, 28 Oct 2009 16:02:38 +0530
changeset 235 8eab0fee0fc2
parent 234 68cb4265173a
child 236 da426ad6f0a9
Updated session 4 day 1.
day1/session4.tex
--- a/day1/session4.tex	Wed Oct 28 15:17:55 2009 +0530
+++ b/day1/session4.tex	Wed Oct 28 16:02:38 2009 +0530
@@ -136,14 +136,16 @@
 \begin{frame}[fragile]
 \frametitle{Matrices: Initializing}
 \begin{lstlisting}
-In []: A = ([[5, 2, 4], 
-            [-3, 6, 2], 
-            [3, -3, 1]])
-
+In []: A = matrix([[ 1,  1,  2, -1],
+                   [ 2,  5, -1, -9],
+                   [ 2,  1, -1,  3],
+                   [ 1, -3,  2,  7]])
 In []: A
-Out[]: [[5, 2, 4], 
-        [-3, 6, 2], 
-        [3, -3, 1]]
+Out[]: 
+matrix([[ 1,  1,  2, -1],
+        [ 2,  5, -1, -9],
+        [ 2,  1, -1,  3],
+        [ 1, -3,  2,  7]])
 \end{lstlisting}
 \end{frame}
 
@@ -153,10 +155,11 @@
 \frametitle{Transpose of a Matrix}
 \begin{lstlisting}
 In []: linalg.transpose(A)
-Out[]: 
-matrix([[ 5, -3,  3],
-        [ 2,  6, -3],
-        [ 4,  2,  1]])
+Out[]:
+matrix([[ 1,  2,  2,  1],
+        [ 1,  5,  1, -3],
+        [ 2, -1, -1,  2],
+        [-1, -9,  3,  7]])
 \end{lstlisting}
 \end{frame}
 
@@ -164,22 +167,23 @@
   \frametitle{Sum of all elements}
   \begin{lstlisting}
 In []: linalg.sum(A)
-Out[]: 17
+Out[]: 12
   \end{lstlisting}
 \end{frame}
 
 \begin{frame}[fragile]
   \frametitle{Matrix Addition}
   \begin{lstlisting}
-In []: B = matrix([[3,2,-1],
-                   [2,-2,4],
-                   [-1, 0.5, -1]])
-
-In []: linalg.add(A, B)
+In []: B = matrix([[3,2,-1,5],
+                   [2,-2,4,9],
+                   [-1,0.5,-1,-7],
+                   [9,-5,7,3]])
+In []: linalg.add(A,B)
 Out[]: 
-matrix([[ 8. ,  4. ,  3. ],
-        [-1. ,  4. ,  6. ],
-        [ 2. , -2.5,  0. ]])
+matrix([[  4. ,   3. ,   1. ,   4. ],
+        [  4. ,   3. ,   3. ,   0. ],
+        [  1. ,   1.5,  -2. ,  -4. ],
+        [ 10. ,  -8. ,   9. ,  10. ]])
   \end{lstlisting}
 \end{frame}
 
@@ -188,9 +192,10 @@
 \begin{lstlisting}
 In []: linalg.multiply(A, B)
 Out[]: 
-matrix([[ 15. ,   4. ,  -4. ],
-        [ -6. , -12. ,   8. ],
-        [ -3. ,  -1.5,  -1. ]])
+matrix([[  3. ,   2. ,  -2. ,  -5. ],
+        [  4. , -10. ,  -4. , -81. ],
+        [ -2. ,   0.5,   1. , -21. ],
+        [  9. ,  15. ,  14. ,  21. ]])
 \end{lstlisting}
 \end{frame}
 
@@ -200,9 +205,10 @@
 \begin{lstlisting}
 In []: linalg.inv(A)
 Out[]: 
-array([[ 0.28571429, -0.33333333, -0.47619048],
-       [ 0.21428571, -0.16666667, -0.52380952],
-       [-0.21428571,  0.5       ,  0.85714286]])
+matrix([[-0.5 ,  0.55, -0.15,  0.7 ],
+        [ 0.75, -0.5 ,  0.5 , -0.75],
+        [ 0.5 , -0.15, -0.05, -0.1 ],
+        [ 0.25, -0.25,  0.25, -0.25]])
 \end{lstlisting}
 \end{small}
 \end{frame}
@@ -211,7 +217,7 @@
 \frametitle{Determinant}
 \begin{lstlisting}
 In []: det(A)
-Out[]: 42.0
+Out[66]: 80.0
 \end{lstlisting}
 \end{frame}
 
@@ -221,10 +227,11 @@
 \begin{lstlisting}
 In []: linalg.eig(A)
 Out[]: 
-(array([ 7.,  2.,  3.]),
- matrix([[-0.57735027,  0.42640143,  0.37139068],
-        [ 0.57735027,  0.63960215,  0.74278135],
-        [-0.57735027, -0.63960215, -0.55708601]]))
+(array([ 11.41026155,   3.71581643,  -0.81723144,  -2.30884654]),
+ matrix([[ 0.12300187, -0.53899627,  0.63269982,  0.56024583],
+        [ 0.8225266 , -0.67562403, -0.63919634, -0.20747251],
+        [-0.04763219, -0.47575453, -0.3709497 , -0.80066041],
+        [-0.55321941, -0.16331814, -0.23133374,  0.04497415]]))
 \end{lstlisting}
 \end{small}
 \end{frame}
@@ -232,8 +239,8 @@
 \begin{frame}[fragile]
 \frametitle{Computing Norms}
 \begin{lstlisting}
-  In []: linalg.norm(A)
-  Out[]: 10.63014581273465
+In []: linalg.norm(A)
+Out[]: 14.0
 \end{lstlisting}
 \end{frame}
 
@@ -243,14 +250,16 @@
   \begin{lstlisting}
 In []: linalg.svd(A)
 Out[]: 
-(matrix([[-0.13391246, -0.94558684, -0.29653495],
-        [ 0.84641267, -0.26476432,  0.46204486],
-        [-0.51541542, -0.18911737,  0.83581192]]),
- array([ 7.96445022,  7.        ,  0.75334767]),
- matrix([[-0.59703387,  0.79815896,  0.08057807],
-        [-0.64299905, -0.41605821, -0.64299905],
-        [-0.47969029, -0.43570384,  0.7616163 ]]))
-  \end{lstlisting}
+(matrix([[-0.08588113,  0.29164297, -0.74892678,  0.58879325],
+        [-0.79093255,  0.39530483, -0.11188116, -0.45347812],
+        [ 0.1523891 ,  0.78799358,  0.51966138,  0.29290907],
+        [ 0.58636823,  0.37113957, -0.39565558, -0.60156827]]),
+ array([ 13.17656506,   3.76954116,   2.79959047,   0.57531379]),
+ matrix([[-0.05893795, -0.42858358,  0.12442679,  0.89295039],
+        [ 0.80364672,  0.51537891,  0.03774111,  0.29514767],
+        [-0.11752501,  0.14226922, -0.96333552,  0.19476145],
+        [-0.58040171,  0.72832696,  0.23468759,  0.27855956]]))
+\end{lstlisting}
   \end{small}
 \end{frame}
 
@@ -316,8 +325,15 @@
 \end{frame}
 
 \subsection{Exercises}
+
 \begin{frame}[fragile]
-\frametitle{Problem 1}
+\frametitle{Problem}
+
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Problem}
+Solve the set of equations:
 \begin{align*}
   x + y + 2z -w & = 3\\
   2x + 5y - z - 9w & = -3\\