Menu

[r5337]: / trunk / py4science / workbook / quad_newton.lyx  Maximize  Restore  History

Download this file

152 lines (112 with data), 2.6 kB

#LyX 1.4.3 created this file. For more info see http://www.lyx.org/
\lyxformat 245
\begin_document
\begin_header
\textclass amsbook
\begin_preamble
\input{preamble.tex}
\end_preamble
\language english
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize default
\spacing single
\papersize default
\use_geometry true
\use_amsmath 1
\cite_engine basic
\use_bibtopic false
\paperorientation portrait
\leftmargin 1.3in
\topmargin 1in
\rightmargin 1.3in
\bottommargin 1in
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\papercolumns 1
\papersides 2
\paperpagestyle default
\tracking_changes false
\output_changes false
\end_header

\begin_body

\begin_layout Section
Newton's method
\end_layout

\begin_layout Standard
Consider the problem of solving for 
\begin_inset Formula $t$
\end_inset

 in
\begin_inset Formula \begin{equation}
\int_{o}^{t}f(s)ds=u\end{equation}

\end_inset

 where 
\begin_inset Formula $f(s)$
\end_inset

 is a monotonically increasing function of 
\begin_inset Formula $s$
\end_inset

 and 
\begin_inset Formula $u>0$
\end_inset

.
\end_layout

\begin_layout Standard
This problem can be simply solved if seen as a root finding question.
 Let
\begin_inset Formula \begin{equation}
g(t)=\int_{o}^{t}f(s)ds-u,\end{equation}

\end_inset

then we just need to find the root for 
\begin_inset Formula $g(t),$
\end_inset

 which is guaranteed to be unique given the conditions above.
 
\end_layout

\begin_layout Standard
The SciPy library includes an optimization package that contains a Newton-Raphso
n solver called 
\family typewriter
scipy.optimize.newton.

\family default
 This solver can optionally take a known derivative for the function whose
 roots are being sought, and in this case the derivative is simply 
\begin_inset Formula \begin{equation}
\frac{dg(t)}{dt}=f(t).\end{equation}

\end_inset


\end_layout

\begin_layout Standard
For this exercise, implement the solution for the test function
\begin_inset Formula \[
f(t)=t\sin^{2}(t),\]

\end_inset

 using 
\begin_inset Formula \[
u=\frac{1}{4}.\]

\end_inset


\end_layout

\begin_layout Standard
The listing\InsetSpace ~

\begin_inset LatexCommand \ref{code:quad_newton_skel}

\end_inset

 contains a skeleton that includes for comparison the correct numerical
 value.
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Standard


\backslash
lstinputlisting[label=code:quad_newton_skel,caption={IGNORED}]{skel/quad_newton_
skel.py}
\end_layout

\end_inset


\end_layout

\begin_layout Standard

\end_layout

\end_body
\end_document
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.