Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Erik Strand
nmm_2020_site
Commits
5e51032d
Commit
5e51032d
authored
Apr 15, 2020
by
Erik Strand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add notes on parabolic interpolation
parent
9ea9cf49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
_code/pset_08/py/lagrange_poly.py
_code/pset_08/py/lagrange_poly.py
+1
-0
_notes/optimization.md
_notes/optimization.md
+43
-0
No files found.
_code/pset_08/py/lagrange_poly.py
View file @
5e51032d
...
...
@@ -26,5 +26,6 @@ print(sp.latex(sol))
q
=
(
x_2
-
x_3
)
*
(
y_2
-
y_1
)
r
=
(
x_2
-
x_1
)
*
(
y_2
-
y_3
)
alt
=
x_2
-
((
x_2
-
x_3
)
*
q
-
(
x_2
-
x_1
)
*
r
)
/
2
/
(
q
-
r
)
print
(
sp
.
latex
(
alt
))
print
(
sp
.
simplify
(
sol
-
alt
))
_notes/optimization.md
View file @
5e51032d
...
...
@@ -2,6 +2,49 @@
title
:
Optimization Algorithms
---
## Parabolic Interpolation
A task that comes up frequently in optimization problems is guessing a function minimum based on a
parabola fit between three points. So I'll derive this technique here.
First, we need a parabola that goes through three points, say $$(x_1, y_1)$$, $$(x_1, y_1)$$, and
$$(x_3, y_3)$$. In the interest of generality, I'll construct it using Lagrange polynomials.
$$
p(x) =
\f
rac{y_1 (x - x_2) (x - x_3)}{(x_1 - x_2) (x_1 - x_3)}
+
\f
rac{y_2 (x - x_1) (x - x_3)}{(x_2 - x_1) (x_2 - x_3)}
+
\f
rac{y_3 (x - x_1) (x - x_2)}{(x_3 - x_1) (x_3 - x_2)}
$$
Differentiating, we find that the derivative is equal to the following.
$$
\b
egin{aligned}
p'(x) &=
\f
rac{y_{1}
\l
eft(x - x_{2}
\r
ight)}{
\l
eft(x_{1} - x_{2}
\r
ight)
\l
eft(x_{1} - x_{3}
\r
ight)}
+
\f
rac{y_{1}
\l
eft(x - x_{3}
\r
ight)}{
\l
eft(x_{1} - x_{2}
\r
ight)
\l
eft(x_{1} - x_{3}
\r
ight)}
\\
&+
\f
rac{y_{2}
\l
eft(x - x_{1}
\r
ight)}{
\l
eft(- x_{1} + x_{2}
\r
ight)
\l
eft(x_{2} - x_{3}
\r
ight)}
+
\f
rac{y_{2}
\l
eft(x - x_{3}
\r
ight)}{
\l
eft(- x_{1} + x_{2}
\r
ight)
\l
eft(x_{2} - x_{3}
\r
ight)}
\\
&+
\f
rac{y_{3}
\l
eft(x - x_{1}
\r
ight)}{
\l
eft(- x_{1} + x_{3}
\r
ight)
\l
eft(- x_{2} + x_{3}
\r
ight)}
+
\f
rac{y_{3}
\l
eft(x - x_{2}
\r
ight)}{
\l
eft(- x_{1} + x_{3}
\r
ight)
\l
eft(- x_{2} + x_{3}
\r
ight)}
\e
nd{aligned}
$$
Setting this to zero, we find that the solution is surprisingly simple.
$$
x_
\t
ext{min} =
\f
rac{1}{2}
\c
dot
\f
rac{x_1^2 (y_2 - y_3) + x_2^2 (y_3 - y_1) + x_3^2 (y_{1} - y_2)}
{x_1 (y_2 - y_3) + x_2 (y_3 - y_1) + x_3 (y_1 - y_2)}
$$
This can also be factored so that it only involves differences of coordinates and function values.
$$
x_
\t
ext{min} =
x_{2} -
\f
rac{1}{2}
\c
dot
\f
rac{(x_2 - x_3)^2 (y_2 - y_1) - (x_2 - x_1)^2 (y_2 - y_3)}{(x_2 - x_3) (y_2 - y_1) - (x_2 - x_1) (y_2 - y_3)}
$$
## Nelder-Mead
TODO: Demonstrate that the Numerical Recipes formulation is equivalent to the standard formulation.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment