author | Puneeth Chaganti <punchagan@fossee.in> |
Mon, 26 Oct 2009 20:44:54 +0530 | |
changeset 177 | 4ec0418ba041 |
parent 172 | 72bd110ab42f |
child 178 | 8a3a9d98fa84 |
permissions | -rw-r--r-- |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
2 |
%Tutorial slides on Python. |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
3 |
% |
141
fccf675946bf
Made usage of FOSSEE consistent; removed all instances of Team, Group.
Puneeth Chaganti <punchagan@fossee.in>
parents:
131
diff
changeset
|
4 |
% Author: FOSSEE |
fccf675946bf
Made usage of FOSSEE consistent; removed all instances of Team, Group.
Puneeth Chaganti <punchagan@fossee.in>
parents:
131
diff
changeset
|
5 |
% Copyright (c) 2009, FOSSEE, IIT Bombay |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
6 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
7 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
8 |
\documentclass[14pt,compress]{beamer} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
9 |
%\documentclass[draft]{beamer} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
10 |
%\documentclass[compress,handout]{beamer} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
11 |
%\usepackage{pgfpages} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
12 |
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
13 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
14 |
% Modified from: generic-ornate-15min-45min.de.tex |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
15 |
\mode<presentation> |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
16 |
{ |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
17 |
\usetheme{Warsaw} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
18 |
\useoutertheme{split} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
19 |
\setbeamercovered{transparent} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
20 |
} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
21 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
22 |
\usepackage[english]{babel} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
23 |
\usepackage[latin1]{inputenc} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
24 |
%\usepackage{times} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
25 |
\usepackage[T1]{fontenc} |
123
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
26 |
\usepackage{amsmath} |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
27 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
28 |
% Taken from Fernando's slides. |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
29 |
\usepackage{ae,aecompl} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
30 |
\usepackage{mathpazo,courier,euler} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
31 |
\usepackage[scaled=.95]{helvet} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
32 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
33 |
\definecolor{darkgreen}{rgb}{0,0.5,0} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
34 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
35 |
\usepackage{listings} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
36 |
\lstset{language=Python, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
37 |
basicstyle=\ttfamily\bfseries, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
38 |
commentstyle=\color{red}\itshape, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
39 |
stringstyle=\color{darkgreen}, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
40 |
showstringspaces=false, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
41 |
keywordstyle=\color{blue}\bfseries} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
42 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
43 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
44 |
% Macros |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
45 |
\setbeamercolor{emphbar}{bg=blue!20, fg=black} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
46 |
\newcommand{\emphbar}[1] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
47 |
{\begin{beamercolorbox}[rounded=true]{emphbar} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
48 |
{#1} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
49 |
\end{beamercolorbox} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
50 |
} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
51 |
\newcounter{time} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
52 |
\setcounter{time}{0} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
53 |
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
54 |
|
127
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
55 |
\newcommand{\typ}[1]{\lstinline{#1}} |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
56 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
57 |
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
58 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
59 |
%%% This is from Fernando's setup. |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
60 |
% \usepackage{color} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
61 |
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
62 |
% % Use and configure listings package for nicely formatted code |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
63 |
% \usepackage{listings} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
64 |
% \lstset{ |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
65 |
% language=Python, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
66 |
% basicstyle=\small\ttfamily, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
67 |
% commentstyle=\ttfamily\color{blue}, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
68 |
% stringstyle=\ttfamily\color{orange}, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
69 |
% showstringspaces=false, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
70 |
% breaklines=true, |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
71 |
% postbreak = \space\dots |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
72 |
% } |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
73 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
74 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
75 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
76 |
% Title page |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
77 |
\title[Basic Python]{Matrices, Solution of equations and Integration\\} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
78 |
|
141
fccf675946bf
Made usage of FOSSEE consistent; removed all instances of Team, Group.
Puneeth Chaganti <punchagan@fossee.in>
parents:
131
diff
changeset
|
79 |
\author[FOSSEE] {FOSSEE} |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
80 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
81 |
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
82 |
\date[] {31, October 2009\\Day 1, Session 4} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
83 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
84 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
85 |
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
86 |
%\logo{\pgfuseimage{iitmlogo}} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
87 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
88 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
89 |
%% Delete this, if you do not want the table of contents to pop up at |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
90 |
%% the beginning of each subsection: |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
91 |
\AtBeginSubsection[] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
92 |
{ |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
93 |
\begin{frame}<beamer> |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
94 |
\frametitle{Outline} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
95 |
\tableofcontents[currentsection,currentsubsection] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
96 |
\end{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
97 |
} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
98 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
99 |
%%\AtBeginSection[] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
100 |
%%{ |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
101 |
%%\begin{frame}<beamer> |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
102 |
%% \frametitle{Outline} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
103 |
%% \tableofcontents[currentsection,currentsubsection] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
104 |
%%\end{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
105 |
%%} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
106 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
107 |
% If you wish to uncover everything in a step-wise fashion, uncomment |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
108 |
% the following command: |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
109 |
%\beamerdefaultoverlayspecification{<+->} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
110 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
111 |
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
112 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
113 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
114 |
% DOCUMENT STARTS |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
115 |
\begin{document} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
116 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
117 |
\begin{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
118 |
\titlepage |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
119 |
\end{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
120 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
121 |
\begin{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
122 |
\frametitle{Outline} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
123 |
\tableofcontents |
123
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
124 |
% \pausesections |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
125 |
\end{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
126 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
127 |
\section{Matrices} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
128 |
\subsection{Initializing} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
129 |
\begin{frame}[fragile] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
130 |
\frametitle{Matrices: Initializing} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
131 |
\begin{lstlisting} |
131
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
127
diff
changeset
|
132 |
In []: a = matrix([[1,2,3], |
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
127
diff
changeset
|
133 |
[4,5,6], |
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
127
diff
changeset
|
134 |
[7,8,9]]) |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
135 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
136 |
In []: a |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
137 |
Out[]: |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
138 |
matrix([[1, 2, 3], |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
139 |
[4, 5, 6], |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
140 |
[7, 8, 9]]) |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
141 |
\end{lstlisting} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
142 |
\end{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
143 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
144 |
\subsection{Basic Operations} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
145 |
\begin{frame}[fragile] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
146 |
\frametitle{Inverse of a Matrix} |
131
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
127
diff
changeset
|
147 |
\begin{small} |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
148 |
\begin{lstlisting} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
149 |
In []: linalg.inv(a) |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
150 |
Out[]: |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
151 |
matrix([[ 3.15221191e+15, -6.30442381e+15, 3.15221191e+15], |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
152 |
[ -6.30442381e+15, 1.26088476e+16, -6.30442381e+15], |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
153 |
[ 3.15221191e+15, -6.30442381e+15, 3.15221191e+15]]) |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
154 |
\end{lstlisting} |
131
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
127
diff
changeset
|
155 |
\end{small} |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
156 |
\end{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
157 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
158 |
\begin{frame}[fragile] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
159 |
\frametitle{Determinant} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
160 |
\begin{lstlisting} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
161 |
In []: linalg.det(a) |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
162 |
Out[]: -9.5171266700777579e-16 |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
163 |
\end{lstlisting} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
164 |
\end{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
165 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
166 |
\begin{frame}[fragile] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
167 |
\frametitle{Computing Norms} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
168 |
\begin{lstlisting} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
169 |
In []: linalg.norm(a) |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
170 |
Out[]: 16.881943016134134 |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
171 |
\end{lstlisting} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
172 |
\end{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
173 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
174 |
\begin{frame}[fragile] |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
175 |
\frametitle{Eigen Values and Eigen Matrix} |
131
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
127
diff
changeset
|
176 |
\begin{small} |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
177 |
\begin{lstlisting} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
178 |
In []: linalg.eigvals(a) |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
179 |
Out[]: array([ 1.61168440e+01, -1.11684397e+00, -1.22196337e-15]) |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
180 |
|
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
181 |
In []: linalg.eig(a) |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
182 |
Out[]: |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
183 |
(array([ 1.61168440e+01, -1.11684397e+00, -1.22196337e-15]), |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
184 |
matrix([[-0.23197069, -0.78583024, 0.40824829], |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
185 |
[-0.52532209, -0.08675134, -0.81649658], |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
186 |
[-0.8186735 , 0.61232756, 0.40824829]])) |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
187 |
\end{lstlisting} |
131
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
127
diff
changeset
|
188 |
\end{small} |
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
189 |
\end{frame} |
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
190 |
|
121
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
191 |
\section{Solving linear equations} |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
192 |
\begin{frame}[fragile] |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
193 |
\frametitle{Solution of equations} |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
194 |
Example problem: Consider the set of equations |
131
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
127
diff
changeset
|
195 |
\vspace{-0.1in} |
121
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
196 |
\begin{align*} |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
197 |
3x + 2y - z & = 1 \\ |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
198 |
2x - 2y + 4z & = -2 \\ |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
199 |
-x + \frac{1}{2}y -z & = 0 |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
200 |
\end{align*} |
131
b3a78754c4a9
Minor edits to day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
127
diff
changeset
|
201 |
\vspace{-0.08in} |
121
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
202 |
To Solve this, |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
203 |
\begin{lstlisting} |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
204 |
In []: A = array([[3,2,-1],[2,-2,4],[-1, 0.5, -1]]) |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
205 |
In []: b = array([1, -2, 0]) |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
206 |
In []: x = linalg.solve(A, b) |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
207 |
In []: Ax = dot(A, x) |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
208 |
In []: allclose(Ax, b) |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
209 |
Out[]: True |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
210 |
\end{lstlisting} |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
211 |
\end{frame} |
ac715f4826f2
Update session4.tex with Linear equations slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
118
diff
changeset
|
212 |
|
172
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
213 |
|
127
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
214 |
\section{Integration} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
215 |
|
172
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
216 |
\subsection{Quadrature} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
217 |
|
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
218 |
\begin{frame}[fragile] |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
219 |
\frametitle{Quadrature} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
220 |
\begin{itemize} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
221 |
\item We wish to find area under a curve |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
222 |
\item Area under $(sin(x) + x^2)$ in $(0,1)$ |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
223 |
\item scipy has functions to do that |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
224 |
\end{itemize} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
225 |
\small{\typ{In []: from scipy.integrate import quad}} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
226 |
\begin{itemize} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
227 |
\item Inputs - function to integrate, limits |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
228 |
\end{itemize} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
229 |
\begin{lstlisting} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
230 |
In []: x = 0 |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
231 |
In []: integrate.quad(sin(x)+x**2, 0, 1) |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
232 |
\end{lstlisting} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
233 |
\alert{\typ{error:}} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
234 |
\typ{First argument must be a callable function.} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
235 |
\end{frame} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
236 |
|
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
237 |
\begin{frame}[fragile] |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
238 |
\frametitle{Functions - Definition} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
239 |
\begin{lstlisting} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
240 |
In []: def f(x): |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
241 |
return sin(x)+x**2 |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
242 |
In []: integrate.quad(f, 0, 1) |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
243 |
\end{lstlisting} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
244 |
\begin{itemize} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
245 |
\item \typ{def} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
246 |
\item arguments |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
247 |
\item \typ{return} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
248 |
\end{itemize} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
249 |
\end{frame} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
250 |
|
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
251 |
\begin{frame}[fragile] |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
252 |
\frametitle{More on functions} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
253 |
\begin{itemize} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
254 |
\item Support default and keyword arguments |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
255 |
\item Scope of variables in the function is local |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
256 |
\item Mutable items are \alert{passed by reference} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
257 |
\item First line after definition may be a documentation string |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
258 |
(\alert{recommended!}) |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
259 |
\item Function definition and execution defines a name bound to the |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
260 |
function |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
261 |
\item You \emph{can} assign a variable to a function! |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
262 |
\end{itemize} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
263 |
\end{frame} |
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
264 |
|
72bd110ab42f
Moved quadrature section; Added a section on functions; day1 session4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
141
diff
changeset
|
265 |
|
127
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
266 |
\subsection{ODEs} |
124 | 267 |
|
123
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
268 |
\begin{frame}[fragile] |
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
269 |
\frametitle{ODE Integration} |
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
270 |
We shall use the simple ODE of a simple pendulum. |
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
271 |
\begin{equation*} |
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
272 |
\ddot{\theta} = -\frac{g}{L}sin(\theta) |
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
273 |
\end{equation*} |
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
274 |
\begin{itemize} |
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
275 |
\item This equation can be written as a system of two first order ODEs |
127
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
276 |
\end{itemize} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
277 |
\begin{align} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
278 |
\dot{\theta} &= \omega \\ |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
279 |
\dot{\omega} &= -\frac{g}{L}sin(\theta) \\ |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
280 |
\text{At}\ t &= 0 : \nonumber \\ |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
281 |
\theta = \theta_0\quad & \&\quad \omega = 0 \nonumber |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
282 |
\end{align} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
283 |
\end{frame} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
284 |
|
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
285 |
\begin{frame}[fragile] |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
286 |
\frametitle{Solving ODEs using SciPy} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
287 |
\begin{itemize} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
288 |
\item We use the \typ{odeint} function from scipy to do the integration |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
289 |
\item Define a function as below |
123
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
290 |
\end{itemize} |
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
291 |
\begin{lstlisting} |
127
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
292 |
In []: def pend_int(unknown, t, p): |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
293 |
.... theta, omega = unknown |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
294 |
.... g, L = p |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
295 |
.... f=[omega, -(g/L)*sin(theta)] |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
296 |
.... return f |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
297 |
.... |
123
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
298 |
\end{lstlisting} |
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
299 |
\end{frame} |
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
300 |
|
127
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
301 |
\begin{frame}[fragile] |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
302 |
\frametitle{Solving ODEs using SciPy \ldots} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
303 |
\begin{itemize} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
304 |
\item \typ{t} is the time variable \\ |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
305 |
\item \typ{p} has the constants \\ |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
306 |
\item \typ{initial} has the initial values |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
307 |
\end{itemize} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
308 |
\begin{lstlisting} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
309 |
In []: t = linspace(0, 10, 101) |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
310 |
In []: p=(-9.81, 0.2) |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
311 |
In []: initial = [10*2*pi/360, 0] |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
312 |
\end{lstlisting} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
313 |
\end{frame} |
123
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
314 |
|
127
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
315 |
\begin{frame}[fragile] |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
316 |
\frametitle{Solving ODEs using SciPy \ldots} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
317 |
|
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
318 |
\small{\typ{In []: from scipy.integrate import odeint}} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
319 |
\begin{lstlisting} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
320 |
In []: pend_sol = odeint(pend_int, |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
321 |
initial,t, |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
322 |
args=(p,)) |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
323 |
\end{lstlisting} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
324 |
\end{frame} |
44c2f614e321
Updated Integration section in Session 4.
Puneeth Chaganti <punchagan@fossee.in>
parents:
124
diff
changeset
|
325 |
|
118
c7f85ba59af3
Added session4.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
326 |
\end{document} |
123
d2f4053a2e85
Added first slides for ODE.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
327 |