If a function y=f(x) is too complicated for calculation or is even unknown, one way to approximate it is to first obtain its values y0=f(x0),...,xn=f(xn) at a sequence of points x0,...,xn, and then construct a relatively simple approximating function g(x)≈f(x).
If g(x) satisfies that g(xi)=f(xi) for all i=0,...,n, it is called the interpolating function of f(x). The most commonly used interpolating functions are algebraic polynomials.
Interpolation and the Lagrange Polynomial
Find a polynomial of degree n, Pn(x)=a0+a1x+...+anxn, such that Pn(xi)=yi for all i=0,...,n.
n=1: Given x0,x1;y0,y1. Find P1(x)=a0+a1x such that P1(x0)=y0 and P1(x1)=y1. P1(x) is the line function through the two given points (x0,y0) and (x1,y1). ⇒P1(x)=y0+x1−x0y1−y0(x−x0)=(x0−x1x−x1)y0+(x1−x0x−x0)y1=i=0∑1L1,i(x)yi
n≥1: Find Ln,i(x) for i=0,...,n such that Ln,i(xj)=δij. Then let Pn(x)=i=0∑nLn,i(x)yi. Hence Pn(xi)=yi.
Each Ln,i has n roots x0,...,xn.
The n-th Lagrange interpolating polynomial: Ln,i(x)=j=i,0≤j≤n∏(xi−xj)(x−xj)⇒Pn(x)=i=0∑nLn,i(x)yi
Theorem: If x0,...,xn are n+1 distinct numbers and f is a function whose values are given at these numbers, then the n-th Lagrange interpolating polynomial is unique.
Proof: If not… Then there exists two polynomials Pn(x) and Qn(x) both satisfying the interpolating conditions. ⇒D(x)=Pn(x)−Qn(x) is a polynomial of degree ≤n
Yet D(x) has n+1 distinct roots x0,x1,...,xn.
Note: The interpolating polynomial is NOT unique unless its degree is constrained to be no greater than n. A counterexample is P(x)=Ln(x)+p(x)i=0∏n(x−xi) where p(x) can be a polynomial of any degree.
Analyze the Remainder
Suppose a≤x0<x1<...<xn≤b and f∈Cn+1[a,b]. Consider the truncation error Rn(x)=f(x)−Pn(x)
Rn(x) has at least n+1 roots⇒Rn(x)=K(x)i=0∏n(x−xi)
Fix any x=xi for all i=0,...,n. Define the function g for t in [a,b] by g(t)=Rn(t)−K(x)i=0∏n(t−xi) g(x) has n+2 distinct roots x0,...,xn,x⇒g(n+1)(ξx)=0,ξx∈(a,b) f(n+1)(ξx)−Pn(n+1)(ξx)−K(x)(n+1)!=Rn(n+1)(ξx)−K(x)(n+1)! ⇒K(x)=(n+1)!f(n+1)(ξx)⇒Rn(x)=(n+1)!f(n+1)(ξx)i=0∏n(x−xi)
Note:
Since in most of the case ξx cannot be determined, we obtain the upper bound of f(n+1) instead. That is, estimate an Mn+1 such that ∣f(n+1)∣≤Mn+1 for all x∈(a,b) and take (n+1)!Mn+1i=0∏n∣x−xi∣ as the upper bound of the total error.
The interpolating polynomial is accurate for any polynomial function f with degree ≤n since f(n+1)(x)≡0
Example: Suppose a table is to be prepared for the function f(x)=ex for x∈[0,1]. Assume that each entry of the table is accurate up to 8 decimal places and the step size is h. What should h be for linear interpolation to given an absolute error of at most 10−6?
Solution: Suppose that [0,1] is partitioned into n equal-spaced subintervals [x0,x1],[x1,x2],...,[xn−1,xn], and x is in the interval [xk,xk+1]. Then the error estimation gives ∣f(x)−P1(x)∣=∣∣2!f(2)(ξ)(x−xk)(x−xk+1)∣∣=∣∣2eξ(x−kh)(x−(k+1)h)∣∣≤2e×4h2 8eh2≤10−6⇒h≤1.72×10−3
Simply take n=1000 and h=0.001.
Example: Given sin6π=21,sin4π=21,sin3π=23. Use the linear and the quadratic Lagrange polynomial of sinx to compute sin50∘ and then estimate the errors.
\textbf{Solution:} First use x0,x1 and x1,x2 to compute the linear interpolations. Use x0=6π,x1=4π⇒P1(x)=π/6−π/4x−π/4×21+π/4−π/6x−π/6×21 sin50∘≈P1(185π)≈0.77614Here f(x)=sinx,f(2)(ξx)=−sinξx,ξx∈(6π,3π) and 21<sinξx<23,R1(x)=2!f(2)(ξx)(x−6π)(x−4π) ⇒−0.01319<R1(185π)<−0.00762 Error of extrapolation≈−0.01001;Error of interpolation≈0.00596 Now use x0,x1 and x2 to compute the quadratic interpolation. P2(x)=(π/6−π/4)(π/6−π/3)(x−π/4)(x−π/3)×21+(π/4−π/6)(π/4−π/3)(x−π/6)(x−π/3)×21+(π/3−π/6)(π/3−π/4)(x−π/6)(x−π/4)×23 R2(x)=3!−cosξx(x−6π)(x−4π)(x−3π);21<cosξx<23 Error of the quadratic interpolation≈0.00061
Definition: Let f be a function defined at x0,x1,...,xn, and suppose that m1,...,mk are k distinct integers with 0≤mi≤n for each i. The Lagrange polynomial that agrees with f(x) at the k points xm1,...,xmk denotes by Pm1,...,mk(x).
Theorem: Let f be defined at x0,..,xk, and let xi and xj be two distinct numbers in this set. Then P(x)=(xi−xj)(x−xj)P0,1,...,j−1,j+1,...,k(x)−(x−xi)P0,1,...,i−1,i+1,...,k(x)
describes the k-th Lagrange polynomial that interpolates f at the k+1 points x0,x1,...,xk.
Proof: For any 0≤r≤k and r=i and j, the two interpolating polynomials on the numerator are equal to f(xr) at xr, so P(xr)=f(xr). The first polynomials on the numerator equals f(xi) at xi, while the second term is zero, so P(xi)=f(xi). Similarly P(xj)=f(xj). The k-th Lagrange polynomial that interpolates f at the k+1 points x0,x1,...,xk is unique.
Divided Differences
The 1st divided difference of f w.r.t. xi and xj: f[xi,xj]=xi−xjf(xi)−f(xj)(i=j,xi=xj)
The 2nd divided difference of f w.r.t. xi,xj and xk. f[xi,xj,xk]=xi−xkf[xi,xj]−f[xj,xk](i=k)
The k+1st divided difference of f w.r.t.x0,...,xk+1: f[x0,...,xk+1]=x0−xk+1f[x0,x1,...,xk]−f[x1,...,xk,xk+1]=xk−xk+1f[x0,...,xk−1,xk]−f[x0,...,xk−1,xk+1]
As a matter of fact, f[x0,...,xk]=i=0∑kωk+1′(xi)f(xi)
where ωk+1(x)=i=0∏k(x−xi),ωk+1′(xi)=0≤j≤k,j=i∏(xi−xj)
The value of f[x0,...,xk] is independent of the order of the numbers x0,...,xk.
Let x=x0+th, then Nn(x)=Nn(x0+th)=k=0∑nCtkΔkf(x0) Rn(x)=(n+1)!f(n+1)(ξ)t(t−1)...(t−n)hn+1,ξ∈(x0,xn)
Newton’s backward-difference formula
Reverse the order of the points Nn(x)=f(xn)+f[xn,xn−1](x−xn)+...+f[xn,...,x0](x−xn)...(x−x1)
Let x=xn+th, then Nn(x)=Nn(xn+th)=k=0∑n(−1)kC−tk∇kf(xn)
Hermite Interpolation
Find the osculating polynomial P(x) such that P(xi)=f(xi),P′(xi)=f′(xi),...,P(m−i)(xi)=f(m−i)(xi) for all i=0,1,...,n.
Note:
Given N conditions (and hence N equations), a polynomial of degree N−1 can be determined.
The osculating polynomial that agrees with f and all its derivatives of order ≤m0 at one point x0 is just the Taylor polynomial P(x)=f(x0)+f′(x0)(x−x0)+...+m0!f(m0)(x−x0)x0
with remainder Rn(x)=f(x)−φ(x)=(m0+1)!f(m0+1)(ξ)(x−x0)m0+1
The case when mi=1 for each i=0,1,...,n gives the Hermite polynomials.
Example: Suppose x0=x1=x2. Given f(x0),f(x1),f(x2) and f′(x1), find the polynomial P(x) such that P(xi)=f(xi),i=0,1,2, and P′(x1)=f′(x1). Analyze the errors.
Solution: First of all, the degree of P(x) must be 3. Similar to Lagrange polynomials, we may assume the form of Hermite polynomial as: P3(x)=i=0∑2f(xi)hi(x)+f′(x1)h1^(x)
where hi(xj)=δij,hi′(x1)=0,h1^(xi)=0,h1′^(x1)=1
h0(x): Has roots x1,x2, and h0′(x1)=0⇒x1 is a multiple root. {h0(x)=C0(x−x1)2(x−x2)h0(x0)=1⇒C0⇒h0(x)=(x0−x1)2(x0−x2)(x−x1)2(x−x2)
h2(x): Similar to h0(x).
h1(x): Has roots x0,x2⇒h1(x)=(Ax+B)(x−x0)(x−x2). A and B can be solved with h1(x1)=1 and h1′(x1)=0.
h1^(x): Has roots x0,x1,x2⇒h1^(x)=C1(x−x0)(x−x1)(x−x2). h1′^(x1)=1⇒C1 can be solved.
In general, given x0,...,xn;y0,...,yn and y0′,...,yn′. The Hermite polynomial H2n+1(x) satisfies H2n+1(xi)=yi and H2n+1′(xi)=yi′ for all i.
Solution: Let H2n+1(x)=i=0∑nyihi(x)+i=0∑nyi′hi^(x) where hi(xj)=δij,hi′(xj)=0,hi^(xj)=0,hi′^(xj)=δij.
hi(x): x0,...,xi^,...,xn are all roots with multiplicity 2 ⇒hi(x)=(Aix+Bi)Ln,i2(x) Ai and Bi can be solved by hi(xj)=1 and hi′(xi)=0 ⇒hi(x)=[1−2Ln,i′(xi)(x−xi)]Ln,i2(x)
hi^(x): All the roots x0,...,xn have multiplicity 2 except xi⇒ {hi^(x)=Ci(x−xi)Ln,i2(x)hi′^(x)=1⇒Ci=1⇒hi^(x)=(x−xi)Ln,i2(x)
If a=x0<x1<...<xn=b,f∈C2n[a,b], then Rn(x)=(2n+2)!f(2n+2)(ξX)[i=0∏n(x−xi)]2
Cubic Spline Interpolation
Piecewise linear interpolation
Approximate f(x) by linear polynomials on each subinterval [xi,xi+1]: f(x)≈P1(x)=xi−xi+1x−xi+1yi+xi+1−xix−xiyi+1 for x∈[xi,xi+1]
Let h=max∣xi+1−xi∣. Then P1h(x)→f(x) as h→0.
Hermite piecewise polynomials
Given x0,..,xn;y0,...,yn;y0′,...,yn′ Construct the Hermite polynomial of degree 3 with y and y′ on the two endpoints of [xi,xi+1].
Cubic Spline
Definition: Given a function f defined on [a,b] and a set of nodes a=x0<x1<...<xn=b, a cubic spline interpolant S for f is a function that satisfies the following conditions:
a. S(x) is a cubic polynomial, denoted Si(x), on the subinterval [xi,xi+1] for each i=0,1,...,n−1;
b. S(xi)=f(xi) for each i=0,1,..,n;
c. Si+1(xi+1)=Si(xi+1) for each i=0,1,...,n−2;
d. Si+1′(xi+1)=Si′(xi+1) for each i=0,1,...,n−2;
e. Si+1′′(xi+1)=Si′′(xi+1) for each i=0,1,...,n−2.
Method of Bending Moment
Let hj=xj−xj−1 and S(x)=Sj(x) for x∈[xj−1,xj]. Then Sj′′(x) is a polynomial of degree 1, which can be determined by the values of f on 2 nodes.
Assume Sj′′(xj−1)=Mj−1,Sj′′(xj)=Mj. Then for all x∈[xj−1,xj], Sj′′(x)=Mj−1hjxj−x+Mjhjx−xj−1
Integrate Sj′′(x) twice, we obtain Sj′(x) and Sj(x): Sj′(x)=−Mj−12hj(xj−x)2+Mj−12hj(x−xj−1)2+Aj Sj(x)=Mj−16hj(xj−x)3+Mj6hj(x−xj−1)3+Ajx+Bj Aj=hjyj−yj−1−hMj−Mj−1hj Ajx+Bj=(yj−1−6Mj−1hj2)hjxj−x+(yj−6Mjhj2)hjx−xj−1
Now solve for Mj: Since S′ is continuous at xj [xj−1,xj]:Sj′(x)=−Mj−12hj(xj−x)2+Mj2hj(x−xj−1)2+f[xj−1,xj]−6Mj−Mj−1hj [xj,xj+1]:Sj+1′(x)=−Mj2hj+1(xj+1−x)2+Mj+12hj+1(x−xj)2+f[xj,xj+1]−6Mj+1−Mjhj+1
From Sj′(xj)=Sj+1′(xj), we can combine the coefficients for Mj−1,Mj, and Mj+1. Define λj=hj+hj+1hj+1,μj=1−λj, and gj=hj+hj+16(f[xj,xj+1]−f[xj−1,xj]) ⇒μjMj−1+2Mj+λjMj+1=gjfor 1≤j≤n−1
That is, we have n+1 unknowns but only n−1 equations. Extra 2 boundary conditions are needed.
Similar for Sn′(x) on [xn−1,b]: ⇒{2M0+M1=h16(f[x0,x1]−y0′)=g0Mn−1+2Mn=hn6(yn′−f[xn−1,xn])=gn
S′′(a)=y0′′=M0,S′′(b)=yn′′=Mn
Then λ0=0,g0=2y0′′;μn=0,gn=2yn′′
The case when M0=Mn=0 is called a free boundary, and when that occurs, the spline is called a Natural Spline.
Periodic Boundary: If f is a periodic function, that is, yn=y0 and S′(a+)=S′(b−)⇒M0=Mn
Note:
Cubic Spline can be uniquely determined by its boundary conditions as long as the coefficient matrix is strictly diagonally dominant.
If f∈C[a,b] and minhimaxhi≤C<∞. Then S(x)→f(x) as maxhi→0. That is, the accuracy of approximation can be improved by adding more nodes without increasing the degree of the splines.
Welcome file Lecture 4: Keyframe interpolation and velocity control 动画中的运动感控制 : 运动的表示: 用数学方法来表示各类物体的运动 运动的控制和编辑: 给动画师提供能够表达他意图的方便、直观的控制工具 运动的生成: 计算每一帧所需的各种运动参数 Goal:再现物理世界的运动,超越物理世界的运行。 I.Interpolation between key frames 1. Parameters to be interpolated : Position of an object Scale of an object Orientation of an object Joint angle between two joints Color attribute of an object 2. Interpolation between frames is not trivial : Appropriate interpolation function Parameterization of the function Maintain the desired control of the interpolated values over time 3. Solution : Generate a space curve Distribute points evenly along curve Speed control: vary points 4. Interpolation v.s. Approximation : An interpolating spline in which the spline passes through the interior control points. An approximating spline in which only the endpoints are interpolated; the interior control points are used only to design th...
Welcome file Lecture 3: Representation of transformation and rotation Motion Specification : Low level techniques (techniques that aid the animator in precisely specifying motion) High level techniques (techniques used to describe general motion behavior) Translate, scale and rotation are all below to low level. Transformation can be used to change the position of objects; Set animations for objects and light source. Technical Background : Spaces and transformations: Coordinate Space: left-handed, right-handed, local coordinates system, global coordinates system. Viewing pipeline: Homogeneous coordinate, Transformation matrix, Matrix Concatenation Orientation representation: Rotation matrix Fixed angle Euler angle Angle and Axis Quaternion I.Representation of Transformation 1.1.3-D Transformations Translate, scale, or rotate a point p p p to p ′ p' p ′ : p ′ = p + T p'=p+T p ′ = p + T p ′ = S p p'=Sp ...