Changed functions section and some minor edits.
--- a/day1/session3.tex Mon Oct 26 20:44:54 2009 +0530
+++ b/day1/session3.tex Tue Oct 27 10:59:11 2009 +0530
@@ -308,28 +308,20 @@
\end{frame}
\begin{frame}[fragile]
-\frametitle{Least Squares Fit}
-\vspace{-0.15in}
-\begin{figure}
-\includegraphics[width=4in]{data/least-sq-fit.png}
-\end{figure}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Calculating $T^2$ Efficiently}
+\frametitle{Dealing with data whole-sale}
\begin{lstlisting}
In []: for t in T:
....: Tsq.append(t*t)
\end{lstlisting}
\begin{itemize}
\item This is not very efficient
-\item We use arrays to make it efficient
+\item We are squaring element after element
+\item We use arrays to make this efficient
\end{itemize}
\begin{lstlisting}
In []: L = array(L)
In []: T = array(T)
In []: Tsq = T*T
-In []: plot(L, Tsq, 'o')
\end{lstlisting}
\end{frame}
@@ -344,6 +336,22 @@
\end{itemize}
\end{frame}
+\begin{frame}[fragile]
+\frametitle{Least Squares Fit}
+\vspace{-0.15in}
+\begin{figure}
+\includegraphics[width=4in]{data/L-Tsq-Line.png}
+\end{figure}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Least Squares Fit}
+\vspace{-0.15in}
+\begin{figure}
+\includegraphics[width=4in]{data/least-sq-fit.png}
+\end{figure}
+\end{frame}
+
\begin{frame}
\frametitle{Least Square Fit Curve}
\begin{itemize}
--- a/day1/session4.tex Mon Oct 26 20:44:54 2009 +0530
+++ b/day1/session4.tex Tue Oct 27 10:59:11 2009 +0530
@@ -249,9 +249,55 @@
\end{frame}
\begin{frame}[fragile]
+\frametitle{Functions - Calling them}
+\begin{lstlisting}
+In [15]: f()
+---------------------------------------
+\end{lstlisting}
+\alert{\typ{TypeError:}}\typ{f() takes exactly 1 argument}
+\typ{(0 given)}
+\begin{lstlisting}
+In []: f(0)
+Out[]: 0.0
+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 Support default and keyword arguments
\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
@@ -262,6 +308,13 @@
\end{itemize}
\end{frame}
+\begin{frame}[fragile]
+\frametitle{Quadrature \ldots}
+\begin{lstlisting}
+In []: integrate.quad(f, 0, 1)
+\end{lstlisting}
+Returns the integral and an estimate of the absolute error in the result.
+\end{frame}
\subsection{ODEs}