182 [-0.52532209, -0.08675134, -0.81649658], |
182 [-0.52532209, -0.08675134, -0.81649658], |
183 [-0.8186735 , 0.61232756, 0.40824829]])) |
183 [-0.8186735 , 0.61232756, 0.40824829]])) |
184 \end{lstlisting} |
184 \end{lstlisting} |
185 \end{frame} |
185 \end{frame} |
186 |
186 |
|
187 \section{Solving linear equations} |
|
188 \begin{frame}[fragile] |
|
189 \frametitle{Solution of equations} |
|
190 Example problem: Consider the set of equations |
|
191 \begin{align*} |
|
192 3x + 2y - z & = 1 \\ |
|
193 2x - 2y + 4z & = -2 \\ |
|
194 -x + \frac{1}{2}y -z & = 0 |
|
195 \end{align*} |
|
196 |
|
197 To Solve this, |
|
198 \begin{lstlisting} |
|
199 In []: A = array([[3,2,-1],[2,-2,4],[-1, 0.5, -1]]) |
|
200 In []: b = array([1, -2, 0]) |
|
201 In []: x = linalg.solve(A, b) |
|
202 In []: Ax = dot(A, x) |
|
203 In []: allclose(Ax, b) |
|
204 Out[]: True |
|
205 \end{lstlisting} |
|
206 \end{frame} |
|
207 |
|
208 |
187 \begin{frame}[fragile] |
209 \begin{frame}[fragile] |
188 \frametitle{ODE Integration} |
210 \frametitle{ODE Integration} |
189 We shall use the simple ODE of a simple pendulum. |
211 We shall use the simple ODE of a simple pendulum. |
190 \begin{equation*} |
212 \begin{equation*} |
191 \ddot{\theta} = -\frac{g}{L}sin(\theta) |
213 \ddot{\theta} = -\frac{g}{L}sin(\theta) |