author | Puneeth Chaganti <punchagan@fossee.in> |
Thu, 05 Nov 2009 09:22:27 +0530 | |
changeset 271 | 3f32f679bb45 |
parent 263 | 8a4a1e5aec85 |
child 288 | c4e25269a86c |
permissions | -rw-r--r-- |
206
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
2 |
%Tutorial slides on Python. |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
3 |
% |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
4 |
% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in> |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
5 |
% Copyright (c) 2005-2009, Prabhu Ramachandran |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
6 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
7 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
8 |
\documentclass[14pt,compress]{beamer} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
9 |
%\documentclass[draft]{beamer} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
10 |
%\documentclass[compress,handout]{beamer} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
11 |
%\usepackage{pgfpages} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
12 |
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm] |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
13 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
14 |
% Modified from: generic-ornate-15min-45min.de.tex |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
15 |
\mode<presentation> |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
16 |
{ |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
17 |
\usetheme{Warsaw} |
239
8953675dc056
Added slide numbers.
Puneeth Chaganti <punchagan@fossee.in>
parents:
219
diff
changeset
|
18 |
\useoutertheme{infolines} |
206
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
19 |
\setbeamercovered{transparent} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
20 |
} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
21 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
22 |
\usepackage[english]{babel} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
23 |
\usepackage[latin1]{inputenc} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
24 |
%\usepackage{times} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
25 |
\usepackage[T1]{fontenc} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
26 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
27 |
% Taken from Fernando's slides. |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
28 |
\usepackage{ae,aecompl} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
29 |
\usepackage{mathpazo,courier,euler} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
30 |
\usepackage[scaled=.95]{helvet} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
31 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
32 |
\definecolor{darkgreen}{rgb}{0,0.5,0} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
33 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
34 |
\usepackage{listings} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
35 |
\lstset{language=Python, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
36 |
basicstyle=\ttfamily\bfseries, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
37 |
commentstyle=\color{red}\itshape, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
38 |
stringstyle=\color{darkgreen}, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
39 |
showstringspaces=false, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
40 |
keywordstyle=\color{blue}\bfseries} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
41 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
42 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
43 |
% Macros |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
44 |
\setbeamercolor{emphbar}{bg=blue!20, fg=black} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
45 |
\newcommand{\emphbar}[1] |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
46 |
{\begin{beamercolorbox}[rounded=true]{emphbar} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
47 |
{#1} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
48 |
\end{beamercolorbox} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
49 |
} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
50 |
\newcounter{time} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
51 |
\setcounter{time}{0} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
52 |
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
53 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
54 |
\newcommand{\typ}[1]{\texttt{#1}} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
55 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
56 |
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
57 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
58 |
%%% This is from Fernando's setup. |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
59 |
% \usepackage{color} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
60 |
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
61 |
% % Use and configure listings package for nicely formatted code |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
62 |
% \usepackage{listings} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
63 |
% \lstset{ |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
64 |
% language=Python, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
65 |
% basicstyle=\small\ttfamily, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
66 |
% commentstyle=\ttfamily\color{blue}, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
67 |
% stringstyle=\ttfamily\color{orange}, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
68 |
% showstringspaces=false, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
69 |
% breaklines=true, |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
70 |
% postbreak = \space\dots |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
71 |
% } |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
72 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
73 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
74 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
75 |
% Title page |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
76 |
\title[Exercises]{Exercises} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
77 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
78 |
\author[FOSSEE] {FOSSEE} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
79 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
80 |
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
239
diff
changeset
|
81 |
\date[] {1 November, 2009\\Day 2, Session 4} |
206
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
82 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
83 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
84 |
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
85 |
%\logo{\pgfuseimage{iitmlogo}} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
86 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
87 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
88 |
%% Delete this, if you do not want the table of contents to pop up at |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
89 |
%% the beginning of each subsection: |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
90 |
\AtBeginSubsection[] |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
91 |
{ |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
92 |
\begin{frame}<beamer> |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
93 |
\frametitle{Outline} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
94 |
\tableofcontents[currentsection,currentsubsection] |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
95 |
\end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
96 |
} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
97 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
98 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
99 |
% If you wish to uncover everything in a step-wise fashion, uncomment |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
100 |
% the following command: |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
101 |
%\beamerdefaultoverlayspecification{<+->} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
102 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
103 |
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
104 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
105 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
106 |
% DOCUMENT STARTS |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
107 |
\begin{document} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
108 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
109 |
\begin{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
110 |
\titlepage |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
111 |
\end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
112 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
113 |
\begin{frame}{Problem 1.1} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
239
diff
changeset
|
114 |
The aliquot of a number is defined as: the sum of the \emph{proper} divisors of the number. \\For example: |
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
239
diff
changeset
|
115 |
\center{aliquot(12) = 1 + 2 + 3 + 4 + 6 = 16.}\\ |
206
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
116 |
Write a function that returns the aliquot number of a given number. |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
117 |
\end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
118 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
119 |
\begin{frame}{Problem 1.2} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
239
diff
changeset
|
120 |
Pair of numbers (a, b) is said to be \alert{amicable} if aliquot number of a is b and aliquot number of b is a.\\ |
206
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
121 |
Example: \texttt{220, 284}\\ |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
122 |
Write a program that prints all four digit amicable pairs. |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
123 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
124 |
\inctime{20} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
125 |
\end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
126 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
127 |
%% \begin{frame}{Problem 2} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
128 |
%% Given an empty chessboard and one Bishop placed in any s%quare, say (r, c), generate the list of all squares the Bi%shop could move to. |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
129 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
130 |
%% \end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
131 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
132 |
\begin{frame}[fragile] |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
133 |
\frametitle{Problem Set 2} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
134 |
Given a string like, ``1, 3-7, 12, 15, 18-21'', produce the list \\ |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
135 |
\begin{lstlisting} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
136 |
[1,3,4,5,6,7,12,15,18,19,20,21] |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
137 |
\end{lstlisting} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
138 |
\inctime{10} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
139 |
\end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
140 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
141 |
\begin{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
142 |
\frametitle{Problem Set 3} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
143 |
\begin{description} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
144 |
\item[3.1] Count word frequencies in a file. |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
145 |
\end{description} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
146 |
\inctime{5} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
147 |
\end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
148 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
149 |
\begin{frame}[fragile] |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
150 |
\frametitle{Problem set 4} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
206
diff
changeset
|
151 |
Central difference |
206
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
152 |
\begin{equation*} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
206
diff
changeset
|
153 |
\frac{sin(x+h)-sin(x-h)}{2h} |
206
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
154 |
\end{equation*} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
155 |
\begin{lstlisting} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
206
diff
changeset
|
156 |
In []: x = linspace(0, 2*pi, 100) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
206
diff
changeset
|
157 |
In []: y = sin(x) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
206
diff
changeset
|
158 |
In []: deltax = x[1] - x[0] |
206
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
159 |
\end{lstlisting} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
160 |
\pause |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
161 |
\begin{enumerate} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
162 |
\item Given this, get the finite difference of sin in the range 0 to 2*pi |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
163 |
\end{enumerate} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
164 |
\end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
165 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
166 |
\begin{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
167 |
\frametitle{Problem Set 5} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
168 |
\begin{itemize} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
169 |
\item[5.1] Write a function that plots any regular n-gon given \typ{n}. |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
170 |
\item[5.2] Consider the logistic map, $f(x) = kx(1-x)$, plot it for |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
171 |
$k=2.5, 3.5$ and $4$ in the same plot. |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
172 |
\end{itemize} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
173 |
\end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
174 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
175 |
\begin{frame}[fragile] |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
176 |
\frametitle{Problem Set 5} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
177 |
\begin{columns} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
178 |
\column{0.6\textwidth} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
179 |
\small{ |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
180 |
\begin{itemize} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
181 |
\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. |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
182 |
\end{itemize}} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
183 |
\column{0.35\textwidth} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
184 |
\hspace*{-0.5in} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
185 |
\includegraphics[height=1.6in, interpolate=true]{data/cobweb} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
186 |
\end{columns} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
187 |
\end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
188 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
189 |
\begin{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
190 |
\frametitle{Problem Set 5.3} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
191 |
Plot the cobweb plot as follows: |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
192 |
\begin{enumerate} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
193 |
\item Start at $(x_0, 0)$ ($\implies$ i=0) |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
194 |
\item Draw a line to $(x_i, f(x_i))$ |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
195 |
\item Set $x_{i+1} = f(x_i)$ |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
196 |
\item Draw a line to $(x_{i+1}, x_{i+1})$ |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
197 |
\item $(i\implies i+1)$ |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
198 |
\item Repeat from 2 for as long as you want |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
199 |
\end{enumerate} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
200 |
\inctime{20} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
201 |
\end{frame} |
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
202 |
|
9ce77dab0a21
Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
203 |
\end{document} |