diff options
Diffstat (limited to 'day1/session6.tex')
-rw-r--r-- | day1/session6.tex | 85 |
1 files changed, 80 insertions, 5 deletions
diff --git a/day1/session6.tex b/day1/session6.tex index 1fed5d3..9ee3215 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$} @@ -136,8 +198,8 @@ \begin{frame}[fragile] \frametitle{Initial Estimates} \begin{itemize} -\item Find the roots of $cosx-x^2$ between $-\pi/2$ and $\pi/2$ -\item We shall use a crude method to get an initial estimate first +\item Find roots of $cosx-x^2$ in $(-\pi/2, \pi/2)$ +\item How to get a rough initial estimate? \end{itemize} \begin{enumerate} \item Check for change of signs of $f(x)$ in the given interval @@ -288,15 +350,28 @@ \begin{frame}[fragile] \frametitle{Scipy Methods \dots} -\small{ +\begin{small} \begin{lstlisting} In []: from scipy.optimize import fixed_point In []: from scipy.optimize import bisect In []: from scipy.optimize import newton -\end{lstlisting}} +\end{lstlisting} +\end{small} \end{frame} +\begin{frame} + \frametitle{Things we have learned} + \begin{itemize} + \item Solving ODEs + \item Finding Roots + \begin{itemize} + \item Estimating Interval + \item Newton Raphson + \item Scipy methods + \end{itemize} + \end{itemize} +\end{frame} \end{document} |