Retained only fsolve and roots in finding roots, session6.
authorPuneeth Chaganti <punchagan@fossee.in>
Thu, 05 Nov 2009 09:22:27 +0530
changeset 271 3f32f679bb45
parent 270 0ad8566e98ff
child 272 e5fc37a9ca96
Retained only fsolve and roots in finding roots, session6.
day1/session6.tex
--- a/day1/session6.tex	Thu Nov 05 09:21:11 2009 +0530
+++ b/day1/session6.tex	Thu Nov 05 09:22:27 2009 +0530
@@ -184,150 +184,6 @@
 \section{Finding Roots}
 
 \begin{frame}[fragile]
-\frametitle{Roots of $f(x)=0$}
-\begin{itemize}
-\item Roots --- values of $x$ satisfying $f(x)=0$
-\item $f(x)=0$ may have real or complex roots
-\item Presently, let's look at real roots
-\end{itemize}
-\end{frame}
-
-\begin{frame}[fragile]
-\frametitle{Roots of $f(x)=0$}
-\begin{itemize}
-\item Given function $cosx-x^2$ 
-\item First we find \alert{a} root in $(-\pi/2, \pi/2)$
-\item Then we find \alert{all} roots in $(-\pi/2, \pi/2)$
-\end{itemize}
-\end{frame}
-
-%% \begin{frame}[fragile]
-%% \frametitle{Fixed Point Method}
-%% \begin{enumerate}
-%% \item Convert $f(x)=0$ to the form $x=g(x)$
-%% \item Start with an initial value of $x$ and iterate successively
-%% \item $x_{n+1}=g(x_n)$ and $x_0$ is our initial guess
-%% \item Iterate until $x_{n+1}-x_n \le tolerance$
-%% \end{enumerate}
-%% \end{frame}
-
-%% \begin{frame}[fragile]
-%% \frametitle{Fixed Point \dots}
-%% \begin{lstlisting}
-%% In []: def our_g(x):
-%%  ....:     return sqrt(cos(x))
-%%  ....: 
-%% In []: tolerance = 1e-5
-%% In []: while abs(x1-x0)>tolerance:
-%%  ....:     x0 = x1
-%%  ....:     x1 = our_g(x1)
-%%  ....:   
-%% In []: x0
-%% \end{lstlisting}
-%% \end{frame}
-
-%% \begin{frame}[fragile]
-%% \frametitle{Bisection Method}
-%% \begin{enumerate}
-%% \item Start with the given interval $(-\pi/2, \pi/2)$ ($(a, b)$)
-%% \item $f(a)\cdot f(b) < 0$
-%% \item Bisect the interval. $c = \frac{a+b}{2}$
-%% \item Change the interval to $(a, c)$ if $f(a)\cdot f(c) < 0$
-%% \item Else, change the interval to $(c, b)$
-%% \item Go back to 3 until $(b-a) \le$ tolerance
-%% \end{enumerate}
-%% \alert{\typ{tolerance = 1e-5}}
-%% \end{frame}
-
-%% \begin{frame}[fragile]
-%% \frametitle{Bisection \dots}
-%% \begin{lstlisting}
-%% In []: tolerance = 1e-5
-%% In []: a = -pi/2
-%% In []: b = 0
-%% In []: while b-a > tolerance:
-%%  ....:     c = (a+b)/2
-%%  ....:     if our_f(a)*our_f(c) < 0:
-%%  ....:         b = c
-%%  ....:     else:
-%%  ....:         a = c
-%%  ....:         
-%% \end{lstlisting}
-%% \end{frame}
-
-%% \begin{frame}[fragile]
-%% \frametitle{Newton-Raphson Method}
-%% \begin{enumerate}
-%% \item Start with an initial guess of x for the root
-%% \item $\Delta x = -f(x)/f^{'}(x)$
-%% \item $ x \leftarrow x + \Delta x$
-%% \item Go back to 2 until $|\Delta x| \le$ tolerance
-%% \end{enumerate}
-%% \end{frame}
-
-%% \begin{frame}[fragile]
-%% \frametitle{Newton-Raphson \dots}
-%% \begin{lstlisting}
-%% In []: def our_df(x):
-%%  ....:     return -sin(x)-2*x
-%%  ....: 
-%% In []: delx = 10*tolerance
-%% In []: while delx > tolerance:
-%%  ....:     delx = -our_f(x)/our_df(x)
-%%  ....:     x = x + delx
-%%  ....:     
-%%  ....:     
-%% \end{lstlisting}
-%% \end{frame}
-
-%% \begin{frame}[fragile]
-%% \frametitle{Newton-Raphson \ldots}
-%% \begin{itemize}
-%% \item What if $f^{'}(x) = 0$?
-%% \item Can you write a better version of the Newton-Raphson?
-%% \item What if the differential is not easy to calculate?
-%% \item Look at Secant Method
-%% \end{itemize}
-%% \end{frame}
-
-%% \begin{frame}[fragile]
-%% \frametitle{Initial Estimates}
-%% \begin{itemize}
-%% \item Given an interval
-%% \item How to find \alert{all} the roots?
-%% \end{itemize}
-%% \begin{enumerate}
-%% \item Check for change of signs of $f(x)$ in the given interval
-%% \item A root lies in the interval where the sign change occurs
-%% \end{enumerate}
-%% \end{frame}
-
-%% \begin{frame}[fragile]
-%% \frametitle{Initial Estimates \ldots}
-%% \begin{lstlisting}
-%% 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}
-%% Get the intervals of x, where sign changes occur
-%% \end{frame}
-
-%% \begin{frame}[fragile]
-%% \frametitle{Initial Estimates \ldots}
-%% \begin{lstlisting}
-%% In []: pos = y[:-1]*y[1:] < 0
-%% In []: rpos = zeros(x.shape, dtype=bool)
-%% In []: rpos[:-1] = pos
-%% In []: rpos[1:] += pos
-%% In []: rts = x[rpos]
-%% \end{lstlisting}
-%% Now use Newton-Raphson?
-%% \end{frame}
-
-
-\begin{frame}[fragile]
 \frametitle{Scipy Methods - \typ{roots}}
 \begin{itemize}
 \item Calculates the roots of polynomials