day1/session6.tex
author Puneeth Chaganti <punchagan@fossee.in>
Thu, 05 Nov 2009 09:21:11 +0530
changeset 270 0ad8566e98ff
parent 266 28d4714a9702
child 271 3f32f679bb45
permissions -rwxr-xr-x
Commented out all finding roots content in session6.
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
240
5a96cf81bdc5 Changed titles of Day1 slides.
Puneeth Chaganti <punchagan@fossee.in>
parents: 239
diff changeset
    76
\title[ODEs \& Root Finding]{Python for Science and Engg:\\ODEs \& Finding Roots}
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}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    81
\date[] {31, October 2009\\Day 1, Session 6}
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
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   126
\section{ODEs}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   127
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   128
\begin{frame}[fragile]
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   129
\frametitle{ODE Integration}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   130
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
   131
\begin{equation*}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   132
\ddot{\theta} = -\frac{g}{L}sin(\theta)
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   133
\end{equation*}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   134
\begin{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   135
\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
   136
\end{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   137
\begin{align}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   138
\dot{\theta} &= \omega \\
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   139
\dot{\omega} &= -\frac{g}{L}sin(\theta) \\
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   140
 \text{At}\ t &= 0 : \nonumber \\
263
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   141
 \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
   142
\end{align}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   143
\end{frame}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   144
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   145
\begin{frame}[fragile]
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   146
\frametitle{Solving ODEs using SciPy}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   147
\begin{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   148
\item We use the \typ{odeint} function from scipy to do the integration
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   149
\item Define a function as below
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   150
\end{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   151
\begin{lstlisting}
263
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   152
In []: def pend_int(initial, t):
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   153
  ....     theta, omega = initial
265
ac31e2f3754e Changes to session1, 5 and 6 at Goa.
Puneeth Chaganti <punchagan@fossee.in>
parents: 258
diff changeset
   154
  ....     g, L = -9.81, 0.2
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   155
  ....     f=[omega, -(g/L)*sin(theta)]
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   156
  ....     return f
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   157
  ....
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   158
\end{lstlisting}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   159
\end{frame}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   160
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   161
\begin{frame}[fragile]
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   162
\frametitle{Solving ODEs using SciPy \ldots}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   163
\begin{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   164
\item \typ{t} is the time variable \\ 
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   165
\item \typ{initial} has the initial values
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   166
\end{itemize}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   167
\begin{lstlisting}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   168
In []: t = linspace(0, 10, 101)
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   169
In []: initial = [10*2*pi/360, 0]
263
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   170
\end{lstlisting} 
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   171
\end{frame}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   172
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   173
\begin{frame}[fragile]
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   174
\frametitle{Solving ODEs using SciPy \ldots}
263
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   175
%%\begin{small}
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   176
\typ{In []: from scipy.integrate import odeint}
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   177
%%\end{small}
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   178
\begin{lstlisting}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   179
In []: pend_sol = odeint(pend_int, 
263
8a4a1e5aec85 Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents: 258
diff changeset
   180
                         initial,t)
221
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   181
\end{lstlisting}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   182
\end{frame}
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   183
9ed9539446bc Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 142
diff changeset
   184
\section{Finding Roots}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   185
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   186
\begin{frame}[fragile]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   187
\frametitle{Roots of $f(x)=0$}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   188
\begin{itemize}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   189
\item Roots --- values of $x$ satisfying $f(x)=0$
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   190
\item $f(x)=0$ may have real or complex roots
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   191
\item Presently, let's look at real roots
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   192
\end{itemize}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   193
\end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   194
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   195
\begin{frame}[fragile]
258
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   196
\frametitle{Roots of $f(x)=0$}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   197
\begin{itemize}
258
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   198
\item Given function $cosx-x^2$ 
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   199
\item First we find \alert{a} root in $(-\pi/2, \pi/2)$
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   200
\item Then we find \alert{all} roots in $(-\pi/2, \pi/2)$
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   201
\end{itemize}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   202
\end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   203
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   204
%% \begin{frame}[fragile]
258
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   205
%% \frametitle{Fixed Point Method}
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   206
%% \begin{enumerate}
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   207
%% \item Convert $f(x)=0$ to the form $x=g(x)$
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   208
%% \item Start with an initial value of $x$ and iterate successively
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   209
%% \item $x_{n+1}=g(x_n)$ and $x_0$ is our initial guess
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   210
%% \item Iterate until $x_{n+1}-x_n \le tolerance$
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   211
%% \end{enumerate}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   212
%% \end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   213
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   214
%% \begin{frame}[fragile]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   215
%% \frametitle{Fixed Point \dots}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   216
%% \begin{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   217
%% In []: def our_g(x):
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   218
%%  ....:     return sqrt(cos(x))
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   219
%%  ....: 
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   220
%% In []: tolerance = 1e-5
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   221
%% In []: while abs(x1-x0)>tolerance:
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   222
%%  ....:     x0 = x1
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   223
%%  ....:     x1 = our_g(x1)
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   224
%%  ....:   
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   225
%% In []: x0
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   226
%% \end{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   227
%% \end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   228
270
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   229
%% \begin{frame}[fragile]
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   230
%% \frametitle{Bisection Method}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   231
%% \begin{enumerate}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   232
%% \item Start with the given interval $(-\pi/2, \pi/2)$ ($(a, b)$)
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   233
%% \item $f(a)\cdot f(b) < 0$
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   234
%% \item Bisect the interval. $c = \frac{a+b}{2}$
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   235
%% \item Change the interval to $(a, c)$ if $f(a)\cdot f(c) < 0$
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   236
%% \item Else, change the interval to $(c, b)$
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   237
%% \item Go back to 3 until $(b-a) \le$ tolerance
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   238
%% \end{enumerate}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   239
%% \alert{\typ{tolerance = 1e-5}}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   240
%% \end{frame}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   241
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   242
%% \begin{frame}[fragile]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   243
%% \frametitle{Bisection \dots}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   244
%% \begin{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   245
%% In []: tolerance = 1e-5
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   246
%% In []: a = -pi/2
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   247
%% In []: b = 0
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   248
%% In []: while b-a > tolerance:
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   249
%%  ....:     c = (a+b)/2
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   250
%%  ....:     if our_f(a)*our_f(c) < 0:
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   251
%%  ....:         b = c
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   252
%%  ....:     else:
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   253
%%  ....:         a = c
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   254
%%  ....:         
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   255
%% \end{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   256
%% \end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   257
270
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   258
%% \begin{frame}[fragile]
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   259
%% \frametitle{Newton-Raphson Method}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   260
%% \begin{enumerate}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   261
%% \item Start with an initial guess of x for the root
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   262
%% \item $\Delta x = -f(x)/f^{'}(x)$
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   263
%% \item $ x \leftarrow x + \Delta x$
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   264
%% \item Go back to 2 until $|\Delta x| \le$ tolerance
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   265
%% \end{enumerate}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   266
%% \end{frame}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   267
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   268
%% \begin{frame}[fragile]
244
f4f3b36a9fba Minor edits to day1 sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 240
diff changeset
   269
%% \frametitle{Newton-Raphson \dots}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   270
%% \begin{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   271
%% In []: def our_df(x):
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   272
%%  ....:     return -sin(x)-2*x
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   273
%%  ....: 
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   274
%% In []: delx = 10*tolerance
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   275
%% In []: while delx > tolerance:
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   276
%%  ....:     delx = -our_f(x)/our_df(x)
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   277
%%  ....:     x = x + delx
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   278
%%  ....:     
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   279
%%  ....:     
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   280
%% \end{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   281
%% \end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   282
258
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   283
%% \begin{frame}[fragile]
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   284
%% \frametitle{Newton-Raphson \ldots}
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   285
%% \begin{itemize}
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   286
%% \item What if $f^{'}(x) = 0$?
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   287
%% \item Can you write a better version of the Newton-Raphson?
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   288
%% \item What if the differential is not easy to calculate?
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   289
%% \item Look at Secant Method
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   290
%% \end{itemize}
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   291
%% \end{frame}
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   292
270
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   293
%% \begin{frame}[fragile]
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   294
%% \frametitle{Initial Estimates}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   295
%% \begin{itemize}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   296
%% \item Given an interval
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   297
%% \item How to find \alert{all} the roots?
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   298
%% \end{itemize}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   299
%% \begin{enumerate}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   300
%% \item Check for change of signs of $f(x)$ in the given interval
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   301
%% \item A root lies in the interval where the sign change occurs
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   302
%% \end{enumerate}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   303
%% \end{frame}
258
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   304
270
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   305
%% \begin{frame}[fragile]
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   306
%% \frametitle{Initial Estimates \ldots}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   307
%% \begin{lstlisting}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   308
%% In []: def our_f(x):
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   309
%%  ....:     return cos(x) - x*x
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   310
%%  ....: 
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   311
%% In []: x = linspace(-pi/2, pi/2, 11)
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   312
%% In []: y = our_f(x)
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   313
%% \end{lstlisting}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   314
%% Get the intervals of x, where sign changes occur
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   315
%% \end{frame}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   316
270
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   317
%% \begin{frame}[fragile]
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   318
%% \frametitle{Initial Estimates \ldots}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   319
%% \begin{lstlisting}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   320
%% In []: pos = y[:-1]*y[1:] < 0
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   321
%% In []: rpos = zeros(x.shape, dtype=bool)
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   322
%% In []: rpos[:-1] = pos
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   323
%% In []: rpos[1:] += pos
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   324
%% In []: rts = x[rpos]
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   325
%% \end{lstlisting}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   326
%% Now use Newton-Raphson?
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   327
%% \end{frame}
258
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   328
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   329
8d5ac98e3247 Improved Day1 Session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 244
diff changeset
   330
\begin{frame}[fragile]
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   331
\frametitle{Scipy Methods - \typ{roots}}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   332
\begin{itemize}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   333
\item Calculates the roots of polynomials
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   334
\end{itemize}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   335
\begin{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   336
  In []: coeffs = [1, 6, 13]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   337
  In []: roots(coeffs)
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   338
\end{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   339
\end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   340
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   341
\begin{frame}[fragile]
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   342
\frametitle{Scipy Methods - \typ{fsolve}}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   343
\begin{small}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   344
\begin{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   345
  In []: from scipy.optimize import fsolve
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   346
\end{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   347
\end{small}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   348
\begin{itemize}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   349
\item Finds the roots of a system of non-linear equations
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   350
\item Input arguments - Function and initial estimate
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   351
\item Returns the solution
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   352
\end{itemize}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   353
\begin{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   354
  In []: fsolve(our_f, -pi/2)
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   355
\end{lstlisting}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   356
\end{frame}
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   357
270
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   358
%% \begin{frame}[fragile]
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   359
%% \frametitle{Scipy Methods \dots}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   360
%% \begin{small}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   361
%% \begin{lstlisting}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   362
%% In []: from scipy.optimize import fixed_point
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   363
270
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   364
%% In []: from scipy.optimize import bisect
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   365
270
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   366
%% In []: from scipy.optimize import newton
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   367
%% \end{lstlisting}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   368
%% \end{small}
0ad8566e98ff Commented out all finding roots content in session6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 266
diff changeset
   369
%% \end{frame}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   370
223
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   371
\begin{frame}
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   372
  \frametitle{Things we have learned}
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   373
  \begin{itemize}
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   374
  \item Solving ODEs
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   375
  \item Finding Roots
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   376
  \end{itemize}
081600805dde Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents: 221
diff changeset
   377
\end{frame}
133
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   378
578db74dfea0 Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
   379
\end{document}