Added another ODE example to session6.
--- a/day1/session1.tex Fri Nov 06 18:40:13 2009 +0530
+++ b/day1/session1.tex Fri Nov 06 20:15:14 2009 +0530
@@ -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 Fri Nov 06 18:40:13 2009 +0530
+++ b/day1/session2.tex Fri Nov 06 20:15:14 2009 +0530
@@ -123,28 +123,7 @@
% You might wish to add the option [pausesections]
\end{frame}
-%\begin{frame}
-%\frametitle{Python Scripts\ldots}
-% \begin{itemize}
-% \item Open a new file in an \alert{editor}
-% \item Copy and paste from the output of \typ{\%hist -n}
-% \item Save the file as \typ{sine_plot.py}
-% \end{itemize}
-% \begin{itemize}
-% \item run the file in IPython using \typ{\%run -i sine_plot.py}\\
-% \end{itemize}
-%\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.
@@ -483,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 Fri Nov 06 18:40:13 2009 +0530
+++ b/day1/session4.tex Fri Nov 06 20:15:14 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 Fri Nov 06 18:40:13 2009 +0530
+++ b/day1/session6.tex Fri Nov 06 20:15:14 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}