summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPuneeth Chaganti2009-11-20 00:06:08 +0530
committerPuneeth Chaganti2009-11-20 00:06:08 +0530
commitbf6020f80bfcd91b377fc8c441bd0688aaa61190 (patch)
tree40057acc2297cbbba725d5a2cdf78bb9c486de60
parent8b33fcbc1a886583c520152f5137b5f978da502e (diff)
parent67677e1a69087ca9ca1c4291e92bcac7e0666024 (diff)
downloadworkshops-more-scipy-bf6020f80bfcd91b377fc8c441bd0688aaa61190.tar.gz
workshops-more-scipy-bf6020f80bfcd91b377fc8c441bd0688aaa61190.tar.bz2
workshops-more-scipy-bf6020f80bfcd91b377fc8c441bd0688aaa61190.zip
Merged branches.
-rwxr-xr-xday1/cheatsheet1.tex140
-rwxr-xr-xday1/cheatsheet2.tex162
-rwxr-xr-xday1/cheatsheet4.tex111
-rwxr-xr-xday1/cheatsheet6.tex114
-rw-r--r--day1/session1.tex40
5 files changed, 403 insertions, 164 deletions
diff --git a/day1/cheatsheet1.tex b/day1/cheatsheet1.tex
index 26edf77..11fd385 100755
--- a/day1/cheatsheet1.tex
+++ b/day1/cheatsheet1.tex
@@ -6,7 +6,8 @@
\usepackage{listings}
\lstset{language=Python,
basicstyle=\ttfamily,
-commentstyle=\itshape\bfseries
+commentstyle=\itshape\bfseries,
+showstringspaces=false,
}
\newcommand{\typ}[1]{\lstinline{#1}}
\usepackage[english]{babel}
@@ -33,49 +34,118 @@ Exiting
\begin{lstlisting}
In [2]: (Ctrl-D)^D
Do you really want to exit ([y]/n)? y
-\end{lstlisting}
+\end{lstlisting} %$
\section{Plotting}
+\subsection{linspace}
+\typ{In []: x = linspace(start, stop, num)}\\
+\typ{linspace} returns array of length \typ{num}, for which \typ{x[0] = start} and \typ{x[num-1] = stop} \\
+\emph{Please note indices of array starts from zero(0)}
+
+\subsection{plot}
+\typ{In []: plot(X, Y)}\\
+For given arrays of equal length(above case X and Y), \typ{plot} plots the correspoding *x* and *y* pairs taken from X and Y.
+
+\subsection{Colors of plots}
+\typ{In []: plot(y, sin(y), 'g')}\\
+Plots graph with green color. Other options available are:
+\begin{lstlisting}
+ 'r' ---> Red
+ 'b' ---> Blue
+ 'r' ---> Red
+ 'c' ---> Cyan
+ 'm' ---> Magenta
+ 'y' ---> Yellow
+ 'k' ---> Black
+ 'w' ---> White
+\end{lstlisting}
+One can also set the line width of plot using optional argument \typ{linewidth}. For example:\\
+\typ{In []: plot(x, cos(x), 'r', linewidth=2)}\\
+Plots the line with linewidth = 2
+\subsection{label and title}
+\typ{In []: xlabel('Length') #sets *x* axis label to Length}\\
+\typ{In []: ylabel('Time') #sets *y* axis label to Time.}\\
+\typ{In []: title('Sinusoids') #sets title of plot}\\
+\\
+\textbf{Additionally}\\
+Pylab accepts TeX equation expressions in any text expression. To get something like:\\
+$\sigma_i=15$ \\
+on title of figure use:
+\begin{lstlisting}
+In []: title('$\sigma_i=15$')
+\end{lstlisting}
+Same way one can have TeX expression on xlabel, ylabel etc.
+
+\subsection{legends}
+\typ{In []: legend('sin(x)',loc=center)} \\
+Placec a legend on the current plot at location *loc*.\\
+Apart from \kwrd{center}, some other \kwrd{loc} which can be specified are:
+\begin{lstlisting}
+'best'
+'right'
+'upper right'
+'upper left'
+'lower left'
+'lower right'
+'center left'
+'center right'
+'lower center'
+'upper center'
+\end{lstlisting}
+\newpage
+One can also mention explicit co-ordinates for placement of legend.
+\begin{lstlisting}
+In []: legend(['sin(2y)'], loc=(.8,.1))
+\end{lstlisting}
+\typ{loc = 0, 1} (top left position of graph)\\
+\typ{loc = 0.5, 0.5} (center of graph).
- \begin{lstlisting}
-In [1]: x = linspace(0, 2*pi, 50)
-In [2]: plot(x, sin(x))
-In [3]: xlabel('x')
-In [4]: ylabel('sin(x)')
-In [5]: title('Sinusoids')
-In [6]: legend(['sin(y)'])
-In [7]: legend(['sin(2y)'], loc = 'center')
-# loc = 'upper right', 'upper left', 'lower left, 'lower right', 'center left',
-# 'center right', 'lower center', 'upper center', 'best', 'right', 'center'
-
-In [8]: legend(['sin(2y)'], loc = (.8, .1))
-
-In [9]: savefig('sin.png') # Save figure
-In [10]: close() # Closes the figure
-
-In [11]: clf() # Clears the Plot area
-
-In [12]: plot(y, sin(y), 'g')
-# Colors can be: 'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'
-
-In [13]: plot(y, cos(y), 'r', linewidth=2)
+\subsection{Annotate}
+\typ{In []: annotate('local max', xy=(1.5, 1))}\\
+Annotates current plot with text, 'local max', at position specified to \typ{xy}.
-In [14]: legend(['x', '-x'])
-In [15]: annotate('origin', xy=(0, 0))
+\subsection{Saving figures}
+\typ{In []: savefig('sinusoids.png')}\\
+Saves the current figure with file name 'sinusoids.png' in current working directory. One can save figure in any of these formats: png, pdf, ps, eps and svg.
-In [16]: xmin, xman = xlim() # Without arguments gets
-In [17]: ymin, ymax = ylim() # values
+\subsection{Miscellaneous}
+\typ{In []: clf() #Clears the current plot area}\\
+\typ{In []: close() #Closes the figure}
+\section{Saving and running scripts}
+\begin{itemize}
+ \item \typ{\%hist}\\
+ It returns the logs of all commands(including mistakes) used in IPython interpreter.
+ \item \typ{\%hist -n}\\
+It disables the line number representation of logs.
+ \item \typ{\%save four\_plot.py 16 18-27}\\
+For creating a script named four\_plot which includes line 16 and line 18 to 27 of logs.
+ \item \typ{\%run -i four\_plot.py}\\
+Running the python script inside IPython interpreter.
+\end{itemize}
-In [18]: xlim(0, 2 * pi) # With values, sets the
-In [19]: ylim(ymin - 0.2, ymax + 0.2) # specified values
+\section{Example}
+ \begin{lstlisting}
+In []: x = linspace(0, 2*pi, 50)
+In []: plot(x, sin(x), 'g')
+In []: plot(x, cos(x), 'r', linewidth=2)
+In []: xlabel('x')
+In []: title('Sinusoidal Waves')
+In []: legend(['sin(x)', 'cos(x)'])
+In []: annotate('origin', xy=(0, 0))
+In []: xmin, xman = xlim() # returns current X axis limits.
+In []: ymin, ymax = ylim()
+In []: xlim(0, 2 * pi) # sets the X axis limits to passed values
+In []: ylim(ymin - 0.2, ymax + 0.2)
+
+In []: savefig('sin.png') # Save figure
+In []: close()
\end{lstlisting}
-\section{Saving and running scripts}
+\section{References}
\begin{itemize}
- \item \typ{\%hist}
- \item \typ{\%save four\_plot.py 16 18-27}
- \item \typ{\%run -i four\_plot.py}
+ \item For documentation on IPython refer: \\ \url{http://ipython.scipy.org/moin/Documentation}
+ \item Plotting(matplotlib) related documentation are available at:\\ \url{http://matplotlib.sourceforge.net/contents.html}
+ \item Explore examples and plots based on matplotlib at \\ \url{http://matplotlib.sourceforge.net/examples/index.html}
\end{itemize}
-
\end{document}
diff --git a/day1/cheatsheet2.tex b/day1/cheatsheet2.tex
index 9823aa3..0b61e7c 100755
--- a/day1/cheatsheet2.tex
+++ b/day1/cheatsheet2.tex
@@ -25,87 +25,135 @@
\LARGE{Plotting Points}\\
\large{FOSSEE}
\end{center}
-\section{Plotting from Data files}
-\begin{verbatim}
-l = [] #Empty List
-t = []
-for line in open('pendulum.txt'): # Opening & Reading files
- points = line.split() # Splitting a string
- l.append(float(points[0])) # Appending to a list
- t.append(float(points[1]))
-tsq = []
-for time in t: #Iterating through lists
- tsq.append(t*t)
-plot(l, tsq, '.') # Plotting points
-\end{verbatim}
+
\section{Plotting Points with Lists}
\begin{lstlisting}
-In [1]: x = [0, 1, 2, 3]
-In [2]: y = [7, 11, 15, 19]
-In [3]: plot(x, y)
-In [4]: clf()
-In [5]: plot(x, y, 'o') # Plotting Circles
-#Dots - '.', #Dashed lines - '--' #Lines - '-'
+In []: x = [0, 1, 2, 3]
+In []: y = [7, 11, 15, 19]
+In []: plot(x, y)
+In []: clf()
+In []: plot(x, y, 'o') # Plotting Circles
+\end{lstlisting}
+
+\subsection{Line style/marker}
+\begin{lstlisting}
+The following format string characters are accepted
+to control the line style or marker:
+
+ ================ ===============================
+ character description
+ ================ ===============================
+ '-' solid line style
+ '--' dashed line style
+ '-.' dash-dot line style
+ ':' dotted line style
+ '.' point marker
+ ',' pixel marker
+ 'o' circle marker
+ 'v' triangle_down marker
+ '^' triangle_up marker
+ '<' triangle_left marker
+ '>' triangle_right marker
+ '1' tri_down marker
+ '2' tri_up marker
+ '3' tri_left marker
+ '4' tri_right marker
+ 's' square marker
+ 'p' pentagon marker
+ '*' star marker
+ 'h' hexagon1 marker
+ 'H' hexagon2 marker
+ '+' plus marker
+ 'x' x marker
+ 'D' diamond marker
+ 'd' thin_diamond marker
+ '|' vline marker
+ '_' hline marker
+ ================ ===============================
+
\end{lstlisting}
+\subsection{Marker combinations}
+\typ{In []: plot(x, y, 'ro')} \\
+This plots figure with red colored filled circles.\\
+Similarly other combination of colors and marker can be used.
\section{Lists}
Initializing
\begin{lstlisting}
-In [10]: mtlist = [] # Empty List
-In [11]: lst = [ 1, 2, 3, 4, 5]
+In []: mtlist = [] # Empty List
+In []: lst = [ 1, 2, 3, 4, 5]
\end{lstlisting}
Slicing
\begin{lstlisting}
-In [12]: lst[1:3] # A slice.
-Out[12]: [2, 3]
+In []: lst[1:3] # A slice.
+Out[]: [2, 3]
-In [13]: lst[1:-1]
-Out[13]: [2, 3, 4]
+In []: lst[1:-1]
+Out[]: [2, 3, 4]
\end{lstlisting}
-Appending to lists
+\subsection{Appending to lists}
\begin{lstlisting}
-In [14]: a = [ 6, 7, 8, 9]
-In [15]: b = lst + a
-In [16]: b
-Out[16]: [1, 2, 3, 4, 5, 6, 7, 8, 9]
-
-In [17]: lst.append(6)
-In [18]: lst
-Out[18]: [ 1, 2, 3, 4, 5, 6]
-\end{lstlisting}
+In []: a = [ 6, 7, 8, 9]
+In []: b = lst + a
+In []: b
+Out[]: [1, 2, 3, 4, 5, 6, 7, 8, 9]
-Iterating over a List
+In []: lst.append(6)
+In []: lst
+Out[]: [ 1, 2, 3, 4, 5, 6]
+\end{lstlisting}
+\subsection{Iterating over a List}
\begin{lstlisting}
-In [19]: for each in b: # Iterating over the list, element-wise
- ....: print b # Print each element
+In []: for element in b: # Iterating over the list, element-wise
+ ....: print element # Print each element
....:
\end{lstlisting}
-Splitting Strings
+\section{Strings}
+\subsection{Splitting Strings}
+\begin{lstlisting}
+In []: greet = ``hello world''
+In []: print greet.split()
+Out[]: ['hello', 'world']
+In []: greet = ``hello, world''
+In []: print greet.split(',')
+Out[]: ['hello', ' world'] # Note the whitespace before 'world'
+\end{lstlisting}
+A string can be split based on the delimiter specified within quotes. A combination of more than one delimiter can also be used.\\
+\typ{In []: greet.split(', ')}\\
+\typ{Out[]: ['hello', 'world']}\\Note the whitespace is not there anymore.
+\newpage
+\section{Plotting from Files}
+\subsection{Opening files}
+
+\typ{In []: f = open('datafile.txt')}\\By default opens in read mode. \\If file does not exist then it throws an exception\\
+\typ{In []: f = open('datafile.txt','r')}\\Specifying the read mode\\
+\typ{In []: f = open('datafile.txt', 'w')}\\Opens the file in write mode. \\If the file already exists, then it deletes all the previous content and opens.
+
+\subsection{Reading from files}
+Just like lists files are iterable as well.
+
\begin{lstlisting}
-In [20]: line = '1.2000e-01 7.4252e-01'
-In [21]: point = line.split() # Splits the string at the space
-Out[21]: ['1.2000e-01', '7.4252e-01']
+ In []: for line in f:
+ ...: print line
+ ...:
+ ...:
\end{lstlisting}
-Plotting from Files
+\subsection{Plotting}
\begin{lstlisting}
-In [22]: L = []
-In [23]: T = []
-
-#Open a file & operate on each line
-In [24]: for line in open('pendulum.txt'):
- .... point = line.split()
- .... L.append(float(point[0]))
- .... T.append(float(point[1]))
-In [25]: TSq = []
-In [26]: for t in T:
- ....: TSq.append(t*t)
- ....:
- ....:
-In [27]: plot(L, TSq, '.')
+l = []
+t = []
+for line in open('pendulum.txt'):
+ point = line.split()
+ l.append(float(point[0]))
+ t.append(float(point[1]))
+tsq = []
+for time in t:
+ tsq.append(time*time)
+plot(l, tsq, '.')
\end{lstlisting}
\end{document}
diff --git a/day1/cheatsheet4.tex b/day1/cheatsheet4.tex
index a7a6a6e..d7e8327 100755
--- a/day1/cheatsheet4.tex
+++ b/day1/cheatsheet4.tex
@@ -24,25 +24,42 @@
\large{FOSSEE}
\end{center}
\section{Matrices}
-Inputting a Matrix
+\subsection{Basics}
+Matrix Creation\\
+\typ{In []: C = array([[1,1,2], [2,4,1], [-1,3,7]])}\\
+It creates C matrix of shape 3x3\\
+Shape is dimenions of given array.
\begin{lstlisting}
-In []: C = array([[1,1,2],
- [2,4,1],
- [-1,3,7]])
-In []: B = ones_like(C)
-In []: A = ones((3,2))
-In []: I = identity(3)
+In []: C.shape
+Out[]: (3, 3)
+In []: shape([[1,2],[4,5],[3,0]])
+Out[]: (3, 2)
\end{lstlisting}
-Accessing Elements
+\typ{In []: B = ones_like(C)} \\
+B would be array of ones with the same shape and type as C.\\
+\typ{In []: A = ones((3,2))} \\
+A would be new array of given shape(arguments), filled with ones.\\
+\typ{In []: I = identity(3)}\\
+I would be identity matrix of shape 3x3
+
+\subsection{Accessing Elements}
\begin{lstlisting}
+In []: C
+Out[]:
+array([[ 1, 1, 2],
+ [ 2, 4, 1],
+ [-1, 3, 7]])
In []: C[1,2]
Out[]: 1
-
+\end{lstlisting}
+Two indexes seperated by \typ{','} specifies [row, column]. So \kwrd{C[1,2]} gets third element of second row(indices starts from 0).
+\newpage
+\begin{lstlisting}
In []: C[1]
Out[]: array([2, 4, 1])
\end{lstlisting}
-
-Changing elements
+Single index implies complete row.
+\subsection{Changing elements}
\begin{lstlisting}
In []: C[1,1] = -2
In []: C
@@ -59,19 +76,27 @@ array([[ 1, 1, 2],
[-1, 3, 7]])
\end{lstlisting}
-Slicing
+\subsection{Slicing}
+Accessing rows with Matricies is straightforward. But If one wants to access particular Column, or want a sub-matrix, Slicing is the way to go.
\begin{lstlisting}
In []: C[:,1]
Out[]: array([1, 0, 3])
-
+\end{lstlisting}
+First index(:) specifies row(':' implies all the rows) and second index(1) specifies column(second column).
+\begin{lstlisting}
In []: C[1,:]
Out[]: array([0, 0, 0])
-
+\end{lstlisting}
+Here we get second row(1), all columns(':') of C matrix.
+\newpage
+\begin{lstlisting}
In []: C[0:2,:]
Out[]:
array([[1, 1, 2],
[0, 0, 0]])
-
+\end{lstlisting}
+Result is sub-matrix with first and second row(endpoint is excluded), and all columns from C.
+\begin{lstlisting}
In []: C[1:3,:]
Out[]:
array([[ 0, 0, 0],
@@ -81,7 +106,9 @@ In []: C[:2,:]
Out[]:
array([[1, 1, 2],
[0, 0, 0]])
-
+\end{lstlisting}
+\typ{':2'} => start from first row, till and excluding third row.
+\begin{lstlisting}
In []: C[1:,:]
Out[]:
array([[ 0, 0, 0],
@@ -92,36 +119,45 @@ Out[]:
array([[ 0, 0],
[-1, 3]])
\end{lstlisting}
-
-Striding
+\typ{'1:'} => Start from second row, till last row\\
+\typ{':2'} => Start from first column, till and excluding third column.
+\newpage
+\subsection{Striding}
+Often apart from submatrix, one needs to get some mechanism to jump a step. For example, how can we have all alternate rows of a Matrix. \\
+Following method will return Matrix with alternate rows.
\begin{lstlisting}
In []: C[::2,:]
Out[]:
array([[ 1, 1, 2],
[-1, 3, 7]])
-
+\end{lstlisting}
+\typ{C[startR:stopR:stepR,startC:stopC:stepC]} => Syntax of mentioning starting index, ending index, and step to jump.\\
+In above mentioned case, \typ{'::2'} means, start from first row, till last row(both are blank), with step of 2, that is, skipping alternate row. After first row, C[startR], next row would be C[startR+stepR] and so on.
+\begin{lstlisting}
In []: C[:,::2]
Out[]:
xarray([[ 1, 2],
[ 0, 0],
[-1, 7]])
-
+\end{lstlisting}
+Same as above, just that here we get matrix with each alternate column and all rows.
+\begin{lstlisting}
In []: C[::2,::2]
Out[]:
array([[ 1, 2],
[-1, 7]])
\end{lstlisting}
-
-Matrix Operations
+\section{Matrix Operations}
+For a Matrix A and B of equal shapes.
\begin{lstlisting}
In []: A.T # Transpose
In []: sum(A) # Sum of all elements
In []: A+B # Addition
-In []: A*B # Product
+In []: A*B # Element wise product
+In []: dot(A,b) #Matrix multiplication
In []: inv(A) # Inverse
In []: det(A) # Determinant
\end{lstlisting}
-
Eigen Values and Eigen Vectors
\begin{lstlisting}
In []: eig(A) #Eigen Values and Vectors
@@ -135,14 +171,33 @@ In []: eigvals(A) #Eigen Values
%% \begin{lstlisting}
%% In []: svd(A)
%% \end{lstlisting}
-Least Square Fit Line
+\section{Least Square Fit Line}
+\begin{lstlisting}
+L = []
+T = []
+for line in open('pendulum.txt'):
+ point = line.split()
+ L.append(float(point[0]))
+ T.append(float(point[1]))
+Tsq = []
+for time in T:
+ Tsq.append(time*time)
+plot(L, Tsq, '.')
+\end{lstlisting}
+This is exact curve we get from L Vs Tsq from data.This relation among L and Tsq is not of straight line. For getting Least Square Fit line, we have to solve the relations:\\
+$L=m*Tsq+c$ (something similar to $y=m*x+c$)\\
+For present scenario, we have L and corresponding Tsq values. For finding m and c at given points we use \typ{lstlq} function provided by pylab. It returns the least-squares solution to an equation. \\
+For finding Least Square Fit line for this particular data we have to do following steps:\\
+\typ{In []: A = array([L, ones\_like(L)])}\\
+A is 2x(Length of array L) array.
\begin{lstlisting}
-In []: A = array([L, ones_like(L)])
-In []: A = A.T
+In []: A = A.T #now A.shape = (Length of array L)x2
In []: result = lstsq(A,TSq)
In []: coef = result[0]
In []: Tline = coef[0]*L + coef[1]
-In []: plot(L, Tline)
\end{lstlisting}
+\typ{coef[0]} is array with all $m$ values, and \typ{coef[1]} contains $c$.\\
+To get the final plot.\\
+\typ{In []: plot(L, Tline)}
\end{document}
diff --git a/day1/cheatsheet6.tex b/day1/cheatsheet6.tex
index 2e9de97..5a9f652 100755
--- a/day1/cheatsheet6.tex
+++ b/day1/cheatsheet6.tex
@@ -1,6 +1,20 @@
\documentclass[12pt]{article}
\title{Solving Equations \& ODEs}
\author{FOSSEE}
+\usepackage{listings}
+\lstset{language=Python,
+ basicstyle=\ttfamily,
+commentstyle=\itshape\bfseries,
+showstringspaces=false,
+}
+\newcommand{\typ}[1]{\lstinline{#1}}
+\usepackage[english]{babel}
+\usepackage[latin1]{inputenc}
+\usepackage{times}
+\usepackage[T1]{fontenc}
+\usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler}
+\usepackage[scaled=.95]{helvet}
\begin{document}
\date{}
\vspace{-1in}
@@ -9,27 +23,87 @@
\large{FOSSEE}
\end{center}
\section{Solving linear equations}
-\begin{verbatim}
- In []: A = array([[3,2,-1],
- [2,-2,4],
- [-1, 0.5, -1]])
- In []: b = array([[1], [-2], [0]])
- In []: x = solve(A, b)
- In []: Ax = dot(A,x)
- In []: allclose(Ax, b)
- Out[]: True
-\end{verbatim}
+Condier following sets of equations:\\
+ \begin{align*}
+ 3x + 2y - z & = 1 \\
+ 2x - 2y + 4z & = -2 \\
+ -x + $\frac{1}{2}$y -z & = 0
+ \end{align*}\\
+The matrix representation is:\\
+\begin{center}
+$A*x = B$
+\end{center}
+Where A is coefficient matrix(in this case 3x3)\\
+B is constant matrix(1x3)\\
+x is the required solution.\\
+\begin{lstlisting}
+In []: A = array([[3,2,-1], [2,-2,4], [-1, 0.5, -1]])
+In []: B = array([[1], [-2], [0]])
+In []: x = solve(A, B)
+\end{lstlisting}
+Solve the equation $A x = B$ for $x$.\\
+To check whether solution is correct try this:
+\begin{lstlisting}
+In []: Ax = dot(A,x) #Matrix multiplication of A and x(LHS)
+In []: allclose(Ax, B)
+Out[]: True
+\end{lstlisting}
+\typ{allclose} Returns \typ{True} if two arrays(in above case Ax and B) are element-wise equal within a tolerance.
+\newpage
\section{Finding roots}
-\begin{verbatim}
- In []: coeffs = [1, 6, 13]
- In []: roots(coeffs)
-\end{verbatim}
-Finding the roots of a function
-\begin{verbatim}
-In []: fsolve(sin(x)+cos(x)**2, 0)
-\end{verbatim}
+\subsection{Polynomials}
+\begin{center}
+ $x^2+6x+13=0$
+\end{center}
+to find roots, pylab provides \typ{roots} function.
+\begin{lstlisting}
+In []: coeffs = [1, 6, 13] #list of all coefficients
+In []: roots(coeffs)
+\end{lstlisting}
+\subsection{functions}
+Functions can be defined and used by following syntax:
+\begin{lstlisting}
+def func_name(arg1, arg2):
+ #function code
+ return ret_value
+\end{lstlisting}
+A simple example can be
+\begin{lstlisting}
+def expression(x):
+ y = x*sin(x)
+ return y
+\end{lstlisting}
+Above function when called with a argument, will return $xsin(x)$ value for that argument.
+\begin{lstlisting}
+In [95]: expression(pi/2)
+Out[95]: 1.5707963267948966
+
+In [96]: expression(pi/3)
+Out[96]: 0.90689968211710881
+\end{lstlisting}
+\subsection{Roots of non-linear eqations}
+For Finding the roots of a non linear equation(defined as $f(x)=0$), around a starting estimate we use \typ{fsolve}:\\
+\typ{In []: from scipy.optimize import fsolve}\\
+\typ{fsolve} is not part of \typ{pylab}, instead it is part of \textbf{optimize} package of \textbf{scipy}, and hence we \textbf{import} it.\\
+%\typ{fsolve} takes first argument as name of function, which evaluates $f(x)$, whose roots one wants to find. And second argument is starting estimate, around which roots are found.
+For illustration, we want to find roots of equation:
+\begin{center}
+ $f(x)=sin(x)+cos(x)^2$
+\end{center}
+So just like we did above, we define a function:
+\begin{lstlisting}
+In []: def f(x):
+ ....: return sin(x)+cos(x)**2
+ ....:
+\end{lstlisting}
+Now to find roots of this non linear equation, around a initial estimate value, say 0, we use \typ{fsolve} in following way:
+\begin{lstlisting}
+In []: fsolve(f, 0) #arguments are function name and estimate
+Out[]: -0.66623943249251527
+\end{lstlisting}
+
\section{ODE}
-\begin{verbatim}
+\begin{lstlisting}
In []: def epid(y, t):
.... k, L = 0.00003, 25000
.... return k*y*(L-y)
@@ -40,5 +114,5 @@ In []: fsolve(sin(x)+cos(x)**2, 0)
In []: y = odeint(epid, 250, t)
In []: plot(t, y)
-\end{verbatim}
+\end{lstlisting}
\end{document}
diff --git a/day1/session1.tex b/day1/session1.tex
index 61cc0d7..47051cc 100644
--- a/day1/session1.tex
+++ b/day1/session1.tex
@@ -335,37 +335,29 @@ In []: legend(['sin(2y)'], loc = 'center')
\begin{columns}
\column{0.6\textwidth}
\includegraphics[height=2in, interpolate=true]{data/position}
-\begin{lstlisting}
-'best', 'right', 'center'
-\end{lstlisting}
\column{0.45\textwidth}
\vspace{-0.2in}
\begin{lstlisting}
-'upper right'
-'upper left'
-'lower left'
-'lower right'
-'center left'
-'center right'
-'lower center'
-'upper center'
+'best'
+'right'
+'center'
\end{lstlisting}
\end{columns}
\end{frame}
-\begin{frame}[fragile]
- \frametitle{For arbitrary location}
-\vspace*{-0.1in}
-\begin{lstlisting}
-In []: legend(['sin(2y)'], loc=(.8,.1))
-\end{lstlisting}
-\emphbar{Specify south-east corner position}
-%\vspace*{-0.2in}
-\begin{center}
- \includegraphics[height=2in, interpolate=true]{data/loc}
-\end{center}
-%\inctime{10}
-\end{frame}
+%% \begin{frame}[fragile]
+%% \frametitle{For arbitrary location}
+%% \vspace*{-0.1in}
+%% \begin{lstlisting}
+%% In []: legend(['sin(2y)'], loc=(.8,.1))
+%% \end{lstlisting}
+%% \emphbar{Specify south-east corner position}
+%% %\vspace*{-0.2in}
+%% \begin{center}
+%% \includegraphics[height=2in, interpolate=true]{data/loc}
+%% \end{center}
+%% %\inctime{10}
+%% \end{frame}
\begin{frame}[fragile]
\frametitle{Saving \& Closing}