author | Shantanu <shantanu@fossee.in> |
Tue, 22 Dec 2009 14:10:37 +0530 | |
changeset 330 | 46533051b9d3 |
parent 319 | cef948318842 |
child 337 | 56aa2efbf7d9 |
permissions | -rwxr-xr-x |
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 |
273
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
76 |
\title[Solving Equations \& ODEs]{Python for Science and Engg:\\Solving Equations \& ODEs} |
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} |
330
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
81 |
\date[] {14 December, 2009\\Day 1, Session 6} |
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 |
|
273
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
126 |
\section{Solving linear equations} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
127 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
128 |
\begin{frame}[fragile] |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
129 |
\frametitle{Solution of equations} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
130 |
Consider, |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
131 |
\begin{align*} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
132 |
3x + 2y - z & = 1 \\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
133 |
2x - 2y + 4z & = -2 \\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
134 |
-x + \frac{1}{2}y -z & = 0 |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
135 |
\end{align*} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
136 |
Solution: |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
137 |
\begin{align*} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
138 |
x & = 1 \\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
139 |
y & = -2 \\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
140 |
z & = -2 |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
141 |
\end{align*} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
142 |
\end{frame} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
143 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
144 |
\begin{frame}[fragile] |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
145 |
\frametitle{Solving using Matrices} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
146 |
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
|
147 |
\begin{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
148 |
In []: A = array([[3,2,-1], |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
149 |
[2,-2,4], |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
150 |
[-1, 0.5, -1]]) |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
151 |
In []: b = array([[1], [-2], [0]]) |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
152 |
In []: x = solve(A, b) |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
153 |
\end{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
154 |
\end{frame} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
155 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
156 |
\begin{frame}[fragile] |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
157 |
\frametitle{Solution:} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
158 |
\begin{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
159 |
In []: x |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
160 |
Out[]: |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
161 |
array([[ 1.], |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
162 |
[-2.], |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
163 |
[-2.]]) |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
164 |
\end{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
165 |
\end{frame} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
166 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
167 |
\begin{frame}[fragile] |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
168 |
\frametitle{Let's check!} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
169 |
\begin{lstlisting} |
330
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
170 |
In []: Ax = dot(A,x) |
273
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
171 |
In []: Ax |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
172 |
Out[]: |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
173 |
array([[ 1.00000000e+00], |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
174 |
[ -2.00000000e+00], |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
175 |
[ 2.22044605e-16]]) |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
176 |
\end{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
177 |
\begin{block}{} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
178 |
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
|
179 |
We can use \kwrd{allclose()} to check. |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
180 |
\end{block} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
181 |
\begin{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
182 |
In []: allclose(Ax, b) |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
183 |
Out[]: True |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
184 |
\end{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
185 |
\inctime{15} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
186 |
\end{frame} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
187 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
188 |
\subsection{Exercises} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
189 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
190 |
\begin{frame}[fragile] |
293
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
191 |
\frametitle{Problem} |
273
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
192 |
Solve the set of equations: |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
193 |
\begin{align*} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
194 |
x + y + 2z -w & = 3\\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
195 |
2x + 5y - z - 9w & = -3\\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
196 |
2x + y -z + 3w & = -11 \\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
197 |
x - 3y + 2z + 7w & = -5\\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
198 |
\end{align*} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
199 |
\inctime{10} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
200 |
\end{frame} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
201 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
202 |
\begin{frame}[fragile] |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
203 |
\frametitle{Solution} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
204 |
Use \kwrd{solve()} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
205 |
\begin{align*} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
206 |
x & = -5\\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
207 |
y & = 2\\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
208 |
z & = 3\\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
209 |
w & = 0\\ |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
210 |
\end{align*} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
211 |
\end{frame} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
212 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
213 |
\section{Finding Roots} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
214 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
215 |
\begin{frame}[fragile] |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
216 |
\frametitle{Scipy Methods - \typ{roots}} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
217 |
\begin{itemize} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
218 |
\item Calculates the roots of polynomials |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
219 |
\end{itemize} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
220 |
\begin{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
221 |
In []: coeffs = [1, 6, 13] |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
222 |
In []: roots(coeffs) |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
223 |
\end{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
224 |
\end{frame} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
225 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
226 |
\begin{frame}[fragile] |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
227 |
\frametitle{Scipy Methods - \typ{fsolve}} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
228 |
\begin{small} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
229 |
\begin{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
230 |
In []: from scipy.optimize import fsolve |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
231 |
\end{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
232 |
\end{small} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
233 |
\begin{itemize} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
234 |
\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
|
235 |
\item Input arguments - Function and initial estimate |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
236 |
\item Returns the solution |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
237 |
\end{itemize} |
283
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
238 |
\end{frame} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
239 |
|
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
240 |
\begin{frame}[fragile] |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
241 |
\frametitle{\typ{fsolve}} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
242 |
Find the root of $sin(x)+cos^2(x)$ nearest to $0$ |
273
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
243 |
\begin{lstlisting} |
283
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
244 |
In []: fsolve(sin(x)+cos(x)**2, 0) |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
245 |
NameError: name 'x' is not defined |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
246 |
In []: x = linspace(-pi, pi) |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
247 |
In []: fsolve(sin(x)+cos(x)**2, 0) |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
248 |
\end{lstlisting} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
249 |
\begin{small} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
250 |
\alert{\typ{TypeError:}} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
251 |
\typ{'numpy.ndarray' object is not callable} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
252 |
\end{small} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
253 |
\end{frame} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
254 |
|
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
255 |
\begin{frame}[fragile] |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
256 |
\frametitle{Functions - Definition} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
257 |
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
|
258 |
\begin{lstlisting} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
259 |
In []: def f(x): |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
260 |
return sin(x)+cos(x)**2 |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
261 |
\end{lstlisting} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
262 |
\begin{itemize} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
263 |
\item \typ{def} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
264 |
\item name |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
265 |
\item arguments |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
266 |
\item \typ{return} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
267 |
\end{itemize} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
268 |
\end{frame} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
269 |
|
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
270 |
\begin{frame}[fragile] |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
271 |
\frametitle{Functions - Calling them} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
272 |
\begin{lstlisting} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
273 |
In [15]: f() |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
274 |
--------------------------------------- |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
275 |
\end{lstlisting} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
276 |
\alert{\typ{TypeError:}}\typ{f() takes exactly 1 argument} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
277 |
\typ{(0 given)} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
278 |
\begin{lstlisting} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
279 |
In []: f(0) |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
280 |
Out[]: 1.0 |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
281 |
In []: f(1) |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
282 |
Out[]: 1.1333975665343254 |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
283 |
\end{lstlisting} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
284 |
More on Functions later \ldots |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
285 |
\end{frame} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
286 |
|
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
287 |
\begin{frame}[fragile] |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
288 |
\frametitle{\typ{fsolve} \ldots} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
289 |
Find the root of $sin(x)+cos^2(x)$ nearest to $0$ |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
290 |
\begin{lstlisting} |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
291 |
In []: fsolve(f, 0) |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
292 |
Out[]: -0.66623943249251527 |
273
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
293 |
\end{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
294 |
\end{frame} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
295 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
296 |
%% \begin{frame}[fragile] |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
297 |
%% \frametitle{Scipy Methods \dots} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
298 |
%% \begin{small} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
299 |
%% \begin{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
300 |
%% In []: from scipy.optimize import fixed_point |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
301 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
302 |
%% In []: from scipy.optimize import bisect |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
303 |
|
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
304 |
%% In []: from scipy.optimize import newton |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
305 |
%% \end{lstlisting} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
306 |
%% \end{small} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
307 |
%% \end{frame} |
c378d1ffb1d1
Moved Solving Linear Equations to session 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
271
diff
changeset
|
308 |
|
221
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
309 |
\section{ODEs} |
293
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
310 |
|
221
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
311 |
\begin{frame}[fragile] |
293
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
312 |
\frametitle{Solving ODEs using SciPy} |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
313 |
\begin{itemize} |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
314 |
\item Let's consider the spread of an epidemic in a population |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
315 |
\item $\frac{dy}{dt} = ky(L-y)$ gives the spread of the disease |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
316 |
\item L is the total population. |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
317 |
\item Use L = 25000, k = 0.00003, y(0) = 250 |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
318 |
\item Define a function as below |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
319 |
\end{itemize} |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
320 |
\begin{lstlisting} |
330
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
321 |
In []: from scipy.integrate import odeint |
293
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
322 |
In []: def epid(y, t): |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
323 |
.... k, L = 0.00003, 25000 |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
324 |
.... return k*y*(L-y) |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
325 |
.... |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
326 |
\end{lstlisting} |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
327 |
\end{frame} |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
328 |
|
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
329 |
\begin{frame}[fragile] |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
330 |
\frametitle{Solving ODEs using SciPy \ldots} |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
331 |
\begin{lstlisting} |
319
cef948318842
Minor edits to sessions 2, 4, 6 on day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
293
diff
changeset
|
332 |
In []: t = linspace(0, 12, 61) |
293
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
333 |
|
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
334 |
In []: y = odeint(epid, 250, t) |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
335 |
|
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
336 |
In []: plot(t, y) |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
337 |
\end{lstlisting} |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
338 |
%Insert Plot |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
339 |
\end{frame} |
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
340 |
|
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
341 |
\begin{frame}[fragile] |
330
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
342 |
\frametitle{Result} |
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
343 |
\begin{center} |
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
344 |
\includegraphics[height=2in, interpolate=true]{data/image} |
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
345 |
\end{center} |
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
346 |
\end{frame} |
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
347 |
|
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
348 |
|
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
349 |
\begin{frame}[fragile] |
293
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
350 |
\frametitle{ODEs - Simple Pendulum} |
221
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
351 |
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
|
352 |
\begin{equation*} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
353 |
\ddot{\theta} = -\frac{g}{L}sin(\theta) |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
354 |
\end{equation*} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
355 |
\begin{itemize} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
356 |
\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
|
357 |
\end{itemize} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
358 |
\begin{align} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
359 |
\dot{\theta} &= \omega \\ |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
360 |
\dot{\omega} &= -\frac{g}{L}sin(\theta) \\ |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
361 |
\text{At}\ t &= 0 : \nonumber \\ |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
258
diff
changeset
|
362 |
\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
|
363 |
\end{align} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
364 |
\end{frame} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
365 |
|
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
366 |
\begin{frame}[fragile] |
293
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
367 |
\frametitle{ODEs - Simple Pendulum \ldots} |
221
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
368 |
\begin{itemize} |
293
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
369 |
\item Use \typ{odeint} to do the integration |
221
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
370 |
\end{itemize} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
371 |
\begin{lstlisting} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
258
diff
changeset
|
372 |
In []: def pend_int(initial, t): |
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
258
diff
changeset
|
373 |
.... theta, omega = initial |
280
9bed85f05eb8
Added save command in session1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
273
diff
changeset
|
374 |
.... g, L = 9.81, 0.2 |
221
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
375 |
.... f=[omega, -(g/L)*sin(theta)] |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
376 |
.... return f |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
377 |
.... |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
378 |
\end{lstlisting} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
379 |
\end{frame} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
380 |
|
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
381 |
\begin{frame}[fragile] |
293
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
382 |
\frametitle{ODEs - Simple Pendulum \ldots} |
221
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
383 |
\begin{itemize} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
384 |
\item \typ{t} is the time variable \\ |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
385 |
\item \typ{initial} has the initial values |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
386 |
\end{itemize} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
387 |
\begin{lstlisting} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
388 |
In []: t = linspace(0, 10, 101) |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
389 |
In []: initial = [10*2*pi/360, 0] |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
258
diff
changeset
|
390 |
\end{lstlisting} |
221
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
391 |
\end{frame} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
392 |
|
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
393 |
\begin{frame}[fragile] |
293
f7d7b5565232
Added another ODE example to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
286
diff
changeset
|
394 |
\frametitle{ODEs - Simple Pendulum \ldots} |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
258
diff
changeset
|
395 |
%%\begin{small} |
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
258
diff
changeset
|
396 |
\typ{In []: from scipy.integrate import odeint} |
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
258
diff
changeset
|
397 |
%%\end{small} |
221
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
398 |
\begin{lstlisting} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
399 |
In []: pend_sol = odeint(pend_int, |
263
8a4a1e5aec85
Changes made for Goa workshop .
Shantanu <shantanu@fossee.in>
parents:
258
diff
changeset
|
400 |
initial,t) |
221
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
401 |
\end{lstlisting} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
402 |
\end{frame} |
9ed9539446bc
Updated day1 session5 and session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
142
diff
changeset
|
403 |
|
330
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
404 |
\begin{frame}[fragile] |
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
405 |
\frametitle{Result} |
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
406 |
\begin{center} |
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
407 |
\includegraphics[height=2in, interpolate=true]{data/ode} |
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
408 |
\end{center} |
46533051b9d3
commited changes made for scipy and cheatsheats.
Shantanu <shantanu@fossee.in>
parents:
319
diff
changeset
|
409 |
\end{frame} |
133
578db74dfea0
Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
410 |
|
223
081600805dde
Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
221
diff
changeset
|
411 |
\begin{frame} |
081600805dde
Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
221
diff
changeset
|
412 |
\frametitle{Things we have learned} |
081600805dde
Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
221
diff
changeset
|
413 |
\begin{itemize} |
283
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
414 |
\item Solving Linear Equations |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
415 |
\item Defining Functions |
5d7ca20e955f
Added functions to session6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
281
diff
changeset
|
416 |
\item Finding Roots |
223
081600805dde
Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
221
diff
changeset
|
417 |
\item Solving ODEs |
081600805dde
Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
221
diff
changeset
|
418 |
\end{itemize} |
081600805dde
Minor edits to sessions 5 and 6.
Puneeth Chaganti <punchagan@fossee.in>
parents:
221
diff
changeset
|
419 |
\end{frame} |
133
578db74dfea0
Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
420 |
|
578db74dfea0
Added Day1 Session6 - Finding Roots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
421 |
\end{document} |