equal
deleted
inserted
replaced
133 \item We shall plot a least squares fit curve for time-period(T) squared vs. length(L) plot of a Simple Pendulum. |
133 \item We shall plot a least squares fit curve for time-period(T) squared vs. length(L) plot of a Simple Pendulum. |
134 \item Given a file containing L and T values |
134 \item Given a file containing L and T values |
135 \end{itemize} |
135 \end{itemize} |
136 \end{frame} |
136 \end{frame} |
137 |
137 |
138 \begin{frame} |
138 \begin{frame}[fragile] |
139 \frametitle{Least Squares Fit \ldots} |
139 \frametitle{Least Squares Fit \ldots} |
140 Machinery Required - |
140 Machinery Required - |
141 \begin{itemize} |
141 \begin{itemize} |
142 \item Reading files and parsing data |
142 \item Reading files and parsing data |
143 \item Plotting points, lines |
143 \item Plotting points, lines |
164 \end{lstlisting} |
164 \end{lstlisting} |
165 We now have two lists L and T |
165 We now have two lists L and T |
166 \end{frame} |
166 \end{frame} |
167 |
167 |
168 \begin{frame}[fragile] |
168 \begin{frame}[fragile] |
169 \frametitle{Calculating T^2} |
169 \frametitle{Calculating $T^2$} |
170 \begin{itemize} |
170 \begin{itemize} |
171 \item Each element of the list T must be squared |
171 \item Each element of the list T must be squared |
172 \item Iterating over each element of the list works |
172 \item Iterating over each element of the list works |
173 \item But very slow \ldots |
173 \item But very slow \ldots |
174 \item Instead, we use arrays |
174 \item Instead, we use arrays |
239 \begin{itemize} |
239 \begin{itemize} |
240 \item Use the poly1d function of pylab, to create a function for the line equation using the coefficients obtained |
240 \item Use the poly1d function of pylab, to create a function for the line equation using the coefficients obtained |
241 \begin{lstlisting} |
241 \begin{lstlisting} |
242 p=poly1d(coeffs) |
242 p=poly1d(coeffs) |
243 \end{lstlisting} |
243 \end{lstlisting} |
244 \item Get new T^2 values using the function \typ{p} obtained |
244 \item Get new $T^2$ values using the function \typ{p} obtained |
245 \begin{lstlisting} |
245 \begin{lstlisting} |
246 Tline = p(L) |
246 Tline = p(L) |
247 \end{lstlisting} |
247 \end{lstlisting} |
248 \item Now plot Tline vs. L, to get the Least squares fit line. |
248 \item Now plot Tline vs. L, to get the Least squares fit line. |
249 \begin{lstlisting} |
249 \begin{lstlisting} |
250 plot(L, Tline) |
250 plot(L, Tline) |
251 \end{lstlisting} |
251 \end{lstlisting} |
|
252 \end{itemize} |
252 \end{frame} |
253 \end{frame} |
253 |
254 |
254 \end{document} |
255 \end{document} |
255 |
256 |
256 Least squares: Smooth curve fit. |
257 Least squares: Smooth curve fit. |