|
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
2 %Tutorial slides on Python. |
|
3 % |
|
4 % Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in> |
|
5 % Copyright (c) 2005-2009, Prabhu Ramachandran |
|
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
7 |
|
8 \documentclass[14pt,compress]{beamer} |
|
9 %\documentclass[draft]{beamer} |
|
10 %\documentclass[compress,handout]{beamer} |
|
11 %\usepackage{pgfpages} |
|
12 %\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm] |
|
13 |
|
14 % Modified from: generic-ornate-15min-45min.de.tex |
|
15 \mode<presentation> |
|
16 { |
|
17 \usetheme{Warsaw} |
|
18 \useoutertheme{infolines} |
|
19 \setbeamercovered{transparent} |
|
20 } |
|
21 |
|
22 \usepackage[english]{babel} |
|
23 \usepackage[latin1]{inputenc} |
|
24 %\usepackage{times} |
|
25 \usepackage[T1]{fontenc} |
|
26 |
|
27 % Taken from Fernando's slides. |
|
28 \usepackage{ae,aecompl} |
|
29 \usepackage{mathpazo,courier,euler} |
|
30 \usepackage[scaled=.95]{helvet} |
|
31 |
|
32 \definecolor{darkgreen}{rgb}{0,0.5,0} |
|
33 |
|
34 \usepackage{listings} |
|
35 \lstset{language=Python, |
|
36 basicstyle=\ttfamily\bfseries, |
|
37 commentstyle=\color{red}\itshape, |
|
38 stringstyle=\color{darkgreen}, |
|
39 showstringspaces=false, |
|
40 keywordstyle=\color{blue}\bfseries} |
|
41 |
|
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
43 % Macros |
|
44 \setbeamercolor{emphbar}{bg=blue!20, fg=black} |
|
45 \newcommand{\emphbar}[1] |
|
46 {\begin{beamercolorbox}[rounded=true]{emphbar} |
|
47 {#1} |
|
48 \end{beamercolorbox} |
|
49 } |
|
50 \newcounter{time} |
|
51 \setcounter{time}{0} |
|
52 \newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} |
|
53 |
|
54 \newcommand{\typ}[1]{\texttt{#1}} |
|
55 |
|
56 \newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } |
|
57 |
|
58 %%% This is from Fernando's setup. |
|
59 % \usepackage{color} |
|
60 % \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} |
|
61 % % Use and configure listings package for nicely formatted code |
|
62 % \usepackage{listings} |
|
63 % \lstset{ |
|
64 % language=Python, |
|
65 % basicstyle=\small\ttfamily, |
|
66 % commentstyle=\ttfamily\color{blue}, |
|
67 % stringstyle=\ttfamily\color{orange}, |
|
68 % showstringspaces=false, |
|
69 % breaklines=true, |
|
70 % postbreak = \space\dots |
|
71 % } |
|
72 |
|
73 |
|
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
75 % Title page |
|
76 \title[Exercises]{Exercises} |
|
77 |
|
78 \author[FOSSEE] {FOSSEE} |
|
79 |
|
80 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
|
81 \date[] {7 November, 2009\\Day 1, Session 5} |
|
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
83 |
|
84 %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} |
|
85 %\logo{\pgfuseimage{iitmlogo}} |
|
86 |
|
87 |
|
88 %% Delete this, if you do not want the table of contents to pop up at |
|
89 %% the beginning of each subsection: |
|
90 \AtBeginSubsection[] |
|
91 { |
|
92 \begin{frame}<beamer> |
|
93 \frametitle{Outline} |
|
94 \tableofcontents[currentsection,currentsubsection] |
|
95 \end{frame} |
|
96 } |
|
97 |
|
98 |
|
99 % If you wish to uncover everything in a step-wise fashion, uncomment |
|
100 % the following command: |
|
101 %\beamerdefaultoverlayspecification{<+->} |
|
102 |
|
103 %\includeonlyframes{current,current1,current2,current3,current4,current5,current6} |
|
104 |
|
105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
106 % DOCUMENT STARTS |
|
107 \begin{document} |
|
108 |
|
109 \begin{frame} |
|
110 \titlepage |
|
111 \end{frame} |
|
112 |
|
113 |
|
114 \begin{frame} |
|
115 \frametitle{Problem 1} |
|
116 \begin{itemize} |
|
117 \item Open file 'pos.txt', it has X and Y Coordinate of a particle under motion |
|
118 \item Plot X vs Y Graph. |
|
119 \item Label both the axes. |
|
120 \item What kind of motion is this? |
|
121 \item Title the graph accordingly. |
|
122 \item Annotate the position where vertical velocity is zero. |
|
123 \end{itemize} |
|
124 \end{frame} |
|
125 |
|
126 \begin{frame} |
|
127 \frametitle{Problem 2} |
|
128 Write a Program that plots a regular n-gon(Let n = 5). |
|
129 \end{frame} |
|
130 |
|
131 \begin{frame}[fragile] |
|
132 \frametitle{Problem 3} |
|
133 Create a sequence of images in which the damped oscillator($e^{x/10}sin(x)$) slowly evolves over time. |
|
134 \begin{columns} |
|
135 \column{0.35\textwidth} |
|
136 \includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot2} |
|
137 \column{0.35\textwidth} |
|
138 \includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot4} |
|
139 \column{0.35\textwidth} |
|
140 \includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot6} |
|
141 \end{columns} |
|
142 \begin{block}{Hint} |
|
143 \small |
|
144 \begin{lstlisting} |
|
145 savefig('plot'+str(i)+'.png') #i is int variable |
|
146 \end{lstlisting} |
|
147 \end{block} |
|
148 \end{frame} |
|
149 |
|
150 \begin{frame} |
|
151 \frametitle{Problem 4} |
|
152 Legendre polynomials $P_n(x)$ are defined by the following recurrence relation |
|
153 |
|
154 \center{$(n+1)P_{n+1}(x) - (2n+1)xP_n(x) + nP_{n-1}(x) = 0$}\\ |
|
155 |
|
156 with $P_0(x) = 1$, $P_1(x) = x$ and $P_2(x) = (3x^2 - 1)/2$. Compute the next three |
|
157 Legendre polynomials and plot all 6 over the interval [-1,1]. |
|
158 \end{frame} |
|
159 \end{document} |
|
160 |
|
161 %% \begin{frame}[fragile] |
|
162 %% \frametitle{Problem Set 5} |
|
163 %% \begin{columns} |
|
164 %% \column{0.6\textwidth} |
|
165 %% \small{ |
|
166 %% \begin{itemize} |
|
167 %% \item[3] Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) = kx(1-x)$. Plot the successive iterates of this process as explained below. |
|
168 %% \end{itemize}} |
|
169 %% \column{0.35\textwidth} |
|
170 %% \hspace*{-0.5in} |
|
171 %% \includegraphics[height=1.6in, interpolate=true]{data/cobweb} |
|
172 %% \end{columns} |
|
173 %% \end{frame} |
|
174 |
|
175 %% \begin{frame} |
|
176 %% \frametitle{Problem Set 5.3} |
|
177 %% Plot the cobweb plot as follows: |
|
178 %% \begin{enumerate} |
|
179 %% \item Start at $(x_0, 0)$ ($\implies$ i=0) |
|
180 %% \item Draw a line to $(x_i, f(x_i))$ |
|
181 %% \item Set $x_{i+1} = f(x_i)$ |
|
182 %% \item Draw a line to $(x_{i+1}, x_{i+1})$ |
|
183 %% \item $(i\implies i+1)$ |
|
184 %% \item Repeat from 2 for as long as you want |
|
185 %% \end{enumerate} |
|
186 %% \inctime{20} |
|
187 %% \end{frame} |