Merged all files. It is a trick. If you want to know RTFM.
--- a/day1/cheatsheet2.tex Tue Nov 10 14:33:51 2009 +0530
+++ b/day1/cheatsheet2.tex Tue Nov 10 17:22:07 2009 +0530
@@ -25,6 +25,19 @@
\LARGE{Plotting Points}\\
\large{FOSSEE}
\end{center}
+\section{Plotting from Data files}
+\begin{verbatim}
+l = [] #Empty List
+t = []
+for line in open('pendulum.txt'): # Opening & Reading files
+ points = line.split() # Splitting a string
+ l.append(float(points[0])) # Appending to a list
+ t.append(float(points[1]))
+tsq = []
+for time in t: #Iterating through lists
+ tsq.append(t*t)
+plot(l, tsq, '.') # Plotting points
+\end{verbatim}
\section{Plotting Points with Lists}
\begin{lstlisting}
@@ -95,6 +108,5 @@
In [27]: plot(L, TSq, '.')
\end{lstlisting}
-
\end{document}
Binary file day1/data/plot1.png has changed
Binary file day1/data/plot10.png has changed
Binary file day1/data/plot11.png has changed
Binary file day1/data/plot2.png has changed
Binary file day1/data/plot3.png has changed
Binary file day1/data/plot4.png has changed
Binary file day1/data/plot5.png has changed
Binary file day1/data/plot6.png has changed
Binary file day1/data/plot7.png has changed
Binary file day1/data/plot8.png has changed
Binary file day1/data/plot9.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercises.tex Tue Nov 10 17:22:07 2009 +0530
@@ -0,0 +1,187 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%Tutorial slides on Python.
+%
+% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in>
+% Copyright (c) 2005-2009, Prabhu Ramachandran
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\documentclass[14pt,compress]{beamer}
+%\documentclass[draft]{beamer}
+%\documentclass[compress,handout]{beamer}
+%\usepackage{pgfpages}
+%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
+
+% Modified from: generic-ornate-15min-45min.de.tex
+\mode<presentation>
+{
+ \usetheme{Warsaw}
+ \useoutertheme{infolines}
+ \setbeamercovered{transparent}
+}
+
+\usepackage[english]{babel}
+\usepackage[latin1]{inputenc}
+%\usepackage{times}
+\usepackage[T1]{fontenc}
+
+% Taken from Fernando's slides.
+\usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler}
+\usepackage[scaled=.95]{helvet}
+
+\definecolor{darkgreen}{rgb}{0,0.5,0}
+
+\usepackage{listings}
+\lstset{language=Python,
+ basicstyle=\ttfamily\bfseries,
+ commentstyle=\color{red}\itshape,
+ stringstyle=\color{darkgreen},
+ showstringspaces=false,
+ keywordstyle=\color{blue}\bfseries}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Macros
+\setbeamercolor{emphbar}{bg=blue!20, fg=black}
+\newcommand{\emphbar}[1]
+{\begin{beamercolorbox}[rounded=true]{emphbar}
+ {#1}
+ \end{beamercolorbox}
+}
+\newcounter{time}
+\setcounter{time}{0}
+\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
+
+\newcommand{\typ}[1]{\texttt{#1}}
+
+\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
+
+%%% This is from Fernando's setup.
+% \usepackage{color}
+% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
+% % Use and configure listings package for nicely formatted code
+% \usepackage{listings}
+% \lstset{
+% language=Python,
+% basicstyle=\small\ttfamily,
+% commentstyle=\ttfamily\color{blue},
+% stringstyle=\ttfamily\color{orange},
+% showstringspaces=false,
+% breaklines=true,
+% postbreak = \space\dots
+% }
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Title page
+\title[Exercises]{Exercises}
+
+\author[FOSSEE] {FOSSEE}
+
+\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\date[] {7 November, 2009\\Day 1, Session 5}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
+%\logo{\pgfuseimage{iitmlogo}}
+
+
+%% Delete this, if you do not want the table of contents to pop up at
+%% the beginning of each subsection:
+\AtBeginSubsection[]
+{
+ \begin{frame}<beamer>
+ \frametitle{Outline}
+ \tableofcontents[currentsection,currentsubsection]
+ \end{frame}
+}
+
+
+% If you wish to uncover everything in a step-wise fashion, uncomment
+% the following command:
+%\beamerdefaultoverlayspecification{<+->}
+
+%\includeonlyframes{current,current1,current2,current3,current4,current5,current6}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% DOCUMENT STARTS
+\begin{document}
+
+\begin{frame}
+ \titlepage
+\end{frame}
+
+
+\begin{frame}
+ \frametitle{Problem 1}
+ \begin{itemize}
+ \item Open file 'pos.txt', it has X and Y Coordinate of a particle under motion
+ \item Plot X vs Y Graph.
+ \item Label both the axes.
+ \item What kind of motion is this?
+ \item Title the graph accordingly.
+ \item Annotate the position where vertical velocity is zero.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Problem 2}
+Write a Program that plots a regular n-gon(Let n = 5).
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Problem 3}
+Create a sequence of images in which the damped oscillator($e^{x/10}sin(x)$) slowly evolves over time.
+\begin{columns}
+\column{0.35\textwidth}
+\includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot2}
+\column{0.35\textwidth}
+\includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot4}
+\column{0.35\textwidth}
+\includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot6}
+\end{columns}
+\begin{block}{Hint}
+\small
+ \begin{lstlisting}
+savefig('plot'+str(i)+'.png') #i is int variable
+ \end{lstlisting}
+\end{block}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Problem 4}
+ Legendre polynomials $P_n(x)$ are defined by the following recurrence relation
+
+\center{$(n+1)P_{n+1}(x) - (2n+1)xP_n(x) + nP_{n-1}(x) = 0$}\\
+
+with $P_0(x) = 1$, $P_1(x) = x$ and $P_2(x) = (3x^2 - 1)/2$. Compute the next three
+ Legendre polynomials and plot all 6 over the interval [-1,1].
+\end{frame}
+\end{document}
+
+%% \begin{frame}[fragile]
+%% \frametitle{Problem Set 5}
+%% \begin{columns}
+%% \column{0.6\textwidth}
+%% \small{
+%% \begin{itemize}
+%% \item[3] Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) = kx(1-x)$. Plot the successive iterates of this process as explained below.
+%% \end{itemize}}
+%% \column{0.35\textwidth}
+%% \hspace*{-0.5in}
+%% \includegraphics[height=1.6in, interpolate=true]{data/cobweb}
+%% \end{columns}
+%% \end{frame}
+
+%% \begin{frame}
+%% \frametitle{Problem Set 5.3}
+%% Plot the cobweb plot as follows:
+%% \begin{enumerate}
+%% \item Start at $(x_0, 0)$ ($\implies$ i=0)
+%% \item Draw a line to $(x_i, f(x_i))$
+%% \item Set $x_{i+1} = f(x_i)$
+%% \item Draw a line to $(x_{i+1}, x_{i+1})$
+%% \item $(i\implies i+1)$
+%% \item Repeat from 2 for as long as you want
+%% \end{enumerate}
+%% \inctime{20}
+%% \end{frame}
--- a/day1/session1.tex Tue Nov 10 14:33:51 2009 +0530
+++ b/day1/session1.tex Tue Nov 10 17:22:07 2009 +0530
@@ -130,9 +130,9 @@
\item[Session 3] Sat 11:20--12:20
\item[Session 4] Sat 12:25--13:25
\item[Quiz 1] Sat 14:25--14:40
- \item[Session 5] Sat 14:40--15:40
- \item[Session 6] Sat 15:55--16:55
- \item[Quiz 2] Sat 17:00--17:15
+ \item[Session 5] Sat 14:40--15:25
+ \item[Session 6] Sat 15:40--16:40
+ \item[Quiz 2] Sat 16:45--17:00
\end{description}
\end{frame}
@@ -144,9 +144,9 @@
\item[Session 3] Sun 11:20--12:20
\item[Session 4] Sun 12:25--13:25
\item[Quiz 1] Sun 14:25--14:40
- \item[Session 5] Sun 14:40--15:40
- \item[Session 6] Sun 15:55--16:55
- \item[Quiz 2] Sun 17:00--17:15
+ \item[Session 5] Sun 14:40--15:25
+ \item[Session 6] Sun 15:40--16:40
+ \item[Quiz 2] Sun 16:45--17:00
\end{description}
\end{frame}
@@ -488,6 +488,14 @@
\end{frame}
\begin{frame}
+\frametitle{Python Scripts\ldots}
+ This is called a Python Script.
+ \begin{itemize}
+ \item run the script in IPython using \typ{\%run -i sine_plot.py}\\
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
\frametitle{What did we learn?}
\begin{itemize}
\item Creating simple plots.
--- a/day1/session2.tex Tue Nov 10 14:33:51 2009 +0530
+++ b/day1/session2.tex Tue Nov 10 17:22:07 2009 +0530
@@ -123,16 +123,7 @@
% You might wish to add the option [pausesections]
\end{frame}
-\section{Scripts}
-
-\begin{frame}[fragile]
-\frametitle{Python Scripts}
- \begin{itemize}
- \item four\_plot.py is called a Python Script
- \item run the file in IPython using \typ{\%run -i four_plot.py}
- \end{itemize}
-\end{frame}
-
+\section{Plotting Points}
\begin{frame}[fragile]
\frametitle{Why would I plot f(x)?}
How often do we plot analytical functions?\\We plot experimental data more.
@@ -197,22 +188,27 @@
\section{Lists}
\begin{frame}[fragile]
- \frametitle{How to create the data?}
-What were \typ{x} and \typ{y}?\\
+ \frametitle{Lists: Introduction}
+ \begin{lstlisting}
+ In []: x = [0, 1, 2, 3]
+
+ In []: y = [7, 11, 15, 19]
+
+ \end{lstlisting}
+What are \typ{x} and \typ{y}?\\
\begin{center}
\alert{\typ{lists!!}}
\end{center}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Lists: Initializing \& accessing elements}
\begin{lstlisting}
In []: mtlist = [] #Empty List
-In []: lst = [ 1, 2, 3, 4, 5]
-\end{lstlisting}
-\end{frame}
+In []: a = [ 1, 2, 3, 4, 5]
-\begin{frame}[fragile]
-\frametitle{Accessing elements of a list}
-\begin{lstlisting}
-In []: lst[0]+lst[1]+lst[-1]
+In []: a[0]+a[1]+a[-1]
Out[]: 8
\end{lstlisting}
\end{frame}
@@ -220,13 +216,13 @@
\begin{frame}[fragile]
\frametitle{List: Slicing}
\begin{block}{Remember\ldots}
- \kwrd{In []: lst = [ 1, 2, 3, 4, 5]}
+ \kwrd{In []: a = [ 1, 2, 3, 4, 5]}
\end{block}
\begin{lstlisting}
-In []: lst[1:3] # A slice.
+In []: a[1:3] # A slice.
Out[]: [2, 3]
-In []: lst[1:-1]
+In []: a[1:-1]
Out[]: [2, 3, 4]
\end{lstlisting}
\alert{\typ{list[initial:final]}}
@@ -236,14 +232,14 @@
\begin{frame}[fragile]
\frametitle{List operations}
\begin{lstlisting}
-In []: a = [ 6, 7, 8, 9]
-In []: b = lst + a
+In []: b = [ 6, 7, 8, 9]
+In []: c = a + b
-In []: b
+In []: c
Out[]: [1, 2, 3, 4, 5, 6, 7, 8, 9]
-In []: lst.append(6)
-In []: lst
+In []: a.append(6)
+In []: a
Out[]: [ 1, 2, 3, 4, 5, 6]
\end{lstlisting}
%\inctime{10}
@@ -252,7 +248,7 @@
\section{Simple Pendulum}
\begin{frame}[fragile]
\frametitle{Simple Pendulum - L and T}
-Let us look at the example of the Simple Pendulum experiment.
+Let us look at the Simple Pendulum experiment.
\begin{center}
\begin{small}
\begin{tabular}{| c | c | c |}
@@ -276,10 +272,10 @@
\begin{frame}[fragile]
\frametitle{Lets use lists}
\begin{lstlisting}
-In []: L = [0.1, 0.2, 0.3, 0.4, 0.5,
+In []: l = [0.1, 0.2, 0.3, 0.4, 0.5,
0.6, 0.7, 0.8, 0.9]
-In []: T = [0.69, 0.8989, 1.1867,
+In []: t = [0.69, 0.8989, 1.1867,
1.2991, 1.4656, 1.5843,
1.7706, 1.8296, 1.9440]
\end{lstlisting}
@@ -288,24 +284,37 @@
\begin{frame}[fragile]
\frametitle{Plotting $L$ vs $T^2$}
\begin{itemize}
-\item We must square each of the values in T
+\item We must square each of the values in \typ{t}
\item How to do it?
-\item We use a \kwrd{for} loop to iterate over T
+\item We use a \kwrd{for} loop to iterate over \typ{t}
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Plotting $L$ vs $T^2$}
\begin{lstlisting}
-In []: TSq = []
+In []: tsq = []
-In []: for t in T:
- ....: TSq.append(t*t)
+In []: for time in t:
+ ....: tsq.append(time*time)
-In []: plot(L, TSq)
+In []: plot(l, tsq)
Out[]: [<matplotlib.lines.Line2D object at 0xa5b05ac>]
\end{lstlisting}
-This gives \kwrd{TSq} which is the list of squares of T values.
+This gives \kwrd{tsq} which is the list of squares of \typ{t} values.
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{How to come out of the \textt{for} loop?}
+ Hit the ``enter'' key twice to come to the previous indentation level
+ \begin{lstlisting}
+ In []: for time in t:
+ ....: tsq.append(time*time)
+ ....:
+ ....:
+
+ In []:
+ \end{lstlisting}
\end{frame}
\begin{frame}[fragile]
@@ -327,7 +336,10 @@
1.4000e-01 8.3568e-01
1.5000e-01 8.6789e-01
\end{lstlisting}
-\ldots %$
+\ldots
+\begin{block}{Windows users:}
+ > type pendulum.txt
+\end{block}
\end{frame}
\begin{frame}[fragile]
@@ -340,31 +352,28 @@
\end{frame}
\begin{frame}[fragile]
-\frametitle{Reading \typ{pendulum.txt}}
+\frametitle{Plotting from \typ{pendulum.txt}}
+Open a new script and type the following:
\begin{lstlisting}
-In []: L = []
-In []: T = []
-In []: for line in open('pendulum.txt'):
- .... points = line.split()
- .... L.append(float(points[0]))
- .... T.append(float(points[1]))
+l = []
+t = []
+for line in open('pendulum.txt'):
+ points = line.split()
+ l.append(float(points[0]))
+ t.append(float(points[1]))
+tsq = []
+for time in t:
+ tsq.append(time*time)
+plot(l, tsq, '.')
\end{lstlisting}
-\begin{itemize}
-\item We now have two lists L and T
-\item Now, repeat previous steps for plotting
-\end{itemize}
\end{frame}
-\begin{frame}[fragile]
-\frametitle{Plotting from \typ{pendulum.txt}}
-\begin{lstlisting}
-In []: TSq = []
-
-In []: for t in T:
- ....: TSq.append(t*t)
-
-In []: plot(L, TSq, '.')
-\end{lstlisting}
+\begin{frame}
+\frametitle{Save and run}
+\begin{itemize}
+ \item Save as pendulum\_plot.py.
+ \item Run using \kwrd{\%run -i pendulum\_plot.py}
+\end{itemize}
\end{frame}
\begin{frame}[fragile]
@@ -375,7 +384,7 @@
\begin{frame}[fragile]
\frametitle{Reading files \ldots}
-\typ{In []: for line in open('pendulum.txt'):}
+\typ{for line in open('pendulum.txt'):}
\begin{itemize}
\item opening file `\typ{pendulum.txt}'
\item reading the file line by line
@@ -429,23 +438,18 @@
\begin{frame}[fragile]
\frametitle{Let's review the code}
-\begin{small}
\begin{lstlisting}
-In []: L = []
-In []: T = []
-In []: for line in open('pendulum.txt'):
- .... points = line.split()
- .... L.append(float(points[0]))
- .... T.append(float(points[1]))
-
-In []: TSq = []
-
-In []: for t in T:
- ....: TSq.append(t*t)
-
-In []: plot(L, TSq, '.')
+l = []
+t = []
+for line in open('pendulum.txt'):
+ points = line.split()
+ l.append(float(points[0]))
+ t.append(float(points[1]))
+tsq = []
+for time in t:
+ tsq.append(time*time)
+plot(l, tsq, '.')
\end{lstlisting}
-\end{small}
\end{frame}
\begin{frame}[fragile]
@@ -458,8 +462,6 @@
\begin{frame}[fragile]
\frametitle{What did we learn?}
\begin{itemize}
- \item Python scripts
- \item \kwrd{\%run -i}
\item Plotting points
\item Plot attributes
\item Lists
--- a/day1/session4.tex Tue Nov 10 14:33:51 2009 +0530
+++ b/day1/session4.tex Tue Nov 10 17:22:07 2009 +0530
@@ -148,6 +148,29 @@
\end{frame}
\begin{frame}[fragile]
+\frametitle{Initializing some special matrices}
+\begin{small}
+ \begin{lstlisting}
+In []: ones((3,5))
+Out[]:
+array([[ 1., 1., 1., 1., 1.],
+ [ 1., 1., 1., 1., 1.],
+ [ 1., 1., 1., 1., 1.]])
+
+In []: ones_like([1, 2, 3, 4, 5])
+Out[]: array([1, 1, 1, 1, 1])
+
+In []: identity(2)
+Out[]:
+array([[ 1., 0.],
+ [ 0., 1.]])
+ \end{lstlisting}
+Also available \alert{\typ{zeros, zeros_like, empty, empty_like}}
+\end{small}
+\end{frame}
+
+
+\begin{frame}[fragile]
\frametitle{Accessing elements}
\begin{lstlisting}
In []: C = array([[1,1,2],
@@ -426,7 +449,7 @@
\section{Least Squares Fit}
\begin{frame}[fragile]
-\frametitle{$L$ vs. $T^2$}
+\frametitle{$L$ vs. $T^2$ - Scatter}
\vspace{-0.15in}
\begin{figure}
\includegraphics[width=4in]{data/L-Tsq-points}
@@ -434,7 +457,7 @@
\end{frame}
\begin{frame}[fragile]
-\frametitle{$L$ vs. $T^2$}
+\frametitle{$L$ vs. $T^2$ - Line}
\vspace{-0.15in}
\begin{figure}
\includegraphics[width=4in]{data/L-Tsq-Line}
@@ -442,7 +465,8 @@
\end{frame}
\begin{frame}[fragile]
-\frametitle{Least Squares Fit}
+\frametitle{$L$ vs. $T^2$ }
+\frametitle{$L$ vs. $T^2$ - Least Square Fit}
\vspace{-0.15in}
\begin{figure}
\includegraphics[width=4in]{data/least-sq-fit}
@@ -484,22 +508,6 @@
In []: A = array([L, ones_like(L)])
In []: A = A.T
\end{lstlisting}
-\begin{small}
-\begin{block}{}
- \begin{lstlisting}
-In []: ones((3,5))
-Out[]:
-array([[ 1., 1., 1., 1., 1.],
- [ 1., 1., 1., 1., 1.],
- [ 1., 1., 1., 1., 1.]])
-
-In []: ones_like([1, 2, 3, 4, 5])
-Out[]: array([1, 1, 1, 1, 1])
- \end{lstlisting}
-Also available \alert{\typ{zeros, zeros_like, empty, empty_like}}
-\end{block}
-\end{small}
-
%% \begin{itemize}
%% \item A is also called a Van der Monde matrix
%% \item It can also be generated using \typ{vander}
@@ -549,6 +557,7 @@
\begin{itemize}
\item Matrices
\begin{itemize}
+ \item Initializing
\item Accessing elements
\item Slicing and Striding
\item Transpose
--- a/day1/session6.tex Tue Nov 10 14:33:51 2009 +0530
+++ b/day1/session6.tex Tue Nov 10 17:22:07 2009 +0530
@@ -188,74 +188,7 @@
\subsection{Exercises}
\begin{frame}[fragile]
-\frametitle{Problem 1}
-Given the matrix:\\
-\begin{center}
-$\begin{bmatrix}
--2 & 2 & 3\\
- 2 & 1 & 6\\
--1 &-2 & 0\\
-\end{bmatrix}$
-\end{center}
-Find:
-\begin{itemize}
- \item[i] Transpose
- \item[ii]Inverse
- \item[iii]Determinant
- \item[iv] Eigenvalues and Eigen vectors
- \item[v] Singular Value decomposition
-\end{itemize}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Problem 2}
-Given
-\begin{center}
-A =
-$\begin{bmatrix}
--3 & 1 & 5 \\
-1 & 0 & -2 \\
-5 & -2 & 4 \\
-\end{bmatrix}$
-, B =
-$\begin{bmatrix}
-0 & 9 & -12 \\
--9 & 0 & 20 \\
-12 & -20 & 0 \\
-\end{bmatrix}$
-\end{center}
-Find:
-\begin{itemize}
- \item[i] Sum of A and B
- \item[ii]Elementwise Product of A and B
- \item[iii] Matrix product of A and B
-\end{itemize}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Solution}
-Sum:
-$\begin{bmatrix}
--3 & 10 & 7 \\
--8 & 0 & 18 \\
-17 & -22 & 4 \\
-\end{bmatrix}$
-,\\ Elementwise Product:
-$\begin{bmatrix}
-0 & 9 & -60 \\
--9 & 0 & -40 \\
-60 & 40 & 0 \\
-\end{bmatrix}$
-,\\ Matrix product:
-$\begin{bmatrix}
-51 & -127 & 56 \\
--24 & 49 & -12 \\
-66 & -35 & -100 \\
-\end{bmatrix}$
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Problem 3}
+\frametitle{Problem}
Solve the set of equations:
\begin{align*}
x + y + 2z -w & = 3\\
@@ -374,8 +307,38 @@
%% \end{frame}
\section{ODEs}
+
\begin{frame}[fragile]
-\frametitle{ODE Integration}
+\frametitle{Solving ODEs using SciPy}
+\begin{itemize}
+\item Let's consider the spread of an epidemic in a population
+\item $\frac{dy}{dt} = ky(L-y)$ gives the spread of the disease
+\item L is the total population.
+\item Use L = 25000, k = 0.00003, y(0) = 250
+\item Define a function as below
+\end{itemize}
+\begin{lstlisting}
+In []: def epid(y, t):
+ .... k, L = 0.00003, 25000
+ .... return k*y*(L-y)
+ ....
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Solving ODEs using SciPy \ldots}
+\begin{lstlisting}
+In []: t = arange(0, 12, 0.2)
+
+In []: y = odeint(epid, 250, t)
+
+In []: plot(t, y)
+\end{lstlisting}
+%Insert Plot
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{ODEs - Simple Pendulum}
We shall use the simple ODE of a simple pendulum.
\begin{equation*}
\ddot{\theta} = -\frac{g}{L}sin(\theta)
@@ -392,10 +355,9 @@
\end{frame}
\begin{frame}[fragile]
-\frametitle{Solving ODEs using SciPy}
+\frametitle{ODEs - Simple Pendulum \ldots}
\begin{itemize}
-\item We use the \typ{odeint} function from scipy to do the integration
-\item Define a function as below
+\item Use \typ{odeint} to do the integration
\end{itemize}
\begin{lstlisting}
In []: def pend_int(initial, t):
@@ -408,7 +370,7 @@
\end{frame}
\begin{frame}[fragile]
-\frametitle{Solving ODEs using SciPy \ldots}
+\frametitle{ODEs - Simple Pendulum \ldots}
\begin{itemize}
\item \typ{t} is the time variable \\
\item \typ{initial} has the initial values
@@ -420,7 +382,7 @@
\end{frame}
\begin{frame}[fragile]
-\frametitle{Solving ODEs using SciPy \ldots}
+\frametitle{ODEs - Simple Pendulum \ldots}
%%\begin{small}
\typ{In []: from scipy.integrate import odeint}
%%\end{small}