From 3e13b7024c7bc4a754fc2abe7267e9f0fe31fc59 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Wed, 4 Nov 2009 09:33:37 +0530 Subject: Changes to session1, 5 and 6 at Goa. --- day1/session6.tex | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) mode change 100644 => 100755 day1/session6.tex (limited to 'day1/session6.tex') diff --git a/day1/session6.tex b/day1/session6.tex old mode 100644 new mode 100755 index 0b5f681..06e2eb0 --- a/day1/session6.tex +++ b/day1/session6.tex @@ -138,7 +138,7 @@ We shall use the simple ODE of a simple pendulum. \dot{\theta} &= \omega \\ \dot{\omega} &= -\frac{g}{L}sin(\theta) \\ \text{At}\ t &= 0 : \nonumber \\ - \theta = \theta_0\quad & \&\quad \omega = 0 \nonumber + \theta = \theta_0(10^o)\quad & \&\quad \omega = 0\ (Initial\ values)\nonumber \end{align} \end{frame} @@ -149,9 +149,9 @@ We shall use the simple ODE of a simple pendulum. \item Define a function as below \end{itemize} \begin{lstlisting} -In []: def pend_int(unknown, t, p): - .... theta, omega = unknown - .... g, L = p +In []: def pend_int(initial, t): + .... theta, omega = initial + .... g, L = -9.81, 0.2 .... f=[omega, -(g/L)*sin(theta)] .... return f .... @@ -162,25 +162,22 @@ In []: def pend_int(unknown, t, p): \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{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{Solving ODEs using SciPy \ldots} -\begin{small} - \typ{In []: from scipy.integrate import odeint} -\end{small} +%%\begin{small} +\typ{In []: from scipy.integrate import odeint} +%%\end{small} \begin{lstlisting} In []: pend_sol = odeint(pend_int, - initial,t, - args=(p,)) + initial,t) \end{lstlisting} \end{frame} @@ -308,14 +305,13 @@ In []: pend_sol = odeint(pend_int, \begin{frame}[fragile] \frametitle{Initial Estimates \ldots} \begin{lstlisting} - In []: def our_f(x): - ....: return cos(x)-x**2 - ....: - In []: x = linspace(-pi/2, pi/2, 11) +In []: def our_f(x): + ....: return cos(x) - x*x + ....: +In []: x = linspace(-pi/2, pi/2, 11) +In []: y = our_f(x) \end{lstlisting} -\begin{itemize} -\item Get the intervals of x, where sign changes occur -\end{itemize} +Get the intervals of x, where sign changes occur \end{frame} \begin{frame}[fragile] @@ -335,7 +331,6 @@ Now use Newton-Raphson? \frametitle{Scipy Methods - \typ{roots}} \begin{itemize} \item Calculates the roots of polynomials -\item Array of coefficients is the only parameter \end{itemize} \begin{lstlisting} In []: coeffs = [1, 6, 13] -- cgit