--- a/day1/session6.tex Tue Apr 27 12:14:30 2010 +0530
+++ b/day1/session6.tex Tue Apr 27 15:20:28 2010 +0530
@@ -273,8 +273,8 @@
\frametitle{Functions - Definition}
We have been using them all along. Now let's see how to define them.
\begin{lstlisting}
-In []: def f(z):
- return sin(z)+cos(z)*cos(z)
+In []: def g(z):
+ ....: return sin(z)+cos(z)*cos(z)
\end{lstlisting}
\begin{itemize}
\item \typ{def}
@@ -287,15 +287,15 @@
\begin{frame}[fragile]
\frametitle{Functions - Calling them}
\begin{lstlisting}
-In []: f()
+In []: g()
---------------------------------------
\end{lstlisting}
-\alert{\typ{TypeError:}}\typ{f() takes exactly 1 argument}
+\alert{\typ{TypeError:}}\typ{g() takes exactly 1 argument}
\typ{(0 given)}
\begin{lstlisting}
-In []: f(0)
+In []: g(0)
Out[]: 1.0
-In []: f(1)
+In []: g(1)
Out[]: 1.1333975665343254
\end{lstlisting}
More on Functions later \ldots
@@ -305,7 +305,7 @@
\frametitle{\typ{fsolve} \ldots}
Find the root of $sin(z)+cos^2(z)$ nearest to $0$
\begin{lstlisting}
-In []: fsolve(f, 0)
+In []: fsolve(g, 0)
Out[]: -0.66623943249251527
\end{lstlisting}
\begin{center}
@@ -315,16 +315,16 @@
\begin{frame}[fragile]
\frametitle{Exercise Problem}
- Find the root of the equation $x^2 - sin(x) + cos^2(x) == tan(x)$ nearest to $0$
+ Find the root of the equation $x^2 - sin(x) + cos^2(x) = tan(x)$ nearest to $0$
\end{frame}
\begin{frame}[fragile]
\frametitle{Solution}
\begin{small}
\begin{lstlisting}
-def f(x):
+def g(x):
return x**2 - sin(x) + cos(x)*cos(x) - tan(x)
-fsolve(f, 0)
+fsolve(g, 0)
\end{lstlisting}
\end{small}
\begin{center}
@@ -353,14 +353,14 @@
\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 Use L = 250000, k = 0.00003, y(0) = 250
\item Define a function as below
\end{itemize}
\begin{lstlisting}
In []: from scipy.integrate import odeint
In []: def epid(y, t):
.... k = 0.00003
- .... L = 25000
+ .... L = 250000
.... return k*y*(L-y)
....
\end{lstlisting}
@@ -414,8 +414,8 @@
.... omega = initial[1]
.... g = 9.81
.... L = 0.2
- .... f=[omega, -(g/L)*sin(theta)]
- .... return f
+ .... F=[omega, -(g/L)*sin(theta)]
+ .... return F
....
\end{lstlisting}
\end{frame}