summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--day1/session3.tex30
-rw-r--r--day1/session4.tex55
2 files changed, 73 insertions, 12 deletions
diff --git a/day1/session3.tex b/day1/session3.tex
index 780af01..1af46cd 100644
--- a/day1/session3.tex
+++ b/day1/session3.tex
@@ -308,28 +308,20 @@ for k in data:
\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 @@ In []: plot(L, Tsq, 'o')
\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}
diff --git a/day1/session4.tex b/day1/session4.tex
index 67988de..fb8e2e4 100644
--- a/day1/session4.tex
+++ b/day1/session4.tex
@@ -249,9 +249,55 @@ In []: integrate.quad(f, 0, 1)
\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 @@ In []: integrate.quad(f, 0, 1)
\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}