-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlect_root_finding.html
More file actions
318 lines (255 loc) · 9.59 KB
/
lect_root_finding.html
File metadata and controls
318 lines (255 loc) · 9.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Numerical Methods</title>
<meta name="description" content="Lecture Derivatives and Integration">
<meta name="author" content="Tony Perkins">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/serif.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1># Numerical Methods with Python</h1>
<h3>Root finding</h3>
<p>
<small>Created by <a href="http://toperkin.github.io/nm.html">Tony Perkins</a></small>
</p>
</section>
<section>
<h2>Three algorithms to implement.</h2>
<ol>
<li>Fixed point iteration</li>
<li>Bisection method</li>
<li>Newton's method</li>
</ol>
</section>
<section>
<h2>Fixed points.
</h2>
<p>A number $p$ is a <i>fixed point</i> for a given function $g$ if
\[g(p)=p.\]
</p>
</section>
<section>
<h2>Fixed points and root finding.
</h2>
<p>Given a root-finding problem $f(z)=0$, there are many $g$ with fixed points at $z$:
\[ g(x) = x - f(x) \]
\[ g(x) = x + 3f(x) \]
\[ g(x) = x + cf(x) \]
</p>
</section>
<section>
<h2>Existence of fixed points.
</h2>
<p>If $g\in C[a, b]$ and $g(x)\in [a, b]$ for all $x\in [a, b]$, then $g$ has a fixed point in $[a,b]$
</p>
</section>
<section>
<h3>proof.</h3><p>Consider $f(x)=g(x)-x$. As $g$ is continuous, so must $f$ be.
</p>
<p>
What happens at the end points? If $g(a)=a$, we're done. $g(a)\nless a$ otherwise $g(a)\not\in [a,b]$. So \[g(a)>a \Leftrightarrow f(a)>0\]
</p>
<p>
If $g(b)=b$, we're done. $g(b)\ngtr b$ otherwise $g(b)\not\in [a,b]$. So \[g(b)< b \Leftrightarrow f(b)< 0\]
</p>
<p>
By the <i>intermediate value theorem</i> $f$ must have a zero, and consequentally $g$ must have a fixed point.
</p>
</section>
<section>
<h2>Uniqueness of fixed points.
</h2>
<p>Suppose $g\in C[a, b]$ and $g(x)\in [a, b]$ for all $x\in [a, b]$.</p>
<p>If, in addition, $g'(x)$ exists on $(a, b)$, and a positive constant $k < 1$ exists with
\[|g'(x)| < k \text{ for all } x\in (a, b)\]
then the fixed point in $[a, b]$ is unique.
</p>
</section>
<section>
<h3>proof.</h3><p>Suppose $p$ and $q$ are both fixed points in $[a, b]$. Then the Mean Value Theorem implies there exists a $\zeta$ between $p$ and $q$ with
\[g'(\zeta) = \frac{g(p)-g(q)}{p-q} = \frac{p-q}{p-q} = 1\]
a contradiction.
</p>
</section>
<section>
<p>There are a lot of fixed point theorems. They are awesome. Here are some of my favorites:</p>
<ul>
<li>Brouwer fixed-point theorem</li>
<li>Banach fixed-point theorem</li>
<li>Schauder fixed-point theorem</li>
<li>Sperner's lemma</li>
</ul>
</section>
<section>
<h2>Fixed-Point Iteration</h2>
<p>For initial $p_0$, generate the sequence $\{p_n\}_{n=0}^\infty$ by $p_n=g(p_{n-1})$.
If the sequence converges to $p$, then
\[p = \lim_{n\rightarrow \infty}p_n = \lim_{n\rightarrow \infty} g(p_n) = g\left(\lim_{n\rightarrow \infty} p_n\right) = g(p) \]
</p>
</section>
<section>
<h2>Fixed-Point Theorem.
</h2>
<p>Suppose $g\in C[a, b]$ and $g(x)\in [a, b]$ for all $x\in [a, b]$.</p>
<p>If, in addition, $g'(x)$ exists on $(a, b)$, and a positive constant $k < 1$ exists with
\[|g'(x)| < k \text{ for all } x\in (a, b).\]
Then, for any number $p_0$ in $[a,b]$ the sequence defined by $p_n=g(p_{n-1})$ converges to the unique fixed point $p$ in $[a, b]$.
</p>
</section>
<section>
<h2>Corollary.
</h2>
<p>Suppose $g$ satisfies the hypothesis above, then bounds for the error are given by</p>
<p>
\[|p_n-p| \le k^n \max\{p_0-a, b-p_0\}\]
</p>
<p>
\[|p_n-p| \le \frac{k^n}{1-k} |p_1-p_0|\]
</p>
</section>
<section>
<h2>Follow from MVT.
</h2>
<p>\[g'(\zeta) = \frac{g(p)-g(q)}{p-q}\]</p>
<p>
\[|g(p)-g(q)| = |g'(\zeta)|\cdot |p-q| \le k\cdot |p-q| \]
</p>
</section>
<section>
<h2>Bisection Method
</h2>
<p>
<ul>
<li>Suppose $f$ is continuos on $[a, b]$, and $f(a)$, $f(b)$ have opposite signs.</li>
<li>By the IVT, there exists an $x_0$ in $(a, b)$ with $f(x_0)=0$</li>
<li>Divide the interval $[a, b]$ by computing the midpoint
\[p=(a+b)/2\]</li>
<li>If $f(p)$ has the same sign as $f(a)$, consider new interval $[p, b]$</li>
<li>If $f(p)$ has the same sign as $f(b)$, consider new interval $[a, p]$</li>
<li>Repeat until the interval is small enough to approximate $x_0$ well.</li>
</ul>
</p>
</section>
<section>
<h2>Termination criteria</h2>
<p>There are many ways to decide when to stop</p>
\[ |p_n - p_{n-1}| < \varepsilon \]
\[ \frac{|p_n-p_{n-1}|}{|p_{n-1}|} < \varepsilon \]
\[ |f(p_n)| < \varepsilon \]
<p>None is perfect. In real software, people use a combination.</p>
</section>
<section>
<h2>Convergence criteria</h2>
<p>Suppose that $f\in C[a, b]$ and $f(a)\cdot f(b) < 0$. The Bisection method generates a sequence $\{p_n\}_{n=1}^\infty$ approximating a zero $p$ of $f$
\[|p_n-p|\le \frac{b-a}{2^n}, \text{ when } n\ge 1.\]</p>
</section>
<section>
<h2>Newton's Method</h2>
<h3>Taylor Polynomial Derivation</h3>
<p>Suppose $f \in C^2[a, b]$ and $p_0\in [a, b]$ with $f'(p_0)\neq 0.$ Expand $f(x)$ about $p_0$:
\[f(p) = f(p_0) + (p-p_0)f'(p_0) + \frac{(p-p_0)^2}{2}f''( \zeta(p) ) \]
Set $f(p)=0$, assume $(p-p_0)^2$ neglible:
\[p\approx p_1=p_0-\frac{f(p_0)}{f'(p_0)}\]
This gives the sequence $\{p_n\}_{n=1}^\infty$
\[p_n = p_{n-1} - \frac{ f(p_{n-1}) }{ f'(p_{n-1}) }\]
</p>
</section>
<section>
<img src="http://toperkin.github.io/NumericalMethods/images-lect_root_finding/newmet.png" alt="">
</section>
<section>
<h3>Newton's Method - Fixed point formulation</h3>
<p>Newton's method is fixed point iteration $p_n=g(p_{n-1})$ where
\[g(x) = x-\frac{f(x)}{f'(x)}\]</p>
</section>
<section>
<p><b>Theorem</b> Let $f\in C^2[a, b]$. If $p\in [a, b]$ is such that $f(p)=0$ and $f'(p)\neq 0$, then there exists a $\delta>0$ such that Newton's method generates a sequence $\{p_n\}_{n=1}^\infty$ converging to $p$ for any initial approximation $p_0\in [p-\delta, p+\delta]$</p>
</section>
<section>
<h1>Bonus topic!</h1>
</section>
<section>
<p>Consider a polynomial of degree $n$</p>
\[p(x) = \sum_{i=0}^na_ix^i = a_0 + a_1x+a_2x^2+\cdots a_nx^n\]
</section>
<section>
<p>How many basic operations (add, subtract, multiply and divide) does it take to evaluate the polynomial at a point $x_0$?</p>
</section>
<section>
<h2>Horner's Method</h2>
\[p(x) = a_0 + x(a_1 + x (a_2 + \cdots+ x (a_{n-1} + a_nx)\cdots ))\]
</section>
<section>
<h2>Moral</h2>
</section>
<section>
<h2>Advanced cleverness is everywhere</h2>
<p>Just because it is the way you where taught to evaluate something, does not mean that it is the best way to evaluate it.</p>
</section>
<section>
<p>Now suppose you have two degree $n$ polynomials $f$ and $g$.</p>
</section>
<section><p>How many basic operations will it take to find the coefficients of their product?</p></section>
<section><p>It can be done in $\mathcal{O}(n^3)$ using the fast Fourier transform.</p></section>
<section><h2>Moral 2.</h2></section>
<section><p>Sometimes the advanced cleverness to do a problem optimally requires mathematics well beyond the 'obvious' method.</p>
<p>The is a paper listed in the project topics list that will explain how to do Fast Fourier Transforms.</p>
</section>
<section>
<h2>That's all folks (for now)!</h2>
<p>These slides were prepared by <a href="http://toperkin.github.io/nm.html">Tony Perkins</a></p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/math/math.js', async: true }
]
});
</script>
</body>
</html>