# HG changeset patch # User Puneeth Chaganti # Date 1262612391 -19800 # Node ID 63b69ed765d00b1c5f8faeeda80fc17579cd2985 # Parent 56aa2efbf7d9dfaf9198294d61bb2a2da961e588# Parent f2c89f9af85f94d9b6a8a66bc0de3fe8742239f8 Merged with mainline. diff -r 56aa2efbf7d9 -r 63b69ed765d0 day1/data/after-filter.png Binary file day1/data/after-filter.png has changed diff -r 56aa2efbf7d9 -r 63b69ed765d0 day1/data/damp.png Binary file day1/data/damp.png has changed diff -r 56aa2efbf7d9 -r 63b69ed765d0 day1/data/location.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/day1/data/location.txt Mon Jan 04 19:09:51 2010 +0530 @@ -0,0 +1,41 @@ +0. 0. +0.25 0.47775 +0.5 0.931 +0.75 1.35975 +1. 1.764 +1.25 2.14375 +1.5 2.499 +1.75 2.82975 +2. 3.136 +2.25 3.41775 +2.5 3.675 +2.75 3.90775 +3. 4.116 +3.25 4.29975 +3.5 4.459 +3.75 4.59375 +4. 4.704 +4.25 4.78975 +4.5 4.851 +4.75 4.88775 +5. 4.9 +5.25 4.88775 +5.5 4.851 +5.75 4.78975 +6. 4.704 +6.25 4.59375 +6.5 4.459 +6.75 4.29975 +7. 4.116 +7.25 3.90775 +7.5 3.675 +7.75 3.41775 +8. 3.136 +8.25 2.82975 +8.5 2.499 +8.75 2.14375 +9. 1.764 +9.25 1.35975 +9.5 0.931 +9.75 0.47775 +10. 0. diff -r 56aa2efbf7d9 -r 63b69ed765d0 day1/data/neighbour.png Binary file day1/data/neighbour.png has changed diff -r 56aa2efbf7d9 -r 63b69ed765d0 day1/data/points.png Binary file day1/data/points.png has changed diff -r 56aa2efbf7d9 -r 63b69ed765d0 day1/data/pos.txt --- a/day1/data/pos.txt Mon Jan 04 19:08:48 2010 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -0. 0. -0.25 0.47775 -0.5 0.931 -0.75 1.35975 -1. 1.764 -1.25 2.14375 -1.5 2.499 -1.75 2.82975 -2. 3.136 -2.25 3.41775 -2.5 3.675 -2.75 3.90775 -3. 4.116 -3.25 4.29975 -3.5 4.459 -3.75 4.59375 -4. 4.704 -4.25 4.78975 -4.5 4.851 -4.75 4.88775 -5. 4.9 -5.25 4.88775 -5.5 4.851 -5.75 4.78975 -6. 4.704 -6.25 4.59375 -6.5 4.459 -6.75 4.29975 -7. 4.116 -7.25 3.90775 -7.5 3.675 -7.75 3.41775 -8. 3.136 -8.25 2.82975 -8.5 2.499 -8.75 2.14375 -9. 1.764 -9.25 1.35975 -9.5 0.931 -9.75 0.47775 -10. 0. diff -r 56aa2efbf7d9 -r 63b69ed765d0 day1/data/smoothing.png Binary file day1/data/smoothing.png has changed diff -r 56aa2efbf7d9 -r 63b69ed765d0 day1/exercises.tex --- a/day1/exercises.tex Mon Jan 04 19:08:48 2010 +0530 +++ b/day1/exercises.tex Mon Jan 04 19:09:51 2010 +0530 @@ -78,7 +78,7 @@ \author[FOSSEE] {FOSSEE} \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} -\date[] {14 December, 2009\\Day 1, Session 5} +\date[] {11 January, 2010\\Day 1, Session 5} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} @@ -111,11 +111,37 @@ \end{frame} +\begin{frame}[fragile] + \frametitle{Problem 1} + \begin{columns} + \column{0.5\textwidth} + \hspace*{-0.5in} + \includegraphics[height=2in, interpolate=true]{data/L-Tsq.png} + \column{0.45\textwidth} + \begin{block}{Example code} + \tiny + \begin{lstlisting} +l = [] +t = [] +for line in open('pendulum.txt'): + point = line.split() + l.append(float(point[0])) + t.append(float(point[1])) +tsq = [] +for time in t: + tsq.append(time*time) +plot(l, tsq, '.') + \end{lstlisting} + \end{block} + \end{columns} + \begin{block}{Problem Statement} + Tweak above code to plot data in file 'location.txt'. + \end{block} +\end{frame} + \begin{frame} - \frametitle{Problem 1} + \frametitle{Problem 1 cont...} \begin{itemize} - \item Open file 'pos.txt', it has X and Y Coordinate of a particle under motion - \item Plot X vs Y Graph. \item Label both the axes. \item What kind of motion is this? \item Title the graph accordingly. @@ -123,13 +149,49 @@ \end{itemize} \end{frame} -\begin{frame} +\begin{frame}[fragile] \frametitle{Problem 2} -Write a Program that plots a regular n-gon(Let n = 5). + \begin{columns} + \column{0.5\textwidth} + \hspace*{-0.5in} + \includegraphics[height=2in, interpolate=true]{data/points} + \column{0.45\textwidth} + \begin{block}{Line between two points} + \tiny + \begin{lstlisting} +In []: x = [1, 5] +In []: y = [1, 4] +In []: plot(x, y) + \end{lstlisting} + \end{block} + \end{columns} + Line can be plotted using arrays of coordinates. + \pause + \begin{block}{Problem statement} + Write a Program that plots a regular n-gon(Let n = 5). + \end{block} +\end{frame} + + +\begin{frame}[fragile] + \frametitle{Problem 3} + \begin{columns} + \column{0.5\textwidth} + \hspace*{-0.5in} + \includegraphics[height=2in, interpolate=true]{data/damp} + \column{0.45\textwidth} + \begin{block}{Damped Oscillation} + \tiny + \begin{lstlisting} +In []: x = linspace(0, 4*pi) +In []: plot(x, exp(x/10)*sin(x)) + \end{lstlisting} + \end{block} + \end{columns} \end{frame} \begin{frame}[fragile] - \frametitle{Problem 3} + \frametitle{Problem 3 cont...} Create a sequence of images in which the damped oscillator($e^{x/10}sin(x)$) slowly evolves over time. \begin{columns} \column{0.35\textwidth} @@ -147,17 +209,71 @@ \end{block} \end{frame} -\begin{frame} +\begin{frame}[fragile] \frametitle{Problem 4} - Legendre polynomials $P_n(x)$ are defined by the following recurrence relation + \begin{lstlisting} +In []: x = imread('smoothing.png') +In []: x.shape +Out[]: (256, 256) +In []: imshow(x,cmap=cm.gray) + \end{lstlisting} +\emphbar{Replace each pixel with mean of neighboring pixels} + \begin{center} + \includegraphics[height=1in, interpolate=true]{data/neighbour} + \end{center} +\end{frame} + +\begin{frame} + \begin{center} + \includegraphics[height=3in, interpolate=true]{data/smoothing} + \end{center} +\end{frame} -\center{$(n+1)P_{n+1}(x) - (2n+1)xP_n(x) + nP_{n-1}(x) = 0$}\\ +\begin{frame}[fragile] + \frametitle{Problem 4: Approach} + For \typ{y} being resultant image: + \begin{lstlisting} +y[1, 1] = x[0, 1]/4 + x[1, 0]/4 + + x[2, 1]/4 + x[1, 2]/4 + \end{lstlisting} + \begin{columns} + \column{0.45\textwidth} + \hspace*{-0.5in} + \includegraphics[height=1.5in, interpolate=true]{data/smoothing} + \column{0.45\textwidth} + \hspace*{-0.5in} + \includegraphics[height=1.5in, interpolate=true]{data/after-filter} + \end{columns} + \begin{block}{Hint:} + Use array Slicing. + \end{block} +\end{frame} -with $P_0(x) = 1$, $P_1(x) = x$ and $P_2(x) = (3x^2 - 1)/2$. Compute the next three - Legendre polynomials and plot all 6 over the interval [-1,1]. +\begin{frame}[fragile] + \frametitle{Solution} + \begin{lstlisting} +In []: y = zeros_like(x) +In []: y[1:-1,1:-1] = x[:-2,1:-1]/4+ + x[2:,1:-1]/4+ + x[1:-1,2:]/4+ + x[1:-1,:-2]/4 +In []: imshow(y,cmap=cm.gray) + \end{lstlisting} \end{frame} + + \end{document} +%% \begin{frame} +%% \frametitle{Problem 4} +%% Legendre polynomials $P_n(x)$ are defined by the following recurrence relation + +%% \center{$(n+1)P_{n+1}(x) - (2n+1)xP_n(x) + nP_{n-1}(x) = 0$}\\ + +%% with $P_0(x) = 1$, $P_1(x) = x$ and $P_2(x) = (3x^2 - 1)/2$. Compute the next three +%% Legendre polynomials and plot all 6 over the interval [-1,1]. +%% \end{frame} + %% \begin{frame}[fragile] %% \frametitle{Problem Set 5} %% \begin{columns}