diff options
Diffstat (limited to 'day1')
-rw-r--r-- | day1/session5.tex | 48 | ||||
-rw-r--r-- | day1/session6.tex | 21 |
2 files changed, 20 insertions, 49 deletions
diff --git a/day1/session5.tex b/day1/session5.tex index 864cbab..36f89c0 100644 --- a/day1/session5.tex +++ b/day1/session5.tex @@ -141,7 +141,6 @@ In []: for line in open('pendulum.txt'): T.append(float(t)) In []: L = array(L) In []: T = array(T) -In []: Tsq = T*T \end{lstlisting} \end{frame} @@ -300,6 +299,7 @@ In []: quad(f, 0, 1) \end{lstlisting} \begin{itemize} \item \typ{def} +\item name \item arguments \item \typ{return} \end{itemize} @@ -319,50 +319,7 @@ 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 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] @@ -392,5 +349,6 @@ Returns the integral and an estimate of the absolute error in the result. \item Quadrature \end{itemize} \end{frame} + \end{document} diff --git a/day1/session6.tex b/day1/session6.tex index c929516..9ee3215 100644 --- a/day1/session6.tex +++ b/day1/session6.tex @@ -198,8 +198,8 @@ In []: pend_sol = odeint(pend_int, \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 @@ -350,15 +350,28 @@ In []: pend_sol = odeint(pend_int, \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} |