day1/session6.tex
changeset 221 9ed9539446bc
parent 142 57e0f0fd3317
child 223 081600805dde
equal deleted inserted replaced
214:19592f802dde 221:9ed9539446bc
    71 %    postbreak = \space\dots
    71 %    postbreak = \space\dots
    72 % }
    72 % }
    73 
    73 
    74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    75 % Title page
    75 % Title page
    76 \title[]{Finding Roots}
    76 \title[]{ODEs \& Finding Roots}
    77 
    77 
    78 \author[FOSSEE] {FOSSEE}
    78 \author[FOSSEE] {FOSSEE}
    79 
    79 
    80 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
    80 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
    81 \date[] {31, October 2009\\Day 1, Session 6}
    81 \date[] {31, October 2009\\Day 1, Session 6}
   121 %%   \frametitle{Outline}
   121 %%   \frametitle{Outline}
   122 %%   \tableofcontents
   122 %%   \tableofcontents
   123 %%   % You might wish to add the option [pausesections]
   123 %%   % You might wish to add the option [pausesections]
   124 %% \end{frame}
   124 %% \end{frame}
   125 
   125 
       
   126 \section{ODEs}
       
   127 
       
   128 \begin{frame}[fragile]
       
   129 \frametitle{ODE Integration}
       
   130 We shall use the simple ODE of a simple pendulum. 
       
   131 \begin{equation*}
       
   132 \ddot{\theta} = -\frac{g}{L}sin(\theta)
       
   133 \end{equation*}
       
   134 \begin{itemize}
       
   135 \item This equation can be written as a system of two first order ODEs
       
   136 \end{itemize}
       
   137 \begin{align}
       
   138 \dot{\theta} &= \omega \\
       
   139 \dot{\omega} &= -\frac{g}{L}sin(\theta) \\
       
   140  \text{At}\ t &= 0 : \nonumber \\
       
   141  \theta = \theta_0\quad & \&\quad  \omega = 0 \nonumber
       
   142 \end{align}
       
   143 \end{frame}
       
   144 
       
   145 \begin{frame}[fragile]
       
   146 \frametitle{Solving ODEs using SciPy}
       
   147 \begin{itemize}
       
   148 \item We use the \typ{odeint} function from scipy to do the integration
       
   149 \item Define a function as below
       
   150 \end{itemize}
       
   151 \begin{lstlisting}
       
   152 In []: def pend_int(unknown, t, p):
       
   153   ....     theta, omega = unknown
       
   154   ....     g, L = p
       
   155   ....     f=[omega, -(g/L)*sin(theta)]
       
   156   ....     return f
       
   157   ....
       
   158 \end{lstlisting}
       
   159 \end{frame}
       
   160 
       
   161 \begin{frame}[fragile]
       
   162 \frametitle{Solving ODEs using SciPy \ldots}
       
   163 \begin{itemize}
       
   164 \item \typ{t} is the time variable \\ 
       
   165 \item \typ{p} has the constants \\
       
   166 \item \typ{initial} has the initial values
       
   167 \end{itemize}
       
   168 \begin{lstlisting}
       
   169 In []: t = linspace(0, 10, 101)
       
   170 In []: p=(-9.81, 0.2)
       
   171 In []: initial = [10*2*pi/360, 0]
       
   172 \end{lstlisting}
       
   173 \end{frame}
       
   174 
       
   175 \begin{frame}[fragile]
       
   176 \frametitle{Solving ODEs using SciPy \ldots}
       
   177 \begin{small}
       
   178   \typ{In []: from scipy.integrate import odeint}
       
   179 \end{small}
       
   180 \begin{lstlisting}
       
   181 In []: pend_sol = odeint(pend_int, 
       
   182                          initial,t, 
       
   183                          args=(p,))
       
   184 \end{lstlisting}
       
   185 \end{frame}
       
   186 
       
   187 \section{Finding Roots}
   126 
   188 
   127 \begin{frame}[fragile]
   189 \begin{frame}[fragile]
   128 \frametitle{Roots of $f(x)=0$}
   190 \frametitle{Roots of $f(x)=0$}
   129 \begin{itemize}
   191 \begin{itemize}
   130 \item Roots --- values of $x$ satisfying $f(x)=0$
   192 \item Roots --- values of $x$ satisfying $f(x)=0$