Merged Madhu and Mainline branches.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Wed, 28 Oct 2009 16:01:29 +0530
changeset 230 77a19a6ffbf8
parent 229 5541c47bc2e8 (current diff)
parent 225 a83f7be6f16c (diff)
child 231 df38a186ed8f
Merged Madhu and Mainline branches.
Binary file day1/data/filter.png has changed
--- a/day1/session1.tex	Wed Oct 28 16:01:13 2009 +0530
+++ b/day1/session1.tex	Wed Oct 28 16:01:29 2009 +0530
@@ -129,15 +129,11 @@
 	\item[Session 2] Sat 10:05--11:05
 	\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[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[Quiz -2]   Sat 17:00--17:15
   \end{description}
-
-  \begin{block}{Goal of the workshop}
-	At the end of this program, successful participants will be able to use python as their scripting and problem solving language. Aimed at Engg. students--focus on basic numerics and plotting-- but should serve a similar purpose for others. 
-  \end{block}
 \end{frame}
 
 \begin{frame}
@@ -147,13 +143,15 @@
 	\item[Session 2] Sun 10:05--11:05
 	\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[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[Quiz -2]   Sun 17:00--17:15
   \end{description}
+\end{frame}
 
-\begin{frame}{About the Workshop}
+\begin{frame}
+  \frametitle{About the Workshop}
   \begin{block}{Intended Audience}
   \begin{itemize}
        \item Engg., Mathematics and Science teachers.
@@ -161,7 +159,7 @@
   \end{itemize}
   \end{block}  
 
-  \begin{block}{Goal:}
+  \begin{block}{Goal}
 	Successful participants will be able to 
         \begin{itemize}
           \item use Python as their scripting and problem solving language. 
@@ -170,15 +168,18 @@
   \end{block}
 \end{frame}
 
-\end{frame}
-\begin{frame}{Checklist}  
+
+\begin{frame}
+\frametitle{Bucketlist}  
   \begin{block}{IPython}
     Type ipython at the command line. Is it available?
   \end{block}
   \begin{block}{Editor}
     We recommend scite.
   \end{block}
-  \end{description}
+  \begin{block}{Data files}
+    Make sure you have all data files.
+  \end{block}
 \end{frame}
 
 \begin{frame}[fragile]
@@ -222,12 +223,12 @@
   \includegraphics[height=2in, interpolate=true]{data/firstplot}
     \column{0.8\textwidth}
     \begin{block}{}
-    \small
+    \begin{small}
 \begin{lstlisting}
 In []: x = linspace(0, 2*pi, 51)
 In []: plot(x, sin(x))
 \end{lstlisting}
-    \small
+    \end{small}
     \end{block}
 \end{columns}
 \end{frame}
--- a/day1/session5.tex	Wed Oct 28 16:01:13 2009 +0530
+++ b/day1/session5.tex	Wed Oct 28 16:01:29 2009 +0530
@@ -79,7 +79,7 @@
 \author[FOSSEE] {FOSSEE}
 
 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date[] {31, October 2009\\Day 1, Session 4}
+\date[] {31, October 2009\\Day 1, Session 5}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
@@ -96,13 +96,13 @@
   \end{frame}
 }
 
-%%\AtBeginSection[]
-%%{
-  %%\begin{frame}<beamer>
-%%    \frametitle{Outline}
-  %%  \tableofcontents[currentsection,currentsubsection]
-  %%\end{frame}
-%%}
+\AtBeginSection[]
+{
+  \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: 
@@ -124,9 +124,203 @@
 %  \pausesections
 \end{frame}
 
-\section{Integration}
+\section{Interpolation}
+
+\begin{frame}[fragile]
+\frametitle{Interpolation}
+\begin{itemize}
+\item Let us begin with interpolation
+\item Let's use the L and T arrays and interpolate this data to obtain data at new points
+\end{itemize}
+\begin{lstlisting}
+In []: L = []
+In []: T = []
+In []: for line in open('pendulum.txt'):
+           l, t = line.split()
+           L.append(float(l))
+           T.append(float(t))
+In []: L = array(L)
+In []: T = array(T)
+\end{lstlisting}
+\end{frame}
+
+%% \begin{frame}[fragile]
+%% \frametitle{Interpolation \ldots}
+%% \begin{small}
+%%   \typ{In []: from scipy.interpolate import interp1d}
+%% \end{small}
+%% \begin{itemize}
+%% \item The \typ{interp1d} function returns a function
+%% \begin{lstlisting}
+%%   In []: f = interp1d(L, T)
+%% \end{lstlisting}
+%% \item Functions can be assigned to variables 
+%% \item This function interpolates between known data values to obtain unknown
+%% \end{itemize}
+%% \end{frame}
+
+%% \begin{frame}[fragile]
+%% \frametitle{Interpolation \ldots}
+%% \begin{lstlisting}
+%% In []: Ln = arange(0.1,0.99,0.005)
+%% # Interpolating! 
+%% # The new values in range of old data
+%% In []: plot(L, T, 'o', Ln, f(Ln), '-')
+%% In []: f = interp1d(L, T, kind='cubic')
+%% # When kind not specified, it's linear
+%% # Others are ...
+%% # 'nearest', 'zero', 
+%% # 'slinear', 'quadratic'
+%% \end{lstlisting}
+%% \end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Spline Interpolation}
+\begin{small}
+\begin{lstlisting}
+In []: from scipy.interpolate import splrep
+In []: from scipy.interpolate import splev
+\end{lstlisting}
+\end{small}
+\begin{itemize}
+\item Involves two steps
+  \begin{enumerate}
+  \item Find out the spline curve, coefficients
+  \item Evaluate the spline at new points
+  \end{enumerate}
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{\typ{splrep}}
+To find the B-spline representation
+\begin{lstlisting}
+In []: tck = splrep(L, T)
+\end{lstlisting}
+Returns a tuple containing 
+\begin{enumerate}
+\item the vector of knots, 
+\item the B-spline coefficients 
+\item the degree of the spline (default=3)
+\end{enumerate}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{\typ{splev}}
+To Evaluate a B-spline and it's derivatives
+\begin{lstlisting}
+In []: Lnew = arange(0.1,1,0.005)
+In []: Tnew = splev(Lnew, tck)
+
+#To obtain derivatives of the spline
+#use der=1, 2,.. for 1st, 2nd,.. order
+In []: Tnew = splev(Lnew, tck, der=1)
+\end{lstlisting}
+\end{frame}
 
-\subsection{Quadrature}
+%% \begin{frame}[fragile]
+%% \frametitle{Interpolation \ldots}
+%% \begin{itemize}
+%% \item 
+%% \end{itemize}
+%% \end{frame}
+
+\section{Differentiation}
+
+\begin{frame}[fragile]
+\frametitle{Numerical Differentiation}
+\begin{itemize}
+\item Given function $f(x)$ or data points $y=f(x)$
+\item We wish to calculate $f^{'}(x)$ at points $x$
+\item Taylor series - finite difference approximations
+\end{itemize}
+\begin{center}
+\begin{tabular}{l l}
+$f(x+h)=f(x)+h.f^{'}(x)$ &Forward \\
+$f(x-h)=f(x)-h.f^{'}(x)$ &Backward
+\end{tabular}
+\end{center}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Forward Difference}
+\begin{lstlisting}
+In []: x = linspace(0, 2*pi, 100)
+In []: y = sin(x)
+In []: deltax = x[1] - x[0]
+\end{lstlisting}
+Obtain the finite forward difference of y
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Forward Difference \ldots}
+\begin{lstlisting}
+In []: fD = (y[1:] - y[:-1]) / deltax
+In []: plot(x, y, x[:-1], fD)
+\end{lstlisting}
+\begin{center}
+  \includegraphics[height=2in, interpolate=true]{data/fwdDiff}
+\end{center}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Example}
+\begin{itemize}
+\item Given x, y positions of a particle in \typ{pos.txt}
+\item Find velocity \& acceleration in x, y directions
+\end{itemize}
+\small{
+\begin{center}
+\begin{tabular}{| c | c | c |}
+\hline
+$X$ & $Y$ \\ \hline
+0.     &  0.\\ \hline
+0.25   &  0.47775\\ \hline
+0.5    &  0.931\\ \hline
+0.75   &  1.35975\\ \hline
+1.     &  1.764\\ \hline
+1.25   &  2.14375\\ \hline
+\vdots & \vdots\\ \hline
+\end{tabular}
+\end{center}}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Example \ldots}
+\begin{itemize}
+\item Read the file
+\item Obtain an array of x, y
+\item Obtain velocity and acceleration
+\item use \typ{deltaT = 0.05}
+\end{itemize}
+\begin{lstlisting}
+In []: X = []
+In []: Y = []
+In []: for line in open('location.txt'):
+  ....     points = line.split()
+  ....     X.append(float(points[0]))
+  ....     Y.append(float(points[1]))
+In []: S = array([X, Y])
+\end{lstlisting}
+\end{frame}
+
+
+\begin{frame}[fragile]
+\frametitle{Example \ldots}
+\begin{itemize}
+\item use \typ{deltaT = 0.05}
+\end{itemize}
+\begin{lstlisting}
+In []: deltaT = 0.05
+
+In []: v = (S[:,1:]-S[:,:-1])/deltaT
+
+In []: a = (v[:,1:]-v[:,:-1])/deltaT
+\end{lstlisting}
+Try Plotting the position, velocity \& acceleration.
+\end{frame}
+
+\section{Quadrature}
 
 \begin{frame}[fragile]
 \frametitle{Quadrature}
@@ -135,7 +329,9 @@
 \item Area under $(sin(x) + x^2)$ in $(0,1)$
 \item scipy has functions to do that
 \end{itemize}
-\small{\typ{In []: from scipy.integrate import quad}}
+\begin{small}
+  \typ{In []: from scipy.integrate import quad}
+\end{small}
 \begin{itemize}
 \item Inputs - function to integrate, limits
 \end{itemize}
@@ -143,12 +339,15 @@
 In []: x = 0
 In []: quad(sin(x)+x**2, 0, 1)
 \end{lstlisting}
+\begin{small}
 \alert{\typ{error:}}
 \typ{First argument must be a callable function.}
+\end{small}
 \end{frame}
 
 \begin{frame}[fragile]
 \frametitle{Functions - Definition}
+We have been using them all along. Now let's see how to define them.
 \begin{lstlisting}
 In []: def f(x):
            return sin(x)+x**2
@@ -156,6 +355,7 @@
 \end{lstlisting}
 \begin{itemize}
 \item \typ{def}
+\item name
 \item arguments
 \item \typ{return}
 \end{itemize}
@@ -175,50 +375,7 @@
 In []: f(1)
 Out[]: 1.8414709848078965
 \end{lstlisting}
-\end{frame}
-
-
-\begin{frame}[fragile]
-\frametitle{Functions - Default Arguments}
-\begin{lstlisting}
-In []: def f(x=1):
-           return sin(x)+x**2
-In []: f(10)
-Out[]: 99.455978889110625
-In []: f(1)
-Out[]: 1.8414709848078965
-In []: f()
-Out[]: 1.8414709848078965
-\end{lstlisting}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Functions - Keyword Arguments}
-\begin{lstlisting}
-In []: def f(x=1, y=pi):
-           return sin(y)+x**2
-In []: f()
-Out[]: 1.0000000000000002
-In []: f(2)
-Out[]: 4.0
-In []: f(y=2)
-Out[]: 1.9092974268256817
-In []: f(y=pi/2,x=0)
-Out[]: 1.0
-\end{lstlisting}
-\end{frame}
-
-\begin{frame}[fragile]
-  \frametitle{More on functions}
-  \begin{itemize}
-  \item Scope of variables in the function is local
-  \item Mutable items are \alert{passed by reference}
-  \item First line after definition may be a documentation string
-    (\alert{recommended!})
-  \item Function definition and execution defines a name bound to the
-    function
-  \item You \emph{can} assign a variable to a function!
-  \end{itemize}
+More on Functions later \ldots
 \end{frame}
 
 \begin{frame}[fragile]
@@ -228,74 +385,16 @@
 \end{lstlisting}
 Returns the integral and an estimate of the absolute error in the result.
 \begin{itemize}
-\item Use \typ{dblquad} for Double integrals
+\item Look at \typ{dblquad} for Double integrals
 \item Use \typ{tplquad} for Triple integrals
 \end{itemize}
 \end{frame}
 
-\subsection{ODEs}
-
-\begin{frame}[fragile]
-\frametitle{ODE Integration}
-We shall use the simple ODE of a simple pendulum. 
-\begin{equation*}
-\ddot{\theta} = -\frac{g}{L}sin(\theta)
-\end{equation*}
-\begin{itemize}
-\item This equation can be written as a system of two first order ODEs
-\end{itemize}
-\begin{align}
-\dot{\theta} &= \omega \\
-\dot{\omega} &= -\frac{g}{L}sin(\theta) \\
- \text{At}\ t &= 0 : \nonumber \\
- \theta = \theta_0\quad & \&\quad  \omega = 0 \nonumber
-\end{align}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Solving ODEs using SciPy}
-\begin{itemize}
-\item We use the \typ{odeint} function from scipy to do the integration
-\item Define a function as below
-\end{itemize}
-\begin{lstlisting}
-In []: def pend_int(unknown, t, p):
-  ....     theta, omega = unknown
-  ....     g, L = p
-  ....     f=[omega, -(g/L)*sin(theta)]
-  ....     return f
-  ....
-\end{lstlisting}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Solving ODEs using SciPy \ldots}
-\begin{itemize}
-\item \typ{t} is the time variable \\ 
-\item \typ{p} has the constants \\
-\item \typ{initial} has the initial values
-\end{itemize}
-\begin{lstlisting}
-In []: t = linspace(0, 10, 101)
-In []: p=(-9.81, 0.2)
-In []: initial = [10*2*pi/360, 0]
-\end{lstlisting}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Solving ODEs using SciPy \ldots}
-
-\small{\typ{In []: from scipy.integrate import odeint}}
-\begin{lstlisting}
-In []: pend_sol = odeint(pend_int, 
-                         initial,t, 
-                         args=(p,))
-\end{lstlisting}
-\end{frame}
-
 \begin{frame}
   \frametitle{Things we have learned}
   \begin{itemize}
+  \item Interpolation
+  \item Differentiation
   \item Functions
     \begin{itemize}
     \item Definition
--- a/day1/session6.tex	Wed Oct 28 16:01:13 2009 +0530
+++ b/day1/session6.tex	Wed Oct 28 16:01:29 2009 +0530
@@ -73,7 +73,7 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Title page
-\title[]{Finding Roots}
+\title[]{ODEs \& Finding Roots}
 
 \author[FOSSEE] {FOSSEE}
 
@@ -123,6 +123,68 @@
 %%   % You might wish to add the option [pausesections]
 %% \end{frame}
 
+\section{ODEs}
+
+\begin{frame}[fragile]
+\frametitle{ODE Integration}
+We shall use the simple ODE of a simple pendulum. 
+\begin{equation*}
+\ddot{\theta} = -\frac{g}{L}sin(\theta)
+\end{equation*}
+\begin{itemize}
+\item This equation can be written as a system of two first order ODEs
+\end{itemize}
+\begin{align}
+\dot{\theta} &= \omega \\
+\dot{\omega} &= -\frac{g}{L}sin(\theta) \\
+ \text{At}\ t &= 0 : \nonumber \\
+ \theta = \theta_0\quad & \&\quad  \omega = 0 \nonumber
+\end{align}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Solving ODEs using SciPy}
+\begin{itemize}
+\item We use the \typ{odeint} function from scipy to do the integration
+\item Define a function as below
+\end{itemize}
+\begin{lstlisting}
+In []: def pend_int(unknown, t, p):
+  ....     theta, omega = unknown
+  ....     g, L = p
+  ....     f=[omega, -(g/L)*sin(theta)]
+  ....     return f
+  ....
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Solving ODEs using SciPy \ldots}
+\begin{itemize}
+\item \typ{t} is the time variable \\ 
+\item \typ{p} has the constants \\
+\item \typ{initial} has the initial values
+\end{itemize}
+\begin{lstlisting}
+In []: t = linspace(0, 10, 101)
+In []: p=(-9.81, 0.2)
+In []: initial = [10*2*pi/360, 0]
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Solving ODEs using SciPy \ldots}
+\begin{small}
+  \typ{In []: from scipy.integrate import odeint}
+\end{small}
+\begin{lstlisting}
+In []: pend_sol = odeint(pend_int, 
+                         initial,t, 
+                         args=(p,))
+\end{lstlisting}
+\end{frame}
+
+\section{Finding Roots}
 
 \begin{frame}[fragile]
 \frametitle{Roots of $f(x)=0$}
@@ -136,8 +198,8 @@
 \begin{frame}[fragile]
 \frametitle{Initial Estimates}
 \begin{itemize}
-\item Find the roots of $cosx-x^2$ between $-\pi/2$ and $\pi/2$
-\item We shall use a crude method to get an initial estimate first
+\item Find roots of $cosx-x^2$ in $(-\pi/2, \pi/2)$
+\item How to get a rough initial estimate?
 \end{itemize}
 \begin{enumerate}
 \item Check for change of signs of $f(x)$ in the given interval
@@ -288,15 +350,28 @@
 
 \begin{frame}[fragile]
 \frametitle{Scipy Methods \dots}
-\small{
+\begin{small}
 \begin{lstlisting}
 In []: from scipy.optimize import fixed_point
 
 In []: from scipy.optimize import bisect
 
 In []: from scipy.optimize import newton
-\end{lstlisting}}
+\end{lstlisting}
+\end{small}
 \end{frame}
 
+\begin{frame}
+  \frametitle{Things we have learned}
+  \begin{itemize}
+  \item Solving ODEs
+  \item Finding Roots
+    \begin{itemize}
+    \item Estimating Interval
+    \item Newton Raphson
+    \item Scipy methods
+    \end{itemize}
+  \end{itemize}
+\end{frame}
 
 \end{document}
Binary file day2/DebugginDiagram.png has changed
--- a/day2/session3.tex	Wed Oct 28 16:01:13 2009 +0530
+++ b/day2/session3.tex	Wed Oct 28 16:01:29 2009 +0530
@@ -97,7 +97,7 @@
 % Title page
 \title[]{3D data Visualization}
 
-\author[FOSSEE Team] {FOSSEE}
+\author[FOSSEE] {FOSSEE}
 
 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
 \date[] {1, November 2009\\Day 2, Session 3}
@@ -157,22 +157,22 @@
 \end{frame}
 
 
-\begin{frame}
-    \frametitle{Is this new?}    
-    \begin{center}
-    We have moved from:
-    \end{center}
-    \begin{columns}
-    \column{}
-    \hspace*{-1in}    
-    \includegraphics[width=1.75in,height=1.75in, interpolate=true]{data/3832}      
-    \column{}\hspace*{-0.25in}
-    To
-    \column{}
-    \hspace*{-1in}
-    \includegraphics[width=1.75in, height=1.75in, interpolate=true]{data/torus}  
-    \end{columns}
-\end{frame}
+%% \begin{frame}
+%%     \frametitle{Is this new?}    
+%%     \begin{center}
+%%     We have moved from:
+%%     \end{center}
+%%     \begin{columns}
+%%     \column{}
+%%     \hspace*{-1in}    
+%%     \includegraphics[width=1.75in,height=1.75in, interpolate=true]{data/3832}      
+%%     \column{}\hspace*{-0.25in}
+%%     To
+%%     \column{}
+%%     \hspace*{-1in}
+%%     \includegraphics[width=1.75in, height=1.75in, interpolate=true]{data/torus}  
+%%     \end{columns}
+%% \end{frame}
 
 \begin{frame}
     \frametitle{3D visualization}
@@ -238,7 +238,7 @@
     \frametitle{Using mlab}
 
     \begin{lstlisting}
->>> from enthought.mayavi import mlab
+In []:from enthought.mayavi import mlab
     \end{lstlisting}
 
     \vspace*{0.5in}
@@ -248,9 +248,9 @@
     \vspace*{0.25in}
 
     \begin{lstlisting}
->>> mlab.test_<TAB>
->>> mlab.test_contour3d()
->>> mlab.test_contour3d??
+In []: mlab.test_<TAB>
+In []: mlab.test_contour3d()
+In []: mlab.test_contour3d??
     \end{lstlisting}
 \end{frame}
 
@@ -279,12 +279,12 @@
     \end{columns}
 
     \begin{lstlisting}
->>> from numpy import *
->>> t = linspace(0, 2*pi, 50)
->>> u = cos(t)*pi
->>> x, y, z = sin(u), cos(u), sin(t)
+In []: from numpy import *
+In []: t = linspace(0, 2*pi, 50)
+In []: u = cos(t) * pi
+in []: x, y, z = sin(u), cos(u), sin(t)
     \end{lstlisting}
-    \emphbar{\PythonCode{>>> mlab.points3d(x, y, z)}}
+    \emphbar{\PythonCode{In []: mlab.points3d(x, y, z)}}
 \end{frame}
 
 \begin{frame}
@@ -294,7 +294,7 @@
         \column{0.5\textwidth}
         \pgfimage[width=2.5in]{MEDIA/m2/mlab/plot3d_ex}
   \end{columns}
-  \emphbar{\PythonCode{>>> mlab.plot3d(x, y, z, t)}}
+  \emphbar{\PythonCode{In []: mlab.plot3d(x, y, z, t)}}
 
     Plots lines between the points
     
@@ -308,11 +308,11 @@
         \pgfimage[width=2in]{MEDIA/m2/mlab/surf_ex}
     \end{columns}            
     \begin{lstlisting}
->>> x, y = mgrid[-3:3:100j,-3:3:100j]
->>> z = sin(x*x + y*y)
+In []: x, y = mgrid[-3:3:100j,-3:3:100j]
+In []: z = sin(x*x + y*y)
     \end{lstlisting}
 
-    \emphbar{\PythonCode{>>> mlab.surf(x, y, z)}}
+    \emphbar{\PythonCode{In []: mlab.surf(x, y, z)}}
 
     \alert{Assumes the points are rectilinear}
 
@@ -322,18 +322,18 @@
     \myemph{\Large 2D data: \texttt{mlab.mesh}}
     \vspace*{0.25in}
 
-    \emphbar{\PythonCode{>>> mlab.mesh(x, y, z)}}
+    \emphbar{\PythonCode{In []: mlab.mesh(x, y, z)}}
 
     \alert{Points needn't be regular}
 
     \vspace*{0.25in}
 \begin{lstlisting}
->>> phi, theta = numpy.mgrid[0:pi:20j, 
+In []: phi, theta = numpy.mgrid[0:pi:20j, 
 ...                         0:2*pi:20j]
->>> x = sin(phi)*cos(theta)
->>> y = sin(phi)*sin(theta)
->>> z = cos(phi)
->>> mlab.mesh(x, y, z, 
+In []: x = sin(phi)*cos(theta)
+In []: y = sin(phi)*sin(theta)
+In []: z = cos(phi)
+In []: mlab.mesh(x, y, z, 
 ...           representation=
 ...           'wireframe')
 \end{lstlisting}
@@ -349,10 +349,10 @@
         \pgfimage[width=1.5in]{MEDIA/m2/mlab/contour3d}\\        
     \end{columns}
 \begin{lstlisting}
->>> x, y, z = ogrid[-5:5:64j, 
+In []: x, y, z = ogrid[-5:5:64j, 
 ...                -5:5:64j, 
 ...                -5:5:64j]
->>> mlab.contour3d(x*x*0.5 + y*y + 
+In []: mlab.contour3d(x*x*0.5 + y*y + 
                    z*z*2)
 \end{lstlisting}
 \end{frame}
@@ -365,7 +365,7 @@
     \pgfimage[width=2in]{MEDIA/m2/mlab/quiver3d_ex}\\
     
 \begin{lstlisting}
->>> mlab.test_quiver3d()
+In []: mlab.test_quiver3d()
 \end{lstlisting}
 
 \emphbar{\PythonCode{obj = mlab.quiver3d(x, y, z, u, v, w)}}
@@ -511,6 +511,15 @@
 
   \end{lstlisting}
 \end{frame}
-  
+
+\begin{frame}
+  \frametitle{We have covered:}
+  \begin{itemize}
+  \item Need of visualization.
+  \item Using mlab to create 3 D plots.
+  \item Mayavi Toolkit.
+  \end{itemize}
+\end{frame}
+
 \end{document}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day2/session4.tex	Wed Oct 28 16:01:29 2009 +0530
@@ -0,0 +1,386 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Tutorial slides on Python.
+%
+% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in>
+% Copyright (c) 2005-2009, Prabhu Ramachandran
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\documentclass[compress,14pt]{beamer}
+% \documentclass[handout]{beamer}
+% \usepackage{pgfpages}
+% \pgfpagesuselayout{4 on 1}[a4paper,border, shrink=5mm,landscape]
+\usepackage{tikz}
+\newcommand{\hyperlinkmovie}{}
+%\usepackage{movie15}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Note that in presentation mode 
+% \paperwidth  364.19536pt
+% \paperheight 273.14662pt
+% h/w = 0.888
+
+
+\mode<presentation>
+{
+  \usetheme{Warsaw}
+  %\usetheme{Boadilla}
+  %\usetheme{default}
+  \useoutertheme{split}
+  \setbeamercovered{transparent}
+}
+
+% To remove navigation symbols
+\setbeamertemplate{navigation symbols}{}
+
+\usepackage{amsmath}
+\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}
+\usepackage{pgf}
+
+\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}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% My Macros
+\setbeamercolor{postit}{bg=yellow,fg=black}
+\setbeamercolor{emphbar}{bg=blue!20, fg=black}
+\newcommand{\emphbar}[1]
+{\begin{beamercolorbox}[rounded=true]{emphbar} 
+      {#1}
+ \end{beamercolorbox}
+}
+%{\centerline{\fcolorbox{gray!50} {blue!10}{
+%\begin{minipage}{0.9\linewidth}
+%    {#1} 
+%\end{minipage}
+%    }}}
+
+\newcommand{\myemph}[1]{\structure{\emph{#1}}}
+\newcommand{\PythonCode}[1]{\lstinline{#1}}
+
+\newcommand{\tvtk}{\texttt{tvtk}}
+\newcommand{\mlab}{\texttt{mlab}}
+
+\newcounter{time}
+\setcounter{time}{0}
+\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\vspace*{0.1in}\tiny \thetime\ m}}
+
+\newcommand\BackgroundPicture[1]{%
+  \setbeamertemplate{background}{%
+      \parbox[c][\paperheight]{\paperwidth}{%
+      \vfill \hfill
+ \hfill \vfill
+}}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Configuring the theme
+%\setbeamercolor{normal text}{fg=white}
+%\setbeamercolor{background canvas}{bg=black}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Title page
+\title[]{Debugging and \\Test Driven Approach}
+
+\author[FOSSEE] {FOSSEE}
+
+\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\date[] {11, October 2009}
+\date[] % (optional)
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%\pgfdeclareimage[height=0.75cm]{iitblogo}{iitblogo}
+%\logo{\pgfuseimage{iitblogo}}
+
+\AtBeginSection[]
+{
+  \begin{frame}<beamer>
+    \frametitle{Outline}
+      \Large
+    \tableofcontents[currentsection,currentsubsection]
+  \end{frame}
+}
+
+%% 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}
+}
+
+\AtBeginSection[]
+{
+  \begin{frame}<beamer>
+    \frametitle{Outline}
+    \tableofcontents[currentsection,currentsubsection]
+  \end{frame}
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% DOCUMENT STARTS
+\begin{document}
+
+\begin{frame}
+  \maketitle
+\end{frame}
+
+
+\section{Debugging}
+\subsection{Errors and Exceptions}
+\begin{frame}[fragile]
+ \frametitle{Errors}
+ \begin{lstlisting}
+>>> while True print 'Hello world'
+ \end{lstlisting}
+\pause
+  \begin{lstlisting}
+  File "<stdin>", line 1, in ?
+    while True print 'Hello world'
+                   ^
+SyntaxError: invalid syntax
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Exceptions}
+ \begin{lstlisting}
+>>> print spam
+\end{lstlisting}
+\pause
+\begin{lstlisting}
+Traceback (most recent call last):
+  File "<stdin>", line 1, in <module>
+NameError: name 'spam' is not defined
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Exceptions}
+ \begin{lstlisting}
+>>> 1 / 0
+\end{lstlisting}
+\pause
+\begin{lstlisting}
+Traceback (most recent call last):
+  File "<stdin>", line 1, in <module>
+ZeroDivisionError: integer division 
+or modulo by zero
+\end{lstlisting}
+\end{frame}
+
+\subsection{Strategy}
+\begin{frame}[fragile]
+    \frametitle{Debugging effectively}
+    \begin{itemize}
+        \item \kwrd{print} based strategy
+        \item Process:
+    \end{itemize}
+\begin{center}
+\pgfimage[interpolate=true,width=5cm,height=5cm]{DebugginDiagram.png}
+\end{center}
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Debugging effectively}
+    \begin{itemize}
+      \item Using \typ{\%debug} in IPython
+    \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Debugging in IPython}
+\small
+\begin{lstlisting}
+In [1]: import mymodule
+In [2]: mymodule.test()
+---------------------------------------------
+NameError   Traceback (most recent call last)
+<ipython console> in <module>()
+mymodule.py in test()
+      1 def test():
+----> 2     print spam
+NameError: global name 'spam' is not defined
+
+In [3]: %debug
+> mymodule.py(2)test()
+      0     print spam
+ipdb> 
+\end{lstlisting}
+\inctime{15} 
+\end{frame}
+
+\subsection{Exercise}
+\begin{frame}[fragile]
+\frametitle{Debugging: Exercise}
+\small
+\begin{lstlisting}
+import keyword
+f = open('/path/to/file')
+
+freq = {}
+for line in f:
+    words = line.split()
+    for word in words:
+        key = word.strip(',.!;?()[]: ')
+        if keyword.iskeyword(key):
+            value = freq[key]
+            freq[key] = value + 1
+
+print freq
+\end{lstlisting}
+\inctime{10}
+\end{frame}
+
+%% \begin{frame}
+%%     \frametitle{Testing}
+   
+%%     \begin{itemize}
+%%         \item Writing tests is really simple!
+
+%%         \item Using nose.
+
+%%         \item Example!
+%%     \end{itemize}
+%% \end{frame}
+
+\section{Test Driven Approach}
+\begin{frame}
+    \frametitle{Need of Testing!}
+   
+    \begin{itemize}
+        \item Quality
+        \item Regression
+        \item Documentation
+    \end{itemize}
+    %% \vspace*{0.25in}
+    %% \emphbar{It is to assure that section of code is working as it is supposed to work}
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Example}
+    \begin{block}{Problem Statement}
+      Write a function to check whether a given input
+      string is a palindrome.
+    \end{block}
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Function: palindrome.py}
+\begin{lstlisting}    
+def is_palindrome(input_str):
+  return input_str == input_str[::-1]
+\end{lstlisting}    
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Test for the palindrome: palindrome.py}
+\begin{lstlisting}    
+from plaindrome import is_palindrome
+def test_function_normal_words():
+  input = "noon"
+  assert is_palindrome(input) == True
+\end{lstlisting}    
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Running the tests.}
+\begin{lstlisting}    
+$ nosetests test.py 
+.
+----------------------------------------------
+Ran 1 test in 0.001s
+
+OK
+\end{lstlisting}    
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Exercise: Including new tests.}
+\begin{lstlisting}    
+def test_function_ignore_cases_words():
+  input = "Noon"
+  assert is_palindrome(input) == True
+\end{lstlisting}
+     \vspace*{0.25in}
+     Check\\
+     \PythonCode{$ nosetests test.py} \\
+     \begin{block}{Task}
+     Tweak the code to pass this test.
+     \end{block}
+\end{frame}
+
+%\begin{frame}[fragile]
+%    \frametitle{Lets write some test!}
+%\begin{lstlisting}    
+%#for form of equation y=mx+c
+%#given m and c for two equation,
+%#finding the intersection point.
+%def intersect(m1,c1,m2,c2):
+%    x = (c2-c1)/(m1-m2)
+%    y = m1*x+c1
+%    return (x,y)
+%\end{lstlisting}
+%
+%Create a simple test for this
+%
+%function which will make it fail.
+%
+%\inctime{15} 
+%\end{frame}
+%
+
+\begin{frame}[fragile]
+    \frametitle{Exercise}
+    Based on Euclid's algorithm:
+    \begin{center}
+    $gcd(a,b)=gcd(b,b\%a)$
+    \end{center}
+    gcd function can be written as:
+    \begin{lstlisting}
+    def gcd(a, b):
+      if a%b == 0: return b
+      return gcd(b, a%b)
+    \end{lstlisting}
+    \vspace*{-0.15in}
+    \begin{block}{Task}
+      \begin{itemize}
+      \item Write at least 
+        two tests for above mentioned function.
+      \item Write a non recursive implementation
+      of gcd(), and test it using already 
+      written tests.
+      \end{itemize}
+    \end{block}
+    
+\inctime{15} 
+\end{frame}
+
+\begin{frame}
+  \frametitle{We have learned}
+  \begin{itemize}
+  \item Following and Resolving Error Messages.
+  \item Exceptions.
+  \item Approach for Debugging.
+  \item Writting and running tests.
+  \end{itemize}
+\end{frame}
+
+\end{document}
--- a/day2/session5.tex	Wed Oct 28 16:01:13 2009 +0530
+++ b/day2/session5.tex	Wed Oct 28 16:01:29 2009 +0530
@@ -147,14 +147,14 @@
 
 \begin{frame}[fragile]
   \frametitle{Problem set 4}
-  Finite difference
+  Central difference
   \begin{equation*}
-  \frac{sin(x+h)-sin(x)}{h}
+  \frac{sin(x+h)-sin(x-h)}{2h}
   \end{equation*}
   \begin{lstlisting}
-  >>> x = linspace(0,2*pi,100)
-  >>> y = sin(x)
-  >>> deltax = x[1] - x[0]
+  In []: x = linspace(0, 2*pi, 100)
+  In []: y = sin(x)
+  In []: deltax = x[1] - x[0]
   \end{lstlisting}
   \pause
     \begin{enumerate}