equal
deleted
inserted
replaced
186 \end{frame} |
186 \end{frame} |
187 |
187 |
188 \subsection{Exercises} |
188 \subsection{Exercises} |
189 |
189 |
190 \begin{frame}[fragile] |
190 \begin{frame}[fragile] |
191 \frametitle{Problem 1} |
191 \frametitle{Problem} |
192 Given the matrix:\\ |
|
193 \begin{center} |
|
194 $\begin{bmatrix} |
|
195 -2 & 2 & 3\\ |
|
196 2 & 1 & 6\\ |
|
197 -1 &-2 & 0\\ |
|
198 \end{bmatrix}$ |
|
199 \end{center} |
|
200 Find: |
|
201 \begin{itemize} |
|
202 \item[i] Transpose |
|
203 \item[ii]Inverse |
|
204 \item[iii]Determinant |
|
205 \item[iv] Eigenvalues and Eigen vectors |
|
206 \item[v] Singular Value decomposition |
|
207 \end{itemize} |
|
208 \end{frame} |
|
209 |
|
210 \begin{frame}[fragile] |
|
211 \frametitle{Problem 2} |
|
212 Given |
|
213 \begin{center} |
|
214 A = |
|
215 $\begin{bmatrix} |
|
216 -3 & 1 & 5 \\ |
|
217 1 & 0 & -2 \\ |
|
218 5 & -2 & 4 \\ |
|
219 \end{bmatrix}$ |
|
220 , B = |
|
221 $\begin{bmatrix} |
|
222 0 & 9 & -12 \\ |
|
223 -9 & 0 & 20 \\ |
|
224 12 & -20 & 0 \\ |
|
225 \end{bmatrix}$ |
|
226 \end{center} |
|
227 Find: |
|
228 \begin{itemize} |
|
229 \item[i] Sum of A and B |
|
230 \item[ii]Elementwise Product of A and B |
|
231 \item[iii] Matrix product of A and B |
|
232 \end{itemize} |
|
233 \end{frame} |
|
234 |
|
235 \begin{frame}[fragile] |
|
236 \frametitle{Solution} |
|
237 Sum: |
|
238 $\begin{bmatrix} |
|
239 -3 & 10 & 7 \\ |
|
240 -8 & 0 & 18 \\ |
|
241 17 & -22 & 4 \\ |
|
242 \end{bmatrix}$ |
|
243 ,\\ Elementwise Product: |
|
244 $\begin{bmatrix} |
|
245 0 & 9 & -60 \\ |
|
246 -9 & 0 & -40 \\ |
|
247 60 & 40 & 0 \\ |
|
248 \end{bmatrix}$ |
|
249 ,\\ Matrix product: |
|
250 $\begin{bmatrix} |
|
251 51 & -127 & 56 \\ |
|
252 -24 & 49 & -12 \\ |
|
253 66 & -35 & -100 \\ |
|
254 \end{bmatrix}$ |
|
255 \end{frame} |
|
256 |
|
257 \begin{frame}[fragile] |
|
258 \frametitle{Problem 3} |
|
259 Solve the set of equations: |
192 Solve the set of equations: |
260 \begin{align*} |
193 \begin{align*} |
261 x + y + 2z -w & = 3\\ |
194 x + y + 2z -w & = 3\\ |
262 2x + 5y - z - 9w & = -3\\ |
195 2x + 5y - z - 9w & = -3\\ |
263 2x + y -z + 3w & = -11 \\ |
196 2x + y -z + 3w & = -11 \\ |
372 %% \end{lstlisting} |
305 %% \end{lstlisting} |
373 %% \end{small} |
306 %% \end{small} |
374 %% \end{frame} |
307 %% \end{frame} |
375 |
308 |
376 \section{ODEs} |
309 \section{ODEs} |
377 \begin{frame}[fragile] |
310 |
378 \frametitle{ODE Integration} |
311 \begin{frame}[fragile] |
|
312 \frametitle{Solving ODEs using SciPy} |
|
313 \begin{itemize} |
|
314 \item Let's consider the spread of an epidemic in a population |
|
315 \item $\frac{dy}{dt} = ky(L-y)$ gives the spread of the disease |
|
316 \item L is the total population. |
|
317 \item Use L = 25000, k = 0.00003, y(0) = 250 |
|
318 \item Define a function as below |
|
319 \end{itemize} |
|
320 \begin{lstlisting} |
|
321 In []: def epid(y, t): |
|
322 .... k, L = 0.00003, 25000 |
|
323 .... return k*y*(L-y) |
|
324 .... |
|
325 \end{lstlisting} |
|
326 \end{frame} |
|
327 |
|
328 \begin{frame}[fragile] |
|
329 \frametitle{Solving ODEs using SciPy \ldots} |
|
330 \begin{lstlisting} |
|
331 In []: t = arange(0, 12, 0.2) |
|
332 |
|
333 In []: y = odeint(epid, 250, t) |
|
334 |
|
335 In []: plot(t, y) |
|
336 \end{lstlisting} |
|
337 %Insert Plot |
|
338 \end{frame} |
|
339 |
|
340 \begin{frame}[fragile] |
|
341 \frametitle{ODEs - Simple Pendulum} |
379 We shall use the simple ODE of a simple pendulum. |
342 We shall use the simple ODE of a simple pendulum. |
380 \begin{equation*} |
343 \begin{equation*} |
381 \ddot{\theta} = -\frac{g}{L}sin(\theta) |
344 \ddot{\theta} = -\frac{g}{L}sin(\theta) |
382 \end{equation*} |
345 \end{equation*} |
383 \begin{itemize} |
346 \begin{itemize} |
390 \theta = \theta_0(10^o)\quad & \&\quad \omega = 0\ (Initial\ values)\nonumber |
353 \theta = \theta_0(10^o)\quad & \&\quad \omega = 0\ (Initial\ values)\nonumber |
391 \end{align} |
354 \end{align} |
392 \end{frame} |
355 \end{frame} |
393 |
356 |
394 \begin{frame}[fragile] |
357 \begin{frame}[fragile] |
395 \frametitle{Solving ODEs using SciPy} |
358 \frametitle{ODEs - Simple Pendulum \ldots} |
396 \begin{itemize} |
359 \begin{itemize} |
397 \item We use the \typ{odeint} function from scipy to do the integration |
360 \item Use \typ{odeint} to do the integration |
398 \item Define a function as below |
|
399 \end{itemize} |
361 \end{itemize} |
400 \begin{lstlisting} |
362 \begin{lstlisting} |
401 In []: def pend_int(initial, t): |
363 In []: def pend_int(initial, t): |
402 .... theta, omega = initial |
364 .... theta, omega = initial |
403 .... g, L = 9.81, 0.2 |
365 .... g, L = 9.81, 0.2 |
406 .... |
368 .... |
407 \end{lstlisting} |
369 \end{lstlisting} |
408 \end{frame} |
370 \end{frame} |
409 |
371 |
410 \begin{frame}[fragile] |
372 \begin{frame}[fragile] |
411 \frametitle{Solving ODEs using SciPy \ldots} |
373 \frametitle{ODEs - Simple Pendulum \ldots} |
412 \begin{itemize} |
374 \begin{itemize} |
413 \item \typ{t} is the time variable \\ |
375 \item \typ{t} is the time variable \\ |
414 \item \typ{initial} has the initial values |
376 \item \typ{initial} has the initial values |
415 \end{itemize} |
377 \end{itemize} |
416 \begin{lstlisting} |
378 \begin{lstlisting} |
418 In []: initial = [10*2*pi/360, 0] |
380 In []: initial = [10*2*pi/360, 0] |
419 \end{lstlisting} |
381 \end{lstlisting} |
420 \end{frame} |
382 \end{frame} |
421 |
383 |
422 \begin{frame}[fragile] |
384 \begin{frame}[fragile] |
423 \frametitle{Solving ODEs using SciPy \ldots} |
385 \frametitle{ODEs - Simple Pendulum \ldots} |
424 %%\begin{small} |
386 %%\begin{small} |
425 \typ{In []: from scipy.integrate import odeint} |
387 \typ{In []: from scipy.integrate import odeint} |
426 %%\end{small} |
388 %%\end{small} |
427 \begin{lstlisting} |
389 \begin{lstlisting} |
428 In []: pend_sol = odeint(pend_int, |
390 In []: pend_sol = odeint(pend_int, |