day2/session5.tex
author Shantanu <shantanu@fossee.in>
Sat, 31 Oct 2009 01:33:41 +0530
changeset 262 9664eddee075
parent 239 8953675dc056
child 263 8a4a1e5aec85
permissions -rw-r--r--
Merged all branches.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    81
\date[] {1, November 2009\\Day 2}
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}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   114
  The aliquot of a number is defined as: the sum of the \emph{proper} divisors of the number. For example, aliquot(12) = 1 + 2 + 3 + 4 + 6 = 16.\\
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   115
  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
   116
\end{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   117
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   118
\begin{frame}{Problem 1.2}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   119
  A pair of numbers (a, b) is said to be \alert{amicable} if the aliquot number of a is b and the aliquot number of b is a.\\
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   120
  Example: \texttt{220, 284}\\
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   121
  Write a program that prints all four digit amicable pairs.
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   122
  
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   123
\inctime{20}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   124
\end{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   125
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   126
%% \begin{frame}{Problem 2}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   127
%%   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
   128
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   129
%% \end{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   130
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   131
\begin{frame}[fragile]
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   132
  \frametitle{Problem Set 2}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   133
  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
   134
  \begin{lstlisting}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   135
    [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
   136
  \end{lstlisting}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   137
\inctime{10}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   138
\end{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   139
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   140
\begin{frame} 
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   141
  \frametitle{Problem Set 3}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   142
  \begin{description}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   143
    \item[3.1] Count word frequencies in a file.
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   144
\end{description}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   145
\inctime{5}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   146
\end{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   147
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   148
\begin{frame}[fragile]
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   149
  \frametitle{Problem set 4}
219
f6725f6bee41 Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents: 206
diff changeset
   150
  Central difference
206
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   151
  \begin{equation*}
219
f6725f6bee41 Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents: 206
diff changeset
   152
  \frac{sin(x+h)-sin(x-h)}{2h}
206
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   153
  \end{equation*}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   154
  \begin{lstlisting}
219
f6725f6bee41 Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents: 206
diff changeset
   155
  In []: x = linspace(0, 2*pi, 100)
f6725f6bee41 Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents: 206
diff changeset
   156
  In []: y = sin(x)
f6725f6bee41 Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents: 206
diff changeset
   157
  In []: deltax = x[1] - x[0]
206
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   158
  \end{lstlisting}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   159
  \pause
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   160
    \begin{enumerate}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   161
      \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
   162
    \end{enumerate}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   163
\end{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   164
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   165
\begin{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   166
  \frametitle{Problem Set 5}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   167
  \begin{itemize}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   168
      \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
   169
      \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
   170
          $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
   171
\end{itemize}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   172
\end{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   173
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   174
\begin{frame}[fragile] 
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   175
\frametitle{Problem Set 5}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   176
  \begin{columns}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   177
    \column{0.6\textwidth}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   178
    \small{
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   179
    \begin{itemize}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   180
      \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
   181
    \end{itemize}}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   182
    \column{0.35\textwidth}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   183
    \hspace*{-0.5in}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   184
  \includegraphics[height=1.6in, interpolate=true]{data/cobweb}  
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   185
\end{columns}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   186
\end{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   187
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   188
\begin{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   189
  \frametitle{Problem Set 5.3}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   190
  Plot the cobweb plot as follows:
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   191
  \begin{enumerate}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   192
    \item Start at $(x_0, 0)$ ($\implies$ i=0)
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   193
    \item Draw a line to $(x_i, f(x_i))$
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   194
    \item Set $x_{i+1} = f(x_i)$
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   195
    \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
   196
    \item $(i\implies i+1)$ 
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   197
    \item Repeat from 2 for as long as you want 
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   198
  \end{enumerate}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   199
\inctime{20}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   200
\end{frame}
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   201
9ce77dab0a21 Added session 5 day 2(Exercises).
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   202
\end{document}