interpolation - computer graphicsgraphics.stanford.edu/courses/cs205a/assets/lecture_slides/... ·...
Post on 09-Aug-2020
8 Views
Preview:
TRANSCRIPT
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Interpolation
CS 205A:Mathematical Methods for Robotics, Vision, and Graphics
Doug James (and Justin Solomon)
CS 205A: Mathematical Methods Interpolation 1 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Announcements
I Final homework 8 outI Due Thursday, March 15 (midnight)I No extensions – results out following day (Fri Mar 16)
I Final exam: Tuesday March 20 @3:30-6:30pm (Room: TBA)
I Allowed: Two double-sided pages ofwritten notes (can reuse last one)
CS 205A: Mathematical Methods Interpolation 2 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
So Far
Tools for analyzingfunctions:
Roots, minima, ...
CS 205A: Mathematical Methods Interpolation 3 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Common Situation
The function isthe unknown.
CS 205A: Mathematical Methods Interpolation 4 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Example: Rendering
CS 205A: Mathematical Methods Interpolation 5 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Example: Regression
CS 205A: Mathematical Methods Interpolation 6 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Input/Output
Input: ~xi 7→ yi (exactly)
Output: f (~x) for ~x 6∈ {~xi}
Contrast with regression
CS 205A: Mathematical Methods Interpolation 7 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Input/Output
Input: ~xi 7→ yi (exactly)
Output: f (~x) for ~x 6∈ {~xi}
Contrast with regression
CS 205A: Mathematical Methods Interpolation 7 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Initial Problem
f : R→ R
Given: xi 7→ yi
CS 205A: Mathematical Methods Interpolation 8 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Initial Problem
f : R→ RGiven: xi 7→ yi
CS 205A: Mathematical Methods Interpolation 8 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
The Problem
{f : R→ R}is a huge set.
CS 205A: Mathematical Methods Interpolation 9 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Common Strategy
Restrict search to a basis φ1, φ2, . . .
f(x) =∑i
aiφi(x)
Need to compute: ~a
CS 205A: Mathematical Methods Interpolation 10 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Monomial Basis
p0(x) = 1
p1(x) = x
p2(x) = x2
p3(x) = x3
......
f(x) = a0 + a1x+ a2x2 + · · ·+ ak−1x
k−1
CS 205A: Mathematical Methods Interpolation 11 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Vandermonde System
1 x1 x21 · · · xk−11
1 x2 x22 · · · xk−12...
...... · · · ...
1 xk−1 x2k−1 · · · xk−1k−1
a0a1...
ak−1
=
y0y1...
yk−1
CS 205A: Mathematical Methods Interpolation 12 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Conditioning Issues
pk(x) = xk look similar on [0, 1] for large k
CS 205A: Mathematical Methods Interpolation 13 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Lagrange Basis
φi(x) ≡∏
j 6=i(x− xj)∏j 6=i(xi − xj)
Still polynomial!
CS 205A: Mathematical Methods Interpolation 14 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Useful Property
φi(x`) =
{1 when ` = i0 otherwise
CS 205A: Mathematical Methods Interpolation 15 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Illustration of Lagrange Basis
1φ1 φ2 φ3 φ4
2 3 40
x1 = 0, x2 = 2, x3 = 3, x4 = 4
CS 205A: Mathematical Methods Interpolation 16 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Interpolation in Lagrange Basis
f (x) ≡∑i
yiφi(x)
O(n2) time to evaluate.
Numerical issues.
CS 205A: Mathematical Methods Interpolation 17 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Interpolation in Lagrange Basis
f (x) ≡∑i
yiφi(x)
O(n2) time to evaluate.
Numerical issues.CS 205A: Mathematical Methods Interpolation 17 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Compromise: Newton Basis
ψi(x) =
i−1∏j=1
(x− xj)
ψ1(x) ≡ 1
CS 205A: Mathematical Methods Interpolation 18 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Illustration of Newton Basis
10
2 3 40
ψ1
ψ2
ψ3
ψ4
x1 = 0, x2 = 2, x3 = 3, x4 = 4
CS 205A: Mathematical Methods Interpolation 19 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Evaluating in Newton
f (x1) = c1ψ1(x1)
f (x2) = c1ψ1(x2) + c2ψ2(x2)
f (x3) = c1ψ1(x3) + c2ψ2(x3) + c3ψ3(x3)... ...
CS 205A: Mathematical Methods Interpolation 20 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Triangular System
ψ1(x1) 0 0 · · · 0ψ1(x2) ψ2(x2) 0 · · · 0ψ1(x3) ψ2(x3) ψ3(x3) · · · 0
......
... · · · ...ψ1(xk) ψ2(xk) ψ3(xk) · · · ψk(xk)
c1c2...ck
=
y1y2...yk
Review:
Efficiency of solution?
O(n2)
CS 205A: Mathematical Methods Interpolation 21 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Triangular System
ψ1(x1) 0 0 · · · 0ψ1(x2) ψ2(x2) 0 · · · 0ψ1(x3) ψ2(x3) ψ3(x3) · · · 0
......
... · · · ...ψ1(xk) ψ2(xk) ψ3(xk) · · · ψk(xk)
c1c2...ck
=
y1y2...yk
Review:
Efficiency of solution?O(n2)
CS 205A: Mathematical Methods Interpolation 21 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Important Point
All three methods yield thesame polynomial.
CS 205A: Mathematical Methods Interpolation 22 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Rational Interpolation
f (x) =p0 + p1x + p2x
2 + · · · + pmxm
q0 + q1x + q2x2 + · · · + qnxn
yi(q0+q1xi+· · ·+qnxni ) = p0+p1xi+· · ·+pmxmiNull space problem!
Scary example: n = m = 1; (0, 1), (1, 2), (2, 2)
CS 205A: Mathematical Methods Interpolation 23 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Rational Interpolation
f (x) =p0 + p1x + p2x
2 + · · · + pmxm
q0 + q1x + q2x2 + · · · + qnxn
yi(q0+q1xi+· · ·+qnxni ) = p0+p1xi+· · ·+pmxmiNull space problem!
Scary example: n = m = 1; (0, 1), (1, 2), (2, 2)
CS 205A: Mathematical Methods Interpolation 23 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Rational Interpolation
f (x) =p0 + p1x + p2x
2 + · · · + pmxm
q0 + q1x + q2x2 + · · · + qnxn
yi(q0+q1xi+· · ·+qnxni ) = p0+p1xi+· · ·+pmxmiNull space problem!
Scary example: n = m = 1; (0, 1), (1, 2), (2, 2)
CS 205A: Mathematical Methods Interpolation 23 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Fourier Series
cos(kx)
sin(kx)
CS 205A: Mathematical Methods Interpolation 24 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Problem with Polynomials
12
1
Local change can have global effect.
CS 205A: Mathematical Methods Interpolation 25 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Compact Support
Compact support
A function g(x) has compact support if there
exists C ∈ R such that g(x) = 0 for any x with
|x| > C.
CS 205A: Mathematical Methods Interpolation 26 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Piecewise Constant Interpolation
CS 205A: Mathematical Methods Interpolation 27 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Piecewise Constant Basis
1
xi
φi(x)
φi(x) =
{1 when
xi−1+xi2 ≤ x <
xi+xi+12
0 otherwise
CS 205A: Mathematical Methods Interpolation 28 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Piecewise Linear Interpolation
CS 205A: Mathematical Methods Interpolation 29 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Piecewise Linear “Hat” Basis
1ψi(x)
xi
ψi(x) =
x−xi−1
xi−xi−1when xi−1 < x ≤ xi
xi+1−xxi+1−xi
when xi < x ≤ xi+1
0 otherwise
CS 205A: Mathematical Methods Interpolation 30 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Observation
Extra differentiability ispossible and may look nicer
but can be undesirable.Example: Interpolating data from nonsmoothphenomena, e.g., contact.
CS 205A: Mathematical Methods Interpolation 31 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Multidimensional Problem
f : Rn→ R
Given: ~xi 7→ yi
CS 205A: Mathematical Methods Interpolation 32 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Multidimensional Problem
f : Rn→ RGiven: ~xi 7→ yi
CS 205A: Mathematical Methods Interpolation 32 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Interpolation on a Grid
CS 205A: Mathematical Methods Interpolation 33 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Nearest-Neighbor Interpolation
Definition (Voronoi cell)
Given S = {~x1, ~x2, . . . , ~xk} ⊆ Rn, the Voronoi cellcorresponding to ~xi is
Vi ≡ {~x : ‖~x− ~xi‖2 < ‖~x− ~xj‖2 for all j 6= i}.
That is, it is the set of points closer to ~xi than to anyother ~xj in S.
CS 205A: Mathematical Methods Interpolation 34 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Voronoi Cells
CS 205A: Mathematical Methods Interpolation 35 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Barycentric Interpolation
n+ 1 points in Rn
∑i
ai~xi = ~x∑i
ai = 1
−→ f(~x) =∑i
ai(~x)yi
CS 205A: Mathematical Methods Interpolation 36 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Barycentric Interpolation
n+ 1 points in Rn
∑i
ai~xi = ~x∑i
ai = 1
−→ f(~x) =∑i
ai(~x)yi
CS 205A: Mathematical Methods Interpolation 36 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Interpretation in 2D
~p2
~p1
~p3
A1
A2
A3~p
CS 205A: Mathematical Methods Interpolation 37 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Generalized Barycentric Coordinates
http://www.eng.biu.ac.il/weberof/publications/complex-coordinates/
CS 205A: Mathematical Methods Interpolation 38 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Localized Barycentric Interpolation:Triangle Hat Functions
CS 205A: Mathematical Methods Interpolation 39 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Linear Algebra of Functions
〈f, g〉 ≡∫ b
a
f(x)g(x) dx
Measures “overlap” of functions!
CS 205A: Mathematical Methods Interpolation 40 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Orthogonal Polynomials
I Legendre: Apply Gram-Schmidt to
1, x, x2, x3, . . .
I Chebyshev: Same, with weighted inner
product
w(x) =1√
1− x2Nice oscillatory properties; minimizes ringing.
CS 205A: Mathematical Methods Interpolation 41 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Question
What is the least-squaresapproximation of f in a set
of polynomials?
CS 205A: Mathematical Methods Interpolation 42 / 43
Introduction Polynomial Alternative Bases Piecewise Bases Multiple Dimensions Theory of Interpolation
Piecewise Polynomial Error
I Piecewise constant:
O(∆x)
I Piecewise linear:
O(∆x2)Next
CS 205A: Mathematical Methods Interpolation 43 / 43
top related