diff options
author | Puneeth Chaganti | 2009-10-28 12:35:01 +0530 |
---|---|---|
committer | Puneeth Chaganti | 2009-10-28 12:35:01 +0530 |
commit | d39c584c384b0e8ebad3df9617db9c61cf9f3334 (patch) | |
tree | e4e5b32c3b120ac3ac80e560ba65fdaf4db3938c /day1/session6.tex | |
parent | b230b3e5a51af3d2db951afa38a84b52f7e4aac7 (diff) | |
download | workshops-d39c584c384b0e8ebad3df9617db9c61cf9f3334.tar.gz workshops-d39c584c384b0e8ebad3df9617db9c61cf9f3334.tar.bz2 workshops-d39c584c384b0e8ebad3df9617db9c61cf9f3334.zip |
Updated day1 session5 and session6.
Diffstat (limited to 'day1/session6.tex')
-rw-r--r-- | day1/session6.tex | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/day1/session6.tex b/day1/session6.tex index 1fed5d3..c929516 100644 --- a/day1/session6.tex +++ b/day1/session6.tex @@ -73,7 +73,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Title page -\title[]{Finding Roots} +\title[]{ODEs \& Finding Roots} \author[FOSSEE] {FOSSEE} @@ -123,6 +123,68 @@ %% % You might wish to add the option [pausesections] %% \end{frame} +\section{ODEs} + +\begin{frame}[fragile] +\frametitle{ODE Integration} +We shall use the simple ODE of a simple pendulum. +\begin{equation*} +\ddot{\theta} = -\frac{g}{L}sin(\theta) +\end{equation*} +\begin{itemize} +\item This equation can be written as a system of two first order ODEs +\end{itemize} +\begin{align} +\dot{\theta} &= \omega \\ +\dot{\omega} &= -\frac{g}{L}sin(\theta) \\ + \text{At}\ t &= 0 : \nonumber \\ + \theta = \theta_0\quad & \&\quad \omega = 0 \nonumber +\end{align} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Solving ODEs using SciPy} +\begin{itemize} +\item We use the \typ{odeint} function from scipy to do the integration +\item Define a function as below +\end{itemize} +\begin{lstlisting} +In []: def pend_int(unknown, t, p): + .... theta, omega = unknown + .... g, L = p + .... f=[omega, -(g/L)*sin(theta)] + .... return f + .... +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Solving ODEs using SciPy \ldots} +\begin{itemize} +\item \typ{t} is the time variable \\ +\item \typ{p} has the constants \\ +\item \typ{initial} has the initial values +\end{itemize} +\begin{lstlisting} +In []: t = linspace(0, 10, 101) +In []: p=(-9.81, 0.2) +In []: initial = [10*2*pi/360, 0] +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Solving ODEs using SciPy \ldots} +\begin{small} + \typ{In []: from scipy.integrate import odeint} +\end{small} +\begin{lstlisting} +In []: pend_sol = odeint(pend_int, + initial,t, + args=(p,)) +\end{lstlisting} +\end{frame} + +\section{Finding Roots} \begin{frame}[fragile] \frametitle{Roots of $f(x)=0$} |