Files
eth-summaries/semester3/numcs/parts/03_zeros/04_newton-one-d.tex
Basil Feitknecht 2765f49320 Fix Newton's Method
The old one incorrectly uses the absolute value of the derivative
2026-01-18 14:30:02 +01:00

35 lines
1.1 KiB
TeX

\newsectionNoPB
\subsection{Newtonverfahren in 1D}
Beim Newtonverfahren verwendet man für jeden Iterationsschritt die lineare Funktion $\tilde{F} = F(x^(k)) + F'(x^{(k)})(x - x^{(k)})$. Die Nullstelle ist dann:
\rmvspace
\begin{align*}
x^{(k + 1)} := x^{(k)} - \frac{F(x^{(k)})}{F'(x^{(k)})}, \mediumhspace \text{falls } F'(x^{(k)}) \neq 0
\end{align*}
\stepLabelNumber{all}
\inlineremark Die Newton-Iteration ist eine Fixpunktiteration mit quadratischer lokaler Konvergenz, mit
\rmvspace
\begin{align*}
\phi(x) = x - \frac{F(x)}{F'(x)} \Longrightarrow \phi'(x) = \frac{F(x) F''(x)}{(F'(x))^2} \Longrightarrow \phi'(x^*) = 0
\end{align*}
\drmvspace
falls $F(x^*) = 0$ und $F^(x^*) \neq 0$
\newpage
\innumpy Ist das Newton-Verfahren mit sehr wenig code implementierbar:
\begin{code}{python}
def newton_method(f, df, x: float, tol=1e-12, maxIter=100):
""" Use Newton's method to find zeros, requires derivative of f """
k = 0
fx = f(x)
dfx = df(x)
while (np.abs(fx) > tol and k < maxIter):
x -= fx / dfx
k += 1
return x, k
\end{code}