day1/session4.tex
author Puneeth Chaganti <punchagan@fossee.in>
Thu, 09 Dec 2010 22:49:18 +0530
branchscipyin2010
changeset 447 df747c8d70e0
parent 445 956b486ffe6f
child 448 dc8d666a594a
permissions -rw-r--r--
Added least square fit and other minor changes to day1/session4.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141
fccf675946bf Made usage of FOSSEE consistent; removed all instances of Team, Group.
Puneeth Chaganti <punchagan@fossee.in>
parents: 137
diff changeset
     2
%Tutorial slides on Python.
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
%
142
57e0f0fd3317 Made usage of FOSSEE consistent, in comments also.
Puneeth Chaganti <punchagan@fossee.in>
parents: 141
diff changeset
     4
% Author: FOSSEE
57e0f0fd3317 Made usage of FOSSEE consistent, in comments also.
Puneeth Chaganti <punchagan@fossee.in>
parents: 141
diff changeset
     5
% Copyright (c) 2009, FOSSEE, IIT Bombay
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     7
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     8
\documentclass[14pt,compress]{beamer}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     9
%\documentclass[draft]{beamer}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    10
%\documentclass[compress,handout]{beamer}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    11
%\usepackage{pgfpages} 
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    12
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    13
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    14
% Modified from: generic-ornate-15min-45min.de.tex
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    15
\mode<presentation>
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    16
{
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    17
  \usetheme{Warsaw}
239
8953675dc056 Added slide numbers.
Puneeth Chaganti <punchagan@fossee.in>
parents: 223
diff changeset
    18
  \useoutertheme{infolines}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    19
  \setbeamercovered{transparent}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    20
}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    21
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    22
\usepackage[english]{babel}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    23
\usepackage[latin1]{inputenc}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    24
%\usepackage{times}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    25
\usepackage[T1]{fontenc}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    26
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    27
% Taken from Fernando's slides.
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    28
\usepackage{ae,aecompl}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    29
\usepackage{mathpazo,courier,euler}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    30
\usepackage[scaled=.95]{helvet}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    31
\usepackage{amsmath}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    32
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    33
\definecolor{darkgreen}{rgb}{0,0.5,0}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    34
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    35
\usepackage{listings}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    36
\lstset{language=Python,
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    37
    basicstyle=\ttfamily\bfseries,
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    38
    commentstyle=\color{red}\itshape,
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    39
  stringstyle=\color{darkgreen},
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    40
  showstringspaces=false,
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    41
  keywordstyle=\color{blue}\bfseries}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    42
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    43
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    44
% Macros
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    45
\setbeamercolor{emphbar}{bg=blue!20, fg=black}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    46
\newcommand{\emphbar}[1]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    47
{\begin{beamercolorbox}[rounded=true]{emphbar} 
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    48
      {#1}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    49
 \end{beamercolorbox}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    50
}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    51
\newcounter{time}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    52
\setcounter{time}{0}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    53
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    54
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    55
\newcommand{\typ}[1]{\lstinline{#1}}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    56
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    57
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    58
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    59
%%% This is from Fernando's setup.
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    60
% \usepackage{color}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    61
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    62
% % Use and configure listings package for nicely formatted code
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    63
% \usepackage{listings}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    64
% \lstset{
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    65
%    language=Python,
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    66
%    basicstyle=\small\ttfamily,
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    67
%    commentstyle=\ttfamily\color{blue},
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    68
%    stringstyle=\ttfamily\color{orange},
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    69
%    showstringspaces=false,
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    70
%    breaklines=true,
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    71
%    postbreak = \space\dots
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    72
% }
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    73
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    75
% Title page
447
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
    76
\title[Solving Equations \& ODEs]{Python for Science and Engg:\\SciPy}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    77
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    78
\author[FOSSEE] {FOSSEE}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    79
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    80
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
447
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
    81
\date[] {SciPy 2010, Tutorials}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    82
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    83
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    84
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    85
%\logo{\pgfuseimage{iitmlogo}}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    86
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    87
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    88
%% Delete this, if you do not want the table of contents to pop up at
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    89
%% the beginning of each subsection:
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    90
\AtBeginSubsection[]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    91
{
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    92
  \begin{frame}<beamer>
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    93
    \frametitle{Outline}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    94
    \tableofcontents[currentsection,currentsubsection]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    95
  \end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    96
}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    97
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    98
\AtBeginSection[]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    99
{
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   100
  \begin{frame}<beamer>
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   101
    \frametitle{Outline}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   102
    \tableofcontents[currentsection,currentsubsection]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   103
  \end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   104
}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   105
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   106
% If you wish to uncover everything in a step-wise fashion, uncomment
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   107
% the following command: 
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   108
%\beamerdefaultoverlayspecification{<+->}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   109
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   110
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   111
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   112
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   113
% DOCUMENT STARTS
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   114
\begin{document}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   115
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   116
\begin{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   117
  \maketitle
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   118
\end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   119
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   120
%% \begin{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   121
%%   \frametitle{Outline}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   122
%%   \tableofcontents
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   123
%%   % You might wish to add the option [pausesections]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   124
%% \end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   125
447
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   126
\section{Least Squares Fit}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   127
\begin{frame}[fragile]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   128
\frametitle{$L$ vs. $T^2$ - Scatter}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   129
Linear trend visible.
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   130
\vspace{-0.1in}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   131
\begin{figure}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   132
\includegraphics[width=4in]{data/L-Tsq-points}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   133
\end{figure}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   134
\end{frame}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   135
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   136
\begin{frame}[fragile]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   137
\frametitle{$L$ vs. $T^2$ - Line}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   138
This line does not make any mathematical sense.
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   139
\vspace{-0.1in}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   140
\begin{figure}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   141
\includegraphics[width=4in]{data/L-Tsq-Line}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   142
\end{figure}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   143
\end{frame}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   144
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   145
\begin{frame}[fragile]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   146
\frametitle{$L$ vs. $T^2$ - Least Square Fit}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   147
This is what our intention is.
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   148
\vspace{-0.1in}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   149
\begin{figure}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   150
\includegraphics[width=4in]{data/least-sq-fit}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   151
\end{figure}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   152
\end{frame}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   153
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   154
\begin{frame}[fragile]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   155
\frametitle{Matrix Formulation}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   156
\begin{itemize}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   157
\item We need to fit a line through points for the equation $T^2 = m \cdot L+c$
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   158
\item In matrix form, the equation can be represented as $T_{sq} = A \cdot p$, where $T_{sq}$ is
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   159
  $\begin{bmatrix}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   160
  T^2_1 \\
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   161
  T^2_2 \\
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   162
  \vdots\\
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   163
  T^2_N \\
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   164
  \end{bmatrix}$
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   165
, A is   
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   166
  $\begin{bmatrix}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   167
  L_1 & 1 \\
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   168
  L_2 & 1 \\
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   169
  \vdots & \vdots\\
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   170
  L_N & 1 \\
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   171
  \end{bmatrix}$
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   172
  and p is 
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   173
  $\begin{bmatrix}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   174
  m\\
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   175
  c\\
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   176
  \end{bmatrix}$
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   177
\item We need to find $p$ to plot the line
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   178
\end{itemize}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   179
\end{frame}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   180
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   181
\begin{frame}[fragile]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   182
\frametitle{Getting $L$ and $T^2$}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   183
%If you \alert{closed} IPython after session 2
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   184
\begin{lstlisting}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   185
In []: L, T = loadtxt('pendulum.txt', 
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   186
                      unpack=True)
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   187
In []: tsq = T*T
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   188
\end{lstlisting}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   189
\end{frame}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   190
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   191
\begin{frame}[fragile]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   192
\frametitle{Generating $A$}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   193
\begin{lstlisting}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   194
In []: A = array([L, ones_like(L)])
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   195
In []: A = A.T
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   196
\end{lstlisting}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   197
\end{frame}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   198
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   199
\begin{frame}[fragile]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   200
\frametitle{\typ{lstsq} \ldots}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   201
\begin{itemize}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   202
\item Now use the \typ{lstsq} function
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   203
\item Along with a lot of things, it returns the least squares solution
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   204
\end{itemize}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   205
\begin{lstlisting}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   206
In []: result = lstsq(A,tsq)
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   207
In []: coef = result[0]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   208
\end{lstlisting}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   209
\end{frame}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   210
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   211
\begin{frame}[fragile]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   212
\frametitle{Least Square Fit Line \ldots}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   213
We get the points of the line from \typ{coef}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   214
\begin{lstlisting}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   215
In []: Tline = coef[0]*L + coef[1]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   216
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   217
In []: Tline.shape
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   218
\end{lstlisting}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   219
\begin{itemize}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   220
\item Now plot \typ{Tline} vs. \typ{L}, to get the Least squares fit line. 
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   221
\end{itemize}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   222
\begin{lstlisting}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   223
In []: plot(L, Tline, 'r')
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   224
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   225
In []: plot(L, tsq, 'o')
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   226
\end{lstlisting}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   227
\end{frame}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   228
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   229
\begin{frame}[fragile]
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   230
\frametitle{Least Squares Fit}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   231
\vspace{-0.15in}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   232
\begin{figure}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   233
\includegraphics[width=4in]{data/least-sq-fit}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   234
\end{figure}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   235
\end{frame}
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   236
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   237
\section{Solving linear equations}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   238
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   239
\begin{frame}[fragile]
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   240
\frametitle{Solution of equations}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   241
Consider,
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   242
  \begin{align*}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   243
    3x + 2y - z  & = 1 \\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   244
    2x - 2y + 4z  & = -2 \\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   245
    -x + \frac{1}{2}y -z & = 0
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   246
  \end{align*}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   247
Solution:
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   248
  \begin{align*}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   249
    x & = 1 \\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   250
    y & = -2 \\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   251
    z & = -2
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   252
  \end{align*}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   253
\end{frame}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   254
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   255
\begin{frame}[fragile]
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   256
\frametitle{Solving using Matrices}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   257
Let us now look at how to solve this using \kwrd{matrices}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   258
  \begin{lstlisting}
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   259
In []: A = array([[3,2,-1],
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   260
                  [2,-2,4],                   
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   261
                  [-1, 0.5, -1]])
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   262
In []: b = array([1, -2, 0])
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   263
In []: x = solve(A, b)
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   264
  \end{lstlisting}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   265
\end{frame}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   266
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   267
\begin{frame}[fragile]
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   268
\frametitle{Solution:}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   269
\begin{lstlisting}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   270
In []: x
358
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   271
Out[]: array([ 1., -2., -2.])
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   272
\end{lstlisting}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   273
\end{frame}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   274
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   275
\begin{frame}[fragile]
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   276
\frametitle{Let's check!}
385
c70118cdde66 Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 382
diff changeset
   277
\begin{small}
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   278
\begin{lstlisting}
358
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   279
In []: Ax = dot(A, x)
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   280
In []: Ax
358
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   281
Out[]: array([  1.00000000e+00,  -2.00000000e+00,  -1.11022302e-16])
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   282
\end{lstlisting}
385
c70118cdde66 Minor corrections.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 382
diff changeset
   283
\end{small}
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   284
\begin{block}{}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   285
The last term in the matrix is actually \alert{0}!\\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   286
We can use \kwrd{allclose()} to check.
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   287
\end{block}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   288
\begin{lstlisting}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   289
In []: allclose(Ax, b)
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   290
Out[]: True
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   291
\end{lstlisting}
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   292
\inctime{10}
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   293
\end{frame}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   294
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   295
\begin{frame}[fragile]
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   296
\frametitle{Problem}
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   297
Solve the set of equations:
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   298
\begin{align*}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   299
  x + y + 2z -w & = 3\\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   300
  2x + 5y - z - 9w & = -3\\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   301
  2x + y -z + 3w & = -11 \\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   302
  x - 3y + 2z + 7w & = -5\\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   303
\end{align*}
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   304
\inctime{5}
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   305
\end{frame}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   306
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   307
\begin{frame}[fragile]
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   308
\frametitle{Solution}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   309
Use \kwrd{solve()}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   310
\begin{align*}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   311
  x & = -5\\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   312
  y & = 2\\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   313
  z & = 3\\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   314
  w & = 0\\
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   315
\end{align*}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   316
\end{frame}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   317
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   318
\section{Finding Roots}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   319
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   320
\begin{frame}[fragile]
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   321
\frametitle{SciPy: \typ{roots}}
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   322
\begin{itemize}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   323
\item Calculates the roots of polynomials
337
56aa2efbf7d9 Changes at scipy.in
Puneeth Chaganti <punchagan@fossee.in>
parents: 330
diff changeset
   324
\item To calculate the roots of $x^2-5x+6$ 
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   325
\end{itemize}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   326
\begin{lstlisting}
337
56aa2efbf7d9 Changes at scipy.in
Puneeth Chaganti <punchagan@fossee.in>
parents: 330
diff changeset
   327
  In []: coeffs = [1, -5, 6]
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   328
  In []: roots(coeffs)
337
56aa2efbf7d9 Changes at scipy.in
Puneeth Chaganti <punchagan@fossee.in>
parents: 330
diff changeset
   329
  Out[]: array([3., 2.])
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   330
\end{lstlisting}
337
56aa2efbf7d9 Changes at scipy.in
Puneeth Chaganti <punchagan@fossee.in>
parents: 330
diff changeset
   331
\vspace*{-.2in}
56aa2efbf7d9 Changes at scipy.in
Puneeth Chaganti <punchagan@fossee.in>
parents: 330
diff changeset
   332
\begin{center}
56aa2efbf7d9 Changes at scipy.in
Puneeth Chaganti <punchagan@fossee.in>
parents: 330
diff changeset
   333
\includegraphics[height=1.6in, interpolate=true]{data/roots}    
56aa2efbf7d9 Changes at scipy.in
Puneeth Chaganti <punchagan@fossee.in>
parents: 330
diff changeset
   334
\end{center}
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   335
\end{frame}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   336
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   337
\begin{frame}[fragile]
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   338
\frametitle{SciPy: \typ{fsolve}}
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   339
\begin{small}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   340
\begin{lstlisting}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   341
  In []: from scipy.optimize import fsolve
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   342
\end{lstlisting}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   343
\end{small}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   344
\begin{itemize}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   345
\item Finds the roots of a system of non-linear equations
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   346
\item Input arguments - Function and initial estimate
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   347
\item Returns the solution
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   348
\end{itemize}
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   349
\end{frame}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   350
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   351
\begin{frame}[fragile]
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   352
\frametitle{\typ{fsolve}}
382
41c34770d63a Updated sessions of day 1 with the corrections from GRD.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 379
diff changeset
   353
Find the root of $sin(z)+cos^2(z)$ nearest to $0$
358
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   354
\vspace{-0.1in}
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   355
\begin{center}
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   356
\includegraphics[height=2.8in, interpolate=true]{data/fsolve}    
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   357
\end{center}
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   358
\end{frame}
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   359
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   360
\begin{frame}[fragile]
162e3e453920 Added files to be circulated during workshops.
Puneeth Chaganti <punchagan@fossee.in>
parents: 343
diff changeset
   361
\frametitle{\typ{fsolve}}
382
41c34770d63a Updated sessions of day 1 with the corrections from GRD.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 379
diff changeset
   362
Root of $sin(z)+cos^2(z)$ nearest to $0$
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   363
\begin{lstlisting}
382
41c34770d63a Updated sessions of day 1 with the corrections from GRD.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 379
diff changeset
   364
In []: fsolve(sin(z)+cos(z)*cos(z), 0)
41c34770d63a Updated sessions of day 1 with the corrections from GRD.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 379
diff changeset
   365
NameError: name 'z' is not defined
359
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   366
\end{lstlisting}
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   367
\end{frame}
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   368
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   369
\begin{frame}[fragile]
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   370
\frametitle{\typ{fsolve}}
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   371
\begin{lstlisting}
382
41c34770d63a Updated sessions of day 1 with the corrections from GRD.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 379
diff changeset
   372
In []: z = linspace(-pi, pi)
41c34770d63a Updated sessions of day 1 with the corrections from GRD.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 379
diff changeset
   373
In []: fsolve(sin(z)+cos(z)*cos(z), 0)
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   374
\end{lstlisting}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   375
\begin{small}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   376
\alert{\typ{TypeError:}}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   377
\typ{'numpy.ndarray' object is not callable}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   378
\end{small}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   379
\end{frame}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   380
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   381
\begin{frame}[fragile]
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   382
\frametitle{Functions - Definition}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   383
We have been using them all along. Now let's see how to define them.
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   384
\begin{lstlisting}
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   385
In []: def g(z):
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   386
 ....:     return sin(z)+cos(z)*cos(z)
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   387
\end{lstlisting}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   388
\begin{itemize}
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   389
\item \typ{def} -- keyword
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   390
\item name: \typ{g}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   391
\item arguments: \typ{z}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   392
\item \typ{return} -- keyword
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   393
\end{itemize}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   394
\end{frame}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   395
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   396
\begin{frame}[fragile]
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   397
\frametitle{Functions - Calling them}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   398
\begin{lstlisting}
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   399
In []: g()
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   400
---------------------------------------
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   401
\end{lstlisting}
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   402
\alert{\typ{TypeError:}}\typ{g() takes exactly 1 argument}
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   403
\typ{(0 given)}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   404
\begin{lstlisting}
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   405
In []: g(0)
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   406
Out[]: 1.0
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   407
In []: g(1)
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   408
Out[]: 1.1333975665343254
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   409
\end{lstlisting}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   410
More on Functions later \ldots
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   411
\end{frame}
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   412
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   413
\begin{frame}[fragile]
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   414
\frametitle{\typ{fsolve} \ldots}
382
41c34770d63a Updated sessions of day 1 with the corrections from GRD.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 379
diff changeset
   415
Find the root of $sin(z)+cos^2(z)$ nearest to $0$
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   416
\begin{lstlisting}
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   417
In []: fsolve(g, 0)
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   418
Out[]: -0.66623943249251527
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   419
\end{lstlisting}
337
56aa2efbf7d9 Changes at scipy.in
Puneeth Chaganti <punchagan@fossee.in>
parents: 330
diff changeset
   420
\begin{center}
56aa2efbf7d9 Changes at scipy.in
Puneeth Chaganti <punchagan@fossee.in>
parents: 330
diff changeset
   421
\includegraphics[height=2in, interpolate=true]{data/fsolve}    
56aa2efbf7d9 Changes at scipy.in
Puneeth Chaganti <punchagan@fossee.in>
parents: 330
diff changeset
   422
\end{center}
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   423
\end{frame}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   424
379
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   425
\begin{frame}[fragile]
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   426
  \frametitle{Exercise Problem}
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   427
  Find the root of the equation $x^2 - sin(x) + cos^2(x) = tan(x)$ nearest to $0$
379
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   428
\end{frame}
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   429
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   430
\begin{frame}[fragile]
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   431
  \frametitle{Solution}
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   432
  \begin{small}
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   433
  \begin{lstlisting}
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   434
def g(x):
382
41c34770d63a Updated sessions of day 1 with the corrections from GRD.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 379
diff changeset
   435
    return x**2 - sin(x) + cos(x)*cos(x) - tan(x)
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   436
fsolve(g, 0)
379
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   437
  \end{lstlisting}
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   438
  \end{small}
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   439
  \begin{center}
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   440
\includegraphics[height=2in, interpolate=true]{data/fsolve_tanx}
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   441
  \end{center}
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   442
\end{frame}
682b6f66fe11 Updated for day1 of GRD workshop.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 378
diff changeset
   443
273
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   444
%% \begin{frame}[fragile]
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   445
%% \frametitle{Scipy Methods \dots}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   446
%% \begin{small}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   447
%% \begin{lstlisting}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   448
%% In []: from scipy.optimize import fixed_point
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   449
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   450
%% In []: from scipy.optimize import bisect
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   451
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   452
%% In []: from scipy.optimize import newton
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   453
%% \end{lstlisting}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   454
%% \end{small}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   455
%% \end{frame}
c378d1ffb1d1 Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 271
diff changeset
   456
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   457
\section{ODEs}
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   458
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   459
\begin{frame}[fragile]
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   460
\frametitle{Solving ODEs using SciPy}
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   461
\begin{itemize}
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   462
\item Consider the spread of an epidemic in a population
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   463
\item $\frac{dy}{dt} = ky(L-y)$ gives the spread of the disease
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   464
\item $L$ is the total population.
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   465
\item Use $L = 2.5E5, k = 3E-5, y(0) = 250$
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   466
\item Define a function as below
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   467
\end{itemize}
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   468
\begin{lstlisting}
330
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   469
In []: from scipy.integrate import odeint
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   470
In []: def epid(y, t):
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   471
  ....     k = 3.0e-5
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   472
  ....     L = 2.5e5
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   473
  ....     return k*y*(L-y)
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   474
  ....
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   475
\end{lstlisting}
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   476
\end{frame}
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   477
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   478
\begin{frame}[fragile]
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   479
\frametitle{Solving ODEs using SciPy \ldots}
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   480
\begin{lstlisting}
319
cef948318842 Minor edits to sessions 2, 4, 6 on day1.
Puneeth Chaganti <punchagan@fossee.in>
parents: 293
diff changeset
   481
In []: t = linspace(0, 12, 61)
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   482
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   483
In []: y = odeint(epid, 250, t)
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   484
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   485
In []: plot(t, y)
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   486
\end{lstlisting}
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   487
%Insert Plot
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   488
\end{frame}
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   489
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   490
\begin{frame}[fragile]
330
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   491
\frametitle{Result}
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   492
\begin{center}
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   493
\includegraphics[height=2in, interpolate=true]{data/image}  
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   494
\end{center}
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   495
\end{frame}
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   496
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   497
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   498
\begin{frame}[fragile]
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   499
\frametitle{ODEs - Simple Pendulum}
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   500
We shall use the simple ODE of a simple pendulum. 
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   501
\begin{equation*}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   502
\ddot{\theta} = -\frac{g}{L}sin(\theta)
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   503
\end{equation*}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   504
\begin{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   505
\item This equation can be written as a system of two first order ODEs
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   506
\end{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   507
\begin{align}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   508
\dot{\theta} &= \omega \\
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   509
\dot{\omega} &= -\frac{g}{L}sin(\theta) \\
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   510
 \text{At}\ t &= 0 : \nonumber \\
263
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   511
 \theta = \theta_0(10^o)\quad & \&\quad  \omega = 0\ (Initial\ values)\nonumber 
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   512
\end{align}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   513
\end{frame}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   514
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   515
\begin{frame}[fragile]
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   516
\frametitle{ODEs - Simple Pendulum \ldots}
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   517
\begin{itemize}
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   518
\item Use \typ{odeint} to do the integration
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   519
\end{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   520
\begin{lstlisting}
263
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   521
In []: def pend_int(initial, t):
359
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   522
  ....     theta = initial[0]
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   523
  ....     omega = initial[1]
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   524
  ....     g = 9.81
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   525
  ....     L = 0.2
387
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   526
  ....     F=[omega, -(g/L)*sin(theta)]
5e485a5d8ac4 Minor corrections post SVCE.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 385
diff changeset
   527
  ....     return F
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   528
  ....
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   529
\end{lstlisting}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   530
\end{frame}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   531
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   532
\begin{frame}[fragile]
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   533
\frametitle{ODEs - Simple Pendulum \ldots}
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   534
\begin{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   535
\item \typ{t} is the time variable \\ 
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   536
\item \typ{initial} has the initial values
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   537
\end{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   538
\begin{lstlisting}
359
cb17c87b090e Fixed errors found during REC workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 358
diff changeset
   539
In []: t = linspace(0, 20, 101)
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   540
In []: initial = [10*2*pi/360, 0]
263
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   541
\end{lstlisting} 
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   542
\end{frame}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   543
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   544
\begin{frame}[fragile]
293
f7d7b5565232 Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 286
diff changeset
   545
\frametitle{ODEs - Simple Pendulum \ldots}
263
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   546
%%\begin{small}
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   547
\typ{In []: from scipy.integrate import odeint}
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   548
%%\end{small}
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   549
\begin{lstlisting}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   550
In []: pend_sol = odeint(pend_int, 
263
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   551
                         initial,t)
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   552
\end{lstlisting}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   553
\end{frame}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   554
330
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   555
\begin{frame}[fragile]
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   556
\frametitle{Result}
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   557
\begin{center}
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   558
\includegraphics[height=2in, interpolate=true]{data/ode}  
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   559
\end{center}
46533051b9d3 commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents: 319
diff changeset
   560
\end{frame}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   561
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   562
\section{FFTs}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   563
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   564
\begin{frame}[fragile]
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   565
\frametitle{The FFT}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   566
\begin{itemize}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   567
    \item We have a simple signal $y(t)$
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   568
    \item Find the FFT and plot it
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   569
\end{itemize}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   570
\begin{lstlisting}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   571
In []: t = linspace(0, 2*pi, 500)
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   572
In []: y = sin(4*pi*t)
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   573
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   574
In []: f = fft(y)
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   575
In []: freq = fftfreq(500, t[1] - t[0])
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   576
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   577
In []: plot(freq[:250], abs(f)[:250])
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   578
In []: grid()
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   579
\end{lstlisting} 
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   580
\end{frame}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   581
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   582
\begin{frame}[fragile]
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   583
\frametitle{FFTs cont\dots}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   584
\begin{lstlisting}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   585
In []: y1 = ifft(f) # inverse FFT
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   586
In []: allclose(y, y1)
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   587
Out[]: True
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   588
\end{lstlisting} 
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   589
\end{frame}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   590
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   591
\begin{frame}[fragile]
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   592
\frametitle{FFTs cont\dots}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   593
Let us add some noise to the signal
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   594
\begin{lstlisting}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   595
In []: yr = y + random(size=500)*0.2
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   596
In []: yn = y + normal(size=500)*0.2
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   597
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   598
In []: plot(t, yr)
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   599
In []: figure()
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   600
In []: plot(freq[:250],
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   601
  ...:      abs(fft(yn))[:250])
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   602
\end{lstlisting}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   603
\begin{itemize}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   604
    \item \typ{random}: produces uniform deviates in $[0, 1)$
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   605
    \item \typ{normal}: draws random samples from a Gaussian
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   606
        distribution
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   607
    \item Useful to create a random matrix of any shape
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   608
\end{itemize}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   609
\end{frame}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   610
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   611
\begin{frame}[fragile]
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   612
\frametitle{FFTs cont\dots}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   613
Filter the noisy signal:
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   614
\begin{lstlisting}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   615
In []: from scipy import signal
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   616
In []: yc = signal.wiener(yn, 5)
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   617
In []: clf()
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   618
In []: plot(t, yc)
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   619
In []: figure()
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   620
In []: plot(freq[:250], 
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   621
  ...:      abs(fft(yc))[:250])
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   622
\end{lstlisting}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   623
Only scratched the surface here \dots
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   624
\end{frame}
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   625
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   626
223
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   627
\begin{frame}
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   628
  \frametitle{Things we have learned}
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   629
  \begin{itemize}
447
df747c8d70e0 Added least square fit and other minor changes to day1/session4.
Puneeth Chaganti <punchagan@fossee.in>
parents: 445
diff changeset
   630
  \item Least Square Fit
283
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   631
  \item Solving Linear Equations
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   632
  \item Defining Functions
5d7ca20e955f Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 281
diff changeset
   633
  \item Finding Roots
223
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   634
  \item Solving ODEs
417
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   635
  \item Random number generation
caec361e3a86 ENH: Added slides for FFT and basic signal processing, wherein we
Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
parents: 389
diff changeset
   636
  \item FFTs and basic signal processing
223
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   637
  \end{itemize}
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   638
\end{frame}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   639
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   640
\end{document}
343
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   641
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   642
%% Questions for Quiz %%
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   643
%% ------------------ %%
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   644
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   645
\begin{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   646
\frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   647
Given a 4x4 matrix \texttt{A} and a 4-vector \texttt{b}, what command do
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   648
you use to solve for the equation \\
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   649
\texttt{Ax = b}?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   650
\end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   651
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   652
\begin{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   653
\frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   654
What command will you use if you wish to integrate a system of ODEs?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   655
\end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   656
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   657
\begin{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   658
\frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   659
How do you calculate the roots of the polynomial, $y = 1 + 6x + 8x^2 +
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   660
x^3$?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   661
\end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   662
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   663
\begin{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   664
\frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   665
Two arrays \lstinline+a+ and \lstinline+b+ are numerically almost equal, what command
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   666
do you use to check if this is true?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   667
\end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   668
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   669
%% \begin{frame}[fragile]
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   670
%% \frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   671
%% \begin{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   672
%%   In []: x = arange(0, 1, 0.25)
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   673
%%   In []: print x
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   674
%% \end{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   675
%% What will be printed?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   676
%% \end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   677
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   678
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   679
%% \begin{frame}[fragile]
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   680
%% \frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   681
%% \begin{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   682
%% from scipy.integrate import quad
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   683
%% def f(x):
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   684
%%     res = x*cos(x)
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   685
%% quad(f, 0, 1)
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   686
%% \end{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   687
%% What changes will you make to the above code to make it work?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   688
%% \end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   689
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   690
%% \begin{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   691
%% \frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   692
%% What two commands will you use to create and evaluate a spline given
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   693
%% some data?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   694
%% \end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   695
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   696
%% \begin{frame}[fragile]
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   697
%% \frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   698
%% What would be the result?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   699
%% \begin{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   700
%%   In []: x
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   701
%%   array([[0, 1, 2],
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   702
%%          [3, 4, 5],
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   703
%%          [6, 7, 8]])
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   704
%%   In []: x[::-1,:]
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   705
%% \end{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   706
%% Hint:
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   707
%% \begin{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   708
%%   In []: x = arange(9)
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   709
%%   In []: x[::-1]
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   710
%%   array([8, 7, 6, 5, 4, 3, 2, 1, 0])
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   711
%% \end{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   712
%% \end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   713
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   714
%% \begin{frame}[fragile]
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   715
%% \frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   716
%% What would be the result?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   717
%% \begin{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   718
%%   In []: y = arange(3)
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   719
%%   In []: x = linspace(0,3,3)
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   720
%%   In []: x-y
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   721
%% \end{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   722
%% \end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   723
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   724
%% \begin{frame}[fragile]
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   725
%% \frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   726
%% \begin{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   727
%%   In []: x
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   728
%%   array([[ 0, 1, 2, 3],
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   729
%%          [ 4, 5, 6, 7],
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   730
%%          [ 8, 9, 10, 11],
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   731
%%          [12, 13, 14, 15]])
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   732
%% \end{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   733
%% How will you get the following \lstinline+x+?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   734
%% \begin{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   735
%%   array([[ 5, 7],
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   736
%%          [ 9, 11]])
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   737
%% \end{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   738
%% \end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   739
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   740
%% \begin{frame}[fragile]
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   741
%% \frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   742
%% What would be the output?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   743
%% \begin{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   744
%%   In []: y = arange(4)
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   745
%%   In []: x = array(([1,2,3,2],[1,3,6,0]))
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   746
%%   In []: x + y
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   747
%% \end{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   748
%% \end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   749
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   750
%% \begin{frame}[fragile]
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   751
%% \frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   752
%% \begin{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   753
%%   In []: line = plot(x, sin(x))
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   754
%% \end{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   755
%% Use the \lstinline+set_linewidth+ method to set width of \lstinline+line+ to 2.
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   756
%% \end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   757
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   758
%% \begin{frame}[fragile]
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   759
%% \frametitle{\incqno }
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   760
%% What would be the output?
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   761
%% \begin{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   762
%%   In []: x = arange(9)
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   763
%%   In []: y = arange(9.)
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   764
%%   In []: x == y
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   765
%% \end{lstlisting}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   766
%% \end{frame}
adb85e126341 Moved all day1 quiz questions to end of day1-sessions.
Puneeth Chaganti <punchagan@fossee.in>
parents: 339
diff changeset
   767