day1/session4.tex
changeset 232 b9748af050c4
parent 214 19592f802dde
child 233 c435d5846ef5
equal deleted inserted replaced
219:f6725f6bee41 232:b9748af050c4
   280                        [2,-2,4],
   280                        [2,-2,4],
   281                        [-1, 0.5, -1]])
   281                        [-1, 0.5, -1]])
   282     In []: b = matrix([[1], [-2], [0]])
   282     In []: b = matrix([[1], [-2], [0]])
   283     In []: x = linalg.solve(A, b)
   283     In []: x = linalg.solve(A, b)
   284     In []: Ax = dot(A, x)
   284     In []: Ax = dot(A, x)
   285     In []: allclose(Ax, b)
       
   286     Out[]: True
       
   287   \end{lstlisting}
   285   \end{lstlisting}
   288 \end{frame}
   286 \end{frame}
   289 
   287 
   290 \begin{frame}[fragile]
   288 \begin{frame}[fragile]
   291 \frametitle{Solution:}
   289 \frametitle{Solution:}
   293 In []: x
   291 In []: x
   294 Out[]: 
   292 Out[]: 
   295 array([[ 1.],
   293 array([[ 1.],
   296        [-2.],
   294        [-2.],
   297        [-2.]])
   295        [-2.]])
   298 
   296 \end{lstlisting}
       
   297 \end{frame}
       
   298 
       
   299 \begin{frame}[fragile]
       
   300 \frametitle{Let's check!}
       
   301 \begin{lstlisting}
   299 In []: Ax
   302 In []: Ax
   300 Out[]: 
   303 Out[]: 
   301 matrix([[  1.00000000e+00],
   304 matrix([[  1.00000000e+00],
   302         [ -2.00000000e+00],
   305         [ -2.00000000e+00],
   303         [  2.22044605e-16]])
   306         [  2.22044605e-16]])
   304 \end{lstlisting}
   307 \end{lstlisting}
       
   308 \begin{block}{}
       
   309 The last term in the matrix is actually \alert{0}!\\
       
   310 We can use \kwrd{allclose()} to check.
       
   311 \end{block}
       
   312 \begin{lstlisting}
       
   313 In []: allclose(Ax, b)
       
   314 Out[]: True
       
   315 \end{lstlisting}
       
   316 \end{frame}
       
   317 
       
   318 \begin{frame}[fragile]
       
   319 \frametitle{Exercises}
       
   320 
   305 \end{frame}
   321 \end{frame}
   306 
   322 
   307 \section{Summary}
   323 \section{Summary}
   308 \begin{frame}
   324 \begin{frame}
   309   \frametitle{Summary}
   325   \frametitle{Summary}