summaryrefslogtreecommitdiff
path: root/day1/session6.tex
diff options
context:
space:
mode:
Diffstat (limited to 'day1/session6.tex')
-rwxr-xr-xday1/session6.tex30
1 files changed, 15 insertions, 15 deletions
diff --git a/day1/session6.tex b/day1/session6.tex
index 61b536c..0e34996 100755
--- a/day1/session6.tex
+++ b/day1/session6.tex
@@ -78,7 +78,7 @@
\author[FOSSEE] {FOSSEE}
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date[] {08 March, 2010\\Day 1, Session 6}
+\date[] {02 April, 2010\\Day 1, Session 6}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
@@ -239,7 +239,7 @@ Use \kwrd{solve()}
\begin{frame}[fragile]
\frametitle{\typ{fsolve}}
-Find the root of $sin(x)+cos^2(x)$ nearest to $0$
+Find the root of $sin(z)+cos^2(z)$ nearest to $0$
\vspace{-0.1in}
\begin{center}
\includegraphics[height=2.8in, interpolate=true]{data/fsolve}
@@ -248,18 +248,18 @@ Find the root of $sin(x)+cos^2(x)$ nearest to $0$
\begin{frame}[fragile]
\frametitle{\typ{fsolve}}
-Root of $sin(x)+cos^2(x)$ nearest to $0$
+Root of $sin(z)+cos^2(z)$ nearest to $0$
\begin{lstlisting}
-In []: fsolve(sin(x)+cos(x)*cos(x), 0)
-NameError: name 'x' is not defined
+In []: fsolve(sin(z)+cos(z)*cos(z), 0)
+NameError: name 'z' is not defined
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{\typ{fsolve}}
\begin{lstlisting}
-In []: x = linspace(-pi, pi)
-In []: fsolve(sin(x)+cos(x)*cos(x), 0)
+In []: z = linspace(-pi, pi)
+In []: fsolve(sin(z)+cos(z)*cos(z), 0)
\end{lstlisting}
\begin{small}
\alert{\typ{TypeError:}}
@@ -271,8 +271,8 @@ In []: fsolve(sin(x)+cos(x)*cos(x), 0)
\frametitle{Functions - Definition}
We have been using them all along. Now let's see how to define them.
\begin{lstlisting}
-In []: def f(x):
- return sin(x)+cos(x)*cos(x)
+In []: def f(z):
+ return sin(z)+cos(z)*cos(z)
\end{lstlisting}
\begin{itemize}
\item \typ{def}
@@ -285,7 +285,7 @@ In []: def f(x):
\begin{frame}[fragile]
\frametitle{Functions - Calling them}
\begin{lstlisting}
-In [15]: f()
+In []: f()
---------------------------------------
\end{lstlisting}
\alert{\typ{TypeError:}}\typ{f() takes exactly 1 argument}
@@ -301,7 +301,7 @@ More on Functions later \ldots
\begin{frame}[fragile]
\frametitle{\typ{fsolve} \ldots}
-Find the root of $sin(x)+cos^2(x)$ nearest to $0$
+Find the root of $sin(z)+cos^2(z)$ nearest to $0$
\begin{lstlisting}
In []: fsolve(f, 0)
Out[]: -0.66623943249251527
@@ -313,16 +313,16 @@ Out[]: -0.66623943249251527
\begin{frame}[fragile]
\frametitle{Exercise Problem}
- Find the root of the equation $x^2 - sin(x) + cos^2(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):
- return x**2 - sin(x) + cos(x)*cos(x)
- fsolve(f, 0)
+def f(x):
+ return x**2 - sin(x) + cos(x)*cos(x) - tan(x)
+fsolve(f, 0)
\end{lstlisting}
\end{small}
\begin{center}