diff options
author | Santosh G. Vattam | 2010-04-27 15:20:28 +0530 |
---|---|---|
committer | Santosh G. Vattam | 2010-04-27 15:20:28 +0530 |
commit | aeb424782a888813d5c56ea885665f8a85a21d89 (patch) | |
tree | 82cf7e9671897cb7b3c7e03bca24314b6e0aa5d8 /day1/session6.tex | |
parent | 8c5dc893d695e91e5068e3719be9ead30e75d2e0 (diff) | |
download | workshops-aeb424782a888813d5c56ea885665f8a85a21d89.tar.gz workshops-aeb424782a888813d5c56ea885665f8a85a21d89.tar.bz2 workshops-aeb424782a888813d5c56ea885665f8a85a21d89.zip |
Minor corrections post SVCE.
Diffstat (limited to 'day1/session6.tex')
-rwxr-xr-x | day1/session6.tex | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/day1/session6.tex b/day1/session6.tex index 455b86d..184a51c 100755 --- a/day1/session6.tex +++ b/day1/session6.tex @@ -273,8 +273,8 @@ In []: fsolve(sin(z)+cos(z)*cos(z), 0) \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 @@ In []: def f(z): \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 @@ More on Functions later \ldots \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 @@ Out[]: -0.66623943249251527 \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 @@ fsolve(f, 0) \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 @@ In []: def pend_int(initial, t): .... 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} |