day1/exercises.tex
author Puneeth Chaganti <punchagan@fossee.in>
Sun, 10 Jan 2010 22:36:09 +0530
changeset 352 b44d7bcc6609
parent 336 f2c89f9af85f
permissions -rw-r--r--
Added a few quiz questions; Minor edits.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     2
%Tutorial slides on Python.
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     3
%
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     4
% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in>
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     5
% Copyright (c) 2005-2009, Prabhu Ramachandran
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     7
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     8
\documentclass[14pt,compress]{beamer}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     9
%\documentclass[draft]{beamer}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    10
%\documentclass[compress,handout]{beamer}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    11
%\usepackage{pgfpages} 
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    12
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    13
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    14
% Modified from: generic-ornate-15min-45min.de.tex
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    15
\mode<presentation>
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    16
{
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    17
  \usetheme{Warsaw}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    18
  \useoutertheme{infolines}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    19
  \setbeamercovered{transparent}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    20
}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    21
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    22
\usepackage[english]{babel}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    23
\usepackage[latin1]{inputenc}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    24
%\usepackage{times}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    25
\usepackage[T1]{fontenc}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    26
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    27
% Taken from Fernando's slides.
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    28
\usepackage{ae,aecompl}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    29
\usepackage{mathpazo,courier,euler}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    30
\usepackage[scaled=.95]{helvet}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    31
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    32
\definecolor{darkgreen}{rgb}{0,0.5,0}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    33
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    34
\usepackage{listings}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    35
\lstset{language=Python,
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    36
    basicstyle=\ttfamily\bfseries,
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    37
    commentstyle=\color{red}\itshape,
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    38
  stringstyle=\color{darkgreen},
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    39
  showstringspaces=false,
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    40
  keywordstyle=\color{blue}\bfseries}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    41
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    42
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    43
% Macros
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    44
\setbeamercolor{emphbar}{bg=blue!20, fg=black}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    45
\newcommand{\emphbar}[1]
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    46
{\begin{beamercolorbox}[rounded=true]{emphbar} 
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    47
      {#1}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    48
 \end{beamercolorbox}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    49
}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    50
\newcounter{time}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    51
\setcounter{time}{0}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    52
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    53
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    54
\newcommand{\typ}[1]{\texttt{#1}}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    55
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    56
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    57
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    58
%%% This is from Fernando's setup.
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    59
% \usepackage{color}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    60
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    61
% % Use and configure listings package for nicely formatted code
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    62
% \usepackage{listings}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    63
% \lstset{
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    64
%    language=Python,
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    65
%    basicstyle=\small\ttfamily,
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    66
%    commentstyle=\ttfamily\color{blue},
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    67
%    stringstyle=\ttfamily\color{orange},
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    68
%    showstringspaces=false,
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    69
%    breaklines=true,
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    70
%    postbreak = \space\dots
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    71
% }
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    72
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    73
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    75
% Title page
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    76
\title[Exercises]{Exercises}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    77
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    78
\author[FOSSEE] {FOSSEE}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    79
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    80
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
    81
\date[] {11 January, 2010\\Day 1, Session 5}
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    82
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    83
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    84
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    85
%\logo{\pgfuseimage{iitmlogo}}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    86
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    87
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    88
%% Delete this, if you do not want the table of contents to pop up at
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    89
%% the beginning of each subsection:
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    90
\AtBeginSubsection[]
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    91
{
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    92
  \begin{frame}<beamer>
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    93
    \frametitle{Outline}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    94
    \tableofcontents[currentsection,currentsubsection]
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    95
  \end{frame}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    96
}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    97
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    98
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    99
% If you wish to uncover everything in a step-wise fashion, uncomment
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   100
% the following command: 
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   101
%\beamerdefaultoverlayspecification{<+->}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   102
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   103
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   104
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   105
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   106
% DOCUMENT STARTS
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   107
\begin{document}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   108
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   109
\begin{frame}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   110
  \titlepage
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   111
\end{frame}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   112
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   113
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   114
\begin{frame}[fragile]
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   115
  \frametitle{Problem 1}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   116
  \begin{columns}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   117
    \column{0.5\textwidth}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   118
    \hspace*{-0.5in}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   119
    \includegraphics[height=2in, interpolate=true]{data/L-Tsq.png}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   120
    \column{0.45\textwidth}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   121
    \begin{block}{Example code}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   122
    \tiny
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   123
    \begin{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   124
l = []
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   125
t = []
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   126
for line in open('pendulum.txt'):
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   127
    point = line.split()
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   128
    l.append(float(point[0]))
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   129
    t.append(float(point[1]))
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   130
tsq = []
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   131
for time in t:
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   132
    tsq.append(time*time)
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   133
plot(l, tsq, '.')
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   134
    \end{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   135
    \end{block}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   136
  \end{columns}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   137
  \begin{block}{Problem Statement}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   138
    Tweak above code to plot data in file 'location.txt'.
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   139
  \end{block}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   140
\end{frame}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   141
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   142
\begin{frame}
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   143
  \frametitle{Problem 1 cont...}
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   144
  \begin{itemize}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   145
  \item Label both the axes.
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   146
  \item What kind of motion is this?
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   147
  \item Title the graph accordingly.
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   148
  \item Annotate the position where vertical velocity is zero.
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   149
  \end{itemize}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   150
\end{frame}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   151
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   152
\begin{frame}[fragile]
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   153
  \frametitle{Problem 2}
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   154
  \begin{columns}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   155
    \column{0.5\textwidth}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   156
    \hspace*{-0.5in}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   157
    \includegraphics[height=2in, interpolate=true]{data/points}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   158
    \column{0.45\textwidth}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   159
    \begin{block}{Line between two points}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   160
    \tiny
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   161
    \begin{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   162
In []: x = [1, 5]
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   163
In []: y = [1, 4]
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   164
In []: plot(x, y)
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   165
    \end{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   166
    \end{block}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   167
  \end{columns}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   168
  Line can be plotted using arrays of coordinates.
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   169
  \pause
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   170
  \begin{block}{Problem statement}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   171
    Write a Program that plots a regular n-gon(Let n = 5).
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   172
  \end{block}  
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   173
\end{frame}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   174
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   175
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   176
\begin{frame}[fragile]
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   177
  \frametitle{Problem 3}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   178
  \begin{columns}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   179
    \column{0.5\textwidth}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   180
    \hspace*{-0.5in}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   181
    \includegraphics[height=2in, interpolate=true]{data/damp}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   182
    \column{0.45\textwidth}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   183
    \begin{block}{Damped Oscillation}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   184
    \tiny
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   185
    \begin{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   186
In []: x = linspace(0, 4*pi)
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   187
In []: plot(x, exp(x/10)*sin(x))
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   188
    \end{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   189
    \end{block}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   190
  \end{columns}
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   191
\end{frame}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   192
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   193
\begin{frame}[fragile]
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   194
  \frametitle{Problem 3 cont...}
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   195
Create a sequence of images in which the damped oscillator($e^{x/10}sin(x)$) slowly evolves over time.
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   196
\begin{columns}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   197
\column{0.35\textwidth}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   198
\includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot2}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   199
\column{0.35\textwidth}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   200
\includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot4}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   201
\column{0.35\textwidth}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   202
\includegraphics[width=1.5in,height=1.5in, interpolate=true]{data/plot6}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   203
\end{columns}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   204
\begin{block}{Hint}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   205
\small
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   206
  \begin{lstlisting}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   207
savefig('plot'+str(i)+'.png') #i is int variable  
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   208
  \end{lstlisting}  
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   209
\end{block}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   210
\end{frame}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   211
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   212
\begin{frame}[fragile]
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   213
  \frametitle{Problem 4}
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   214
  \begin{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   215
In []: x = imread('smoothing.png')
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   216
In []: x.shape
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   217
Out[]: (256, 256)
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   218
In []: imshow(x,cmap=cm.gray)
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   219
  \end{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   220
\emphbar{Replace each pixel with mean of neighboring pixels}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   221
  \begin{center}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   222
  \includegraphics[height=1in, interpolate=true]{data/neighbour}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   223
  \end{center}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   224
\end{frame}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   225
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   226
\begin{frame}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   227
  \begin{center}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   228
    \includegraphics[height=3in, interpolate=true]{data/smoothing}    
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   229
  \end{center}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   230
\end{frame}
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   231
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   232
\begin{frame}[fragile]
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   233
  \frametitle{Problem 4: Approach}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   234
  For \typ{y} being resultant image:
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   235
  \begin{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   236
y[1, 1] = x[0, 1]/4 + x[1, 0]/4 
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   237
          + x[2, 1]/4 + x[1, 2]/4    
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   238
  \end{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   239
   \begin{columns}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   240
    \column{0.45\textwidth}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   241
    \hspace*{-0.5in}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   242
    \includegraphics[height=1.5in, interpolate=true]{data/smoothing}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   243
    \column{0.45\textwidth}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   244
    \hspace*{-0.5in}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   245
    \includegraphics[height=1.5in, interpolate=true]{data/after-filter}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   246
  \end{columns}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   247
   \begin{block}{Hint:}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   248
     Use array Slicing.
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   249
   \end{block}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   250
\end{frame}
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   251
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   252
\begin{frame}[fragile]
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   253
  \frametitle{Solution}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   254
  \begin{lstlisting}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   255
In []: y = zeros_like(x)
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   256
In []: y[1:-1,1:-1] = x[:-2,1:-1]/4+
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   257
                      x[2:,1:-1]/4+
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   258
                      x[1:-1,2:]/4+
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   259
                      x[1:-1,:-2]/4
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   260
In []: imshow(y,cmap=cm.gray)
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   261
  \end{lstlisting}
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   262
\end{frame}
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   263
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   264
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   265
\end{document}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   266
336
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   267
%% \begin{frame}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   268
%%   \frametitle{Problem 4}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   269
%%   Legendre polynomials $P_n(x)$ are defined by the following recurrence relation
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   270
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   271
%% \center{$(n+1)P_{n+1}(x) - (2n+1)xP_n(x) + nP_{n-1}(x) = 0$}\\
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   272
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   273
%% with $P_0(x) = 1$, $P_1(x) = x$ and $P_2(x) = (3x^2 - 1)/2$. Compute the next three 
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   274
%%    Legendre polynomials and plot all 6 over the interval [-1,1].
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   275
%% \end{frame}
f2c89f9af85f Added changes to exercise session of day1.
Shantanu <shantanu@fossee.in>
parents: 330
diff changeset
   276
294
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   277
%% \begin{frame}[fragile] 
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   278
%% \frametitle{Problem Set 5}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   279
%%   \begin{columns}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   280
%%     \column{0.6\textwidth}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   281
%%     \small{
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   282
%%     \begin{itemize}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   283
%%       \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. 
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   284
%%     \end{itemize}}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   285
%%     \column{0.35\textwidth}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   286
%%     \hspace*{-0.5in}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   287
%%   \includegraphics[height=1.6in, interpolate=true]{data/cobweb}  
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   288
%% \end{columns}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   289
%% \end{frame}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   290
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   291
%% \begin{frame}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   292
%%   \frametitle{Problem Set 5.3}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   293
%%   Plot the cobweb plot as follows:
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   294
%%   \begin{enumerate}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   295
%%     \item Start at $(x_0, 0)$ ($\implies$ i=0)
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   296
%%     \item Draw a line to $(x_i, f(x_i))$
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   297
%%     \item Set $x_{i+1} = f(x_i)$
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   298
%%     \item Draw a line to $(x_{i+1}, x_{i+1})$
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   299
%%     \item $(i\implies i+1)$ 
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   300
%%     \item Repeat from 2 for as long as you want 
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   301
%%   \end{enumerate}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   302
%% \inctime{20}
f05b1c457120 Added exercise session day1.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
   303
%% \end{frame}