《数值分析》 David Kincaid, Ward Cheney 著, 王国荣 余耀明 徐兆亮 译.
因为看的论文里用到了样条函数,故查阅了一些资料并整理一下.
样条函数是由一些具有某些连续性条件得子空间上得分段多项式构成. 给定n+1个点 t 0 , t 1 , … , t n t_0, t_1, \ldots, t_n t0,t1,…,tn并且满足 t 0 < t 1 < … t n . t_0 < t_1 < \ldots t_n. t0<t1<…tn. 这些点称为结点. 又假如指定一个整数 k ≥ 0 k \ge0 k≥0, 具有结点 t 0 , t 1 , … , t n t_0, t_1, \ldots, t_n t0,t1,…,tn的一个 k k k次样条函数是指满足下列条件的函数 S S S:
假设有数据 ( t 0 , y 0 ) , ( t 1 , y 1 ) , … , ( t n , y n ) (t_0, y_0), (t_1, y_1), \ldots, (t_n, y_n) (t0,y0),(t1,y1),…,(tn,yn). 我们来探讨如何唯一确定一个三次样条函数.
记 [ t i , t i + 1 ] [t_i, t_{i+1}] [ti,ti+1]上表示 S S S的多项式记为 S i S_i Si.
首先根据连续性条件有:
S i − 1 ( t i ) = y i = S i ( t i ) ( 1 ≤ i ≤ n − 1 ) , S 0 ( t 0 ) = y 0 , S n ( t n ) = y n . S_{i-1}(t_i)=y_i=S_{i}(t_i) \quad (1 \le i \le n-1), \\ S_0(t_0)=y_0, S_n(t_n)=y_n. Si−1(ti)=yi=Si(ti)(1≤i≤n−1),S0(t0)=y0,Sn(tn)=yn.
这是 2 n 2n 2n个方程,
再利用2阶连续可导的条件:
S i − 1 ′ ( t i ) = S i ′ ( t i ) ( 1 ≤ i ≤ n − 1 ) S i − 1 ′ ′ ( t i ) = S i ′ ′ ( t i ) ( 1 ≤ i ≤ n − 1 ) S'_{i-1}(t_i)=S'_i(t_i) \quad (1 \le i \le n-1) \\ S''_{i-1}(t_i)=S''_i(t_i) \quad (1 \le i \le n-1) \\ Si−1′(ti)=Si′(ti)(1≤i≤n−1)Si−1′′(ti)=Si′′(ti)(1≤i≤n−1)
可知,这里有 2 n − 2 2n-2 2n−2个方程,总共有 4 n − 2 4n-2 4n−2个方程,但是唯一确定一个三次样条函数,需要 4 n 4n 4n个方程,所以还有2个自由度,这个怎么利用后面会提到.
定义 z i = S ′ ′ ( t i ) z_i=S''(t_i) zi=S′′(ti), 因为容易证明 S i ′ ′ ( t i ) = z i , S i ′ ′ ( t i + 1 ) = z i + 1 S_i''(t_i)=z_i, S_i''(t_{i+1})=z_{i+1} Si′′(ti)=zi,Si′′(ti+1)=zi+1, 且因为 S i S_i Si是三次多项式,所以其二阶导数为一阶多项式,所以:
S i ′ ′ ( x ) = z i h i ( t i + 1 − x ) + z i + 1 h i ( x − t i ) S_i''(x) = \frac{z_i}{h_i}(t_{i+1}-x) + \frac{z_{i+1}}{h_i}(x-t_i) Si′′(x)=hizi(ti+1−x)+hizi+1(x−ti)
其中 h i : = t i + 1 − t i h_i := t_{i+1} - t_i hi:=ti+1−ti.
进行俩次积分,其结果是 S i S_i Si:
S i ( x ) = z i 6 h i ( t i + 1 − x ) 3 + z i + 1 6 h i ( x − t i ) 3 + C ( x − t i ) + D ( t i + 1 − x ) . S_i(x) = \frac{z_i}{6h_i} (t_{i+1} - x)^3 + \frac{z_{i+1}}{6 h_i}(x-t_i)^3 + C(x-t_i)+D(t_{i+1}-x). Si(x)=6hizi(ti+1−x)3+6hizi+1(x−ti)3+C(x−ti)+D(ti+1−x).
其中 C , D C, D C,D是积分常数, 再利用 S i ( t i ) = y i , S i ( t i + 1 ) = y i + 1 S_i(t_i)=y_i, S_i(t_{i+1})=y_{i+1} Si(ti)=yi,Si(ti+1)=yi+1可得:
S i ( x ) = z i 6 h i ( t i + 1 − x ) 3 + z i + 1 6 h i ( x − t i ) 3 + ( y i + 1 h i − z i + 1 h i 6 ) ( x − t i ) + ( y i h i − z i h i 6 ) ( t i + 1 − x ) . \begin{array}{ll} S_i(x) &= \frac{z_i}{6h_i} (t_{i+1} - x)^3 + \frac{z_{i+1}}{6 h_i}(x-t_i)^3 \\ &+ (\frac{y_{i+1}}{h_i}-\frac{z_{i+1}h_i}{6})(x-t_i) + (\frac{y_i}{h_i} - \frac{z_ih_i}{6})(t_{i+1}-x). \end{array} Si(x)=6hizi(ti+1−x)3+6hizi+1(x−ti)3+(hiyi+1−6zi+1hi)(x−ti)+(hiyi−6zihi)(ti+1−x).
注: 原书在此处有误.
求在结点处的一阶导数:
S i ′ ( t i ) = − h i 3 z i − h i 6 z i + 1 − y i h i + y i + 1 h i , S_i'(t_i) = -\frac{h_i}{3} z_i - \frac{h_i}{6}z_{i+1} - \frac{y_i}{h_i} + \frac{y_{i+1}}{h_i}, Si′(ti)=−3hizi−6hizi+1−hiyi+hiyi+1,
S i − 1 ′ ( t i ) = h i − 1 6 z i − 1 + h i − 1 3 z i − y i − 1 h i − 1 + y i h i − 1 . S_{i-1}'(t_i) = \frac{h_{i-1}}{6} z_{i-1} + \frac{h_{i-1}}{3}z_i - \frac{y_{i-1}}{h_{i-1}}+\frac{y_i}{h_{i-1}}. Si−1′(ti)=6hi−1zi−1+3hi−1zi−hi−1yi−1+hi−1yi.
上面俩式子相等,可得:
h i − 1 z i − 1 + 2 ( h i + h i − 1 ) z i + h i z i + 1 = 6 h i ( y i + 1 − y i ) − 6 h i − 1 ( y i − y i − 1 ) , i = 1 , 2 , … , n − 1. h_{i-1}z_{i-1} + 2(h_i + h_{i-1})z_i + h_i z_{i+1} = \frac{6}{h_i}(y_{i+1} - y_i) - \frac{6}{h_{i-1}}(y_i - y_{i-1}), \: i=1,2,\ldots, n-1. hi−1zi−1+2(hi+hi−1)zi+hizi+1=hi6(yi+1−yi)−hi−16(yi−yi−1),i=1,2,…,n−1.
这个线性方程组有未知量 z 0 , z 1 , … , z n z_0, z_1, \ldots, z_n z0,z1,…,zn, 方程个数为 n − 1 n-1 n−1个,所以需要另外增添条件,一个很好的选择是 z 0 = z n = 0 z_0=z_n=0 z0=zn=0(后面会有一个定理为其提供依据).
[ u 1 h 1 h 1 u 2 h 2 h 2 u 3 h 3 ⋱ ⋱ ⋱ h n − 3 u n − 2 h n − 2 h n − 2 u n − 1 ] [ z 1 z 2 z 3 ⋮ z n − 2 z n − 1 ] = [ v 1 v 2 v 3 ⋮ v n − 2 v n − 1 ] , \left [ \begin{array}{cccccc} u_1 & h_1 & & & & \\ h_1 & u_2 & h_2 & & & \\ & h_2 & u_3 & h_3 & & \\ & & \ddots & \ddots & \ddots & \\ & & & h_{n-3} & u_{n-2} & h_{n-2} \\ & & & & h_{n-2} & u_{n-1} \end{array} \right] \left [ \begin{array}{c} z_1 \\ z_2 \\ z_3 \\ \vdots \\ z_{n-2} \\ z_{n-1} \end{array} \right ] = \left [ \begin{array}{c} v_1 \\ v_2 \\ v_3 \\ \vdots \\ v_{n-2} \\ v_{n-1} \end{array} \right ], ⎣⎢⎢⎢⎢⎢⎢⎡u1h1h1u2h2h2u3⋱h3⋱hn−3⋱un−2hn−2hn−2un−1⎦⎥⎥⎥⎥⎥⎥⎤⎣⎢⎢⎢⎢⎢⎢⎢⎡z1z2z3⋮zn−2zn−1⎦⎥⎥⎥⎥⎥⎥⎥⎤=⎣⎢⎢⎢⎢⎢⎢⎢⎡v1v2v3⋮vn−2vn−1⎦⎥⎥⎥⎥⎥⎥⎥⎤,
其中
h i = t i + 1 − t i u i = 2 ( h i + h i − 1 ) b i = 6 h i ( y i + 1 − y i ) v = b i − b i − 1 . h_i = t_{i+1} - t_i \\ u_i = 2(h_i + h_{i-1}) \\ b_i = \frac{6}{h_i} (y_{i+1} - y_i)\\ v = b_i - b_{i-1}. hi=ti+1−tiui=2(hi+hi−1)bi=hi6(yi+1−yi)v=bi−bi−1.
"""
三次样条函数实现
"""
import numpy as np
import matplotlib.pyplot as plt
class Polynomial:
def __init__(self, t1, t2, y1, y2, z1, z2):
assert t2 > t1, "t2 > t1 needed..."
self.z = (z1, z2)
self.y = (y1, y2)
self.t = (t1, t2)
self.h = t2 - t1
def __call__(self, x):
if x < self.t[0] or x > self.t[1]:
return 0.
reduce1_t2_x = self.t[1] - x
reduce1_x_t1 = x - self.t[0]
return self.z[0] / (6 * self.h) * reduce1_t2_x ** 3 + \
self.z[1] / (6 * self.h) * reduce1_x_t1 ** 3 + \
(self.y[1] / self.h - self.z[1] * self.h / 6) * reduce1_x_t1 + \
(self.y[0] / self.h - self.z[0] * self.h / 6) * reduce1_t2_x
class Spline3:
def __init__(self, t, y):
self.n = len(t) - 1
assert len(y) == self.n + 1, "t and y not match"
self.t = np.array(t, dtype=float)
self.y = np.array(y, dtype=float)
self.h = np.diff(t)
assert np.all(self.h > 0), "Invalid t"
self.b = np.diff(y) * 6 / self.h
self.calc_z() #计算z
self.generate_splines() #生成分段多项式函数
def calc_z(self):
u = []
v = []
z = [0.]
u.append((self.h[0] + self.h[1]) / 2)
v.append(self.b[1] - self.b[0])
for i in range(1, self.n-1): #对角化
u_i = 2 * (self.h[i] + self.h[i-1]) - \
self.h[i-1] ** 2 / u[-1]
v_i = self.b[i] - self.b[i-1] - \
self.h[i-1] * v[i-1] / u[-1]
u.append(u_i)
v.append(v_i)
z.append(v[-1] / u[-1])
for i in reversed(range(self.n-2)): #计算解
z.append((v[i] - self.h[i] * z[-1]) / u[i])
z.append(0.)
z.reverse()
self.z = z
return z
def generate_splines(self):
s = []
for i in range(self.n):
t1 = self.t[i]
t2 = self.t[i+1]
y1 = self.y[i]
y2 = self.y[i+1]
z1 = self.z[i]
z2 = self.z[i+1]
s.append(Polynomial(t1, t2, y1,
y2, z1, z2))
self.s = s
return s
def __call__(self, x):
def f(x):
if x < self.t[0] or x > self.t[-1]:
return 0.
for item in self.s:
result = item(x)
if result:
return result
raise ValueError("Something wrong happened...")
if not hasattr(x, "__len__"):
return f(x)
else:
y = []
for item in x:
y.append(f(item))
return np.array(y)
def plot(self):
t = np.linspace(self.t[0], self.t[-1], 100)
y = self(t)
fig, ax = plt.subplots()
ax.plot(t, y, "b--")
ax.set(xlabel="x", ylabel="y")
ax.scatter(self.t, self.y, color="red")
plt.show()
这个“最优性”似乎用“最光滑”来理解更为恰当吧. 这个定理也解释了之前的为什么 z 0 = z n = 0 z_0=z_n=0 z0=zn=0.
定理1(自然三次样条最优性定理) 设 f ′ ′ f'' f′′在 [ a , b ] [a, b] [a,b]上连续且 a = t 0 < t 1 < ⋯ < t n = b a=t_0
∫ a b [ S ′ ′ ( x ) ] 2 d x ≤ ∫ a b [ f ′ ′ ( x ) ] 2 d x . \int_a^b [S''(x)]^2 \mathrm{d}x \le \int_a^b [f''(x)]^2 \mathrm{d}x. ∫ab[S′′(x)]2dx≤∫ab[f′′(x)]2dx.
证明: 令 g ≡ f − S g \equiv f-S g≡f−S, 从而对于 0 ≤ i ≤ n 0 \le i \le n 0≤i≤n, g ( t i ) = 0 g(t_i)=0 g(ti)=0并且
∫ a b ( f ′ ′ ) 2 d x = ∫ a b ( S ′ ′ ) 2 d x + ∫ a b ( g ′ ′ ) 2 d x + 2 ∫ a b S ′ ′ g ′ ′ d x , \int_a^b (f'')^2 \mathrm{d}x = \int_a^b (S'')^2 \mathrm{d}x + \int_a^b (g'')^2 \mathrm{d}x + 2 \int_a^b S'' g'' \mathrm{d}x, ∫ab(f′′)2dx=∫ab(S′′)2dx+∫ab(g′′)2dx+2∫abS′′g′′dx,
只需证明:
∫ a b S ′ ′ g ′ ′ d x ≥ 0. \int_a^b S''g'' \mathrm{d}x \ge 0. ∫abS′′g′′dx≥0.
注意到: S ′ ′ ( t 0 ) = S ′ ′ ( t n ) = 0 S''(t_0) = S''(t_n)=0 S′′(t0)=S′′(tn)=0, 以及在 [ t i − 1 , t i ] [t_{i-1}, t_i] [ti−1,ti]上 S ′ ′ ′ S''' S′′′是常数(记为 c i c_i ci), 我们有:
∫ a b S ′ ′ g ′ ′ d x = ∑ i = 1 n ∫ t i − 1 t i S ′ ′ g ′ ′ d x = ∑ i = 1 n { ( S ′ ′ g ′ ) ∣ t i − 1 t i − ∫ t i − 1 t i S ′ ′ ′ g ′ d x } = − ∑ i = 1 n ∫ t i − 1 t i S ′ ′ ′ g ′ d x = − ∑ i = 1 n c i ∫ t i − 1 t i g ′ d x = − ∑ i = 1 n c i [ g ( t i ) − g ( t i − 1 ) ] = 0. \begin{array}{ll} \int_a^b S'' g'' \mathrm{d}x &= \sum_{i=1}^n \int_{t_{i-1}}^{t_i} S'' g'' \mathrm{d}x \\ & = \sum_{i=1}^n \{ (S''g')|_{t_{i-1}}^{t_{i}}-\int_{t_{i-1}}^{t_{i}} S'''g'\mathrm{d}x\} \\ & = -\sum_{i=1}^n \int_{t_{i-1}}^{t_i} S''' g' \mathrm{d}x = - \sum_{i=1}^n c_i \int_{t_{i-1}}^{t_i} g' \mathrm{d}x \\ &= -\sum_{i=1}^n c_i [g(t_i) - g(t_{i-1})] = 0. \end{array} ∫abS′′g′′dx=∑i=1n∫ti−1tiS′′g′′dx=∑i=1n{(S′′g′)∣ti−1ti−∫ti−1tiS′′′g′dx}=−∑i=1n∫ti−1tiS′′′g′dx=−∑i=1nci∫ti−1tig′dx=−∑i=1nci[g(ti)−g(ti−1)]=0.
实际上,条件可以放松,注意到在上述证明步骤中:
∑ i = 1 n ( S ′ ′ g ′ ) ∣ t i − 1 t i = ( S ′ ′ g ′ ) ( b ) − ( S ′ ′ g ′ ) ( a ) . \sum_{i=1}^n (S''g')|_{t_{i-1}}^{t_i} = (S''g')(b) - (S''g')(a). i=1∑n(S′′g′)∣ti−1ti=(S′′g′)(b)−(S′′g′)(a).
当这个表达式非负的时候,结论依然成立,即需要
S ′ ′ ( b ) [ f ′ ( b ) − S ′ ( b ) ] ≥ S ′ ′ ( a ) [ f ′ ( a ) − S ′ ( a ) ] . S''(b)[f'(b)-S'(b)] \ge S''(a)[f'(a) - S'(a)]. S′′(b)[f′(b)−S′(b)]≥S′′(a)[f′(a)−S′(a)].
例如: S ′ ( a ) = f ′ ( a ) S'(a)=f'(a) S′(a)=f′(a)和 S ′ ( b ) = f ′ ( b ) S'(b) = f'(b) S′(b)=f′(b).
自然样条: 一个 2 m + 1 2m+1 2m+1次的自然样条是一个函数 S ∈ C 2 m ( R ) S \in C^{2m}(\R) S∈C2m(R), 在每一个区间 [ t 0 , t 1 ] , ⋯ , [ t n − 1 , t n ] [t_0, t_1], \cdots, [t_{n-1},t_n] [t0,t1],⋯,[tn−1,tn]内,它都化为一个次数 ≤ 2 m + 1 \le 2m+1 ≤2m+1的多项式,而在区间 ( − ∞ , t 0 ) (-\infty,t_0) (−∞,t0)和 ( t n , + ∞ ) (t_n, +\infty) (tn,+∞)内化为一个次数至多为 m m m的多项式.
降在 n + 1 n+1 n+1个结点 t 0 , t 1 , … , t n t_0, t_1, \ldots, t_n t0,t1,…,tn上的全体 2 m + 1 2m+1 2m+1次自然样条所构成的线性空间记为 N 2 m + 1 ( t 0 , t 1 , ⋯ , t n ) \mathcal{N}^{2m+1}(t_0,t_1,\cdots,t_n) N2m+1(t0,t1,⋯,tn), 简记为 N n 2 m + 1 \mathcal{N}_n^{2m+1} Nn2m+1.
下面不加证明地给出定理:
定理2(截断幂函数定理): N n 2 m + 1 \mathcal{N}_n^{2m+1} Nn2m+1中地每个元有表达式
S ( x ) = ∑ i = 1 m a i x i + ∑ i = 0 n b i ( x − t i ) + 2 m + 1 , S(x) = \sum_{i=1}^m a_ix^i + \sum_{i=0}^n b_i (x-t_i)_+^{2m+1}, S(x)=i=1∑maixi+i=0∑nbi(x−ti)+2m+1,
其中对于 0 ≤ j ≤ m , ∑ i = 0 n b i t I j = 0. 0 \le j \le m, \sum_{i=0}^n b_it_I^j=0. 0≤j≤m,∑i=0nbitIj=0. ( x − t i ) + = x − t i , x − t i ≥ 0 , (x-t_i)_+=x-t_i, \: x-t_i\ge0, (x−ti)+=x−ti,x−ti≥0, 否则为 0 0 0.
定理3(奇数次自然样条唯一性定理): 给定结点 t 0 < t 1 < ⋯ < t n , t_0 < t_1 < \cdots < t_n, t0<t1<⋯<tn, 设 0 ≤ m ≤ n 0 \le m \le n 0≤m≤n. 则存在唯一的 2 m + 1 2m+1 2m+1次自然样条在这些结点上渠道给定的值.
证明很有趣,很在意奇数次的限制,这里给出证明.
证明:
S ( x ) = ∑ i = 1 m a i x i + ∑ i = 0 n b i ( x − t i ) + 2 m + 1 , S(x) = \sum_{i=1}^m a_ix^i + \sum_{i=0}^n b_i (x-t_i)_+^{2m+1}, S(x)=i=1∑maixi+i=0∑nbi(x−ti)+2m+1,
假设 S ( t i ) = λ i S(t_i)=\lambda_i S(ti)=λi,再结合定理2,只需下列方程组:
{ S ( t i ) = λ i 0 ≤ i ≤ n ∑ j = 0 n b j t j i = 0 0 ≤ i ≤ m , \left \{ \begin{array}{ll} S(t_i)= \lambda_i & 0 \le i \le n \\ \sum_{j=0}^n b_jt_j^i=0 & 0 \le i \le m \end{array} \right. , {S(ti)=λi∑j=0nbjtji=00≤i≤n0≤i≤m,
存在唯一解,这一个 m + n + 2 m+n+2 m+n+2个未知量 m + n + 2 m+n+2 m+n+2个方程的方程组,所以只需证明其对应的其次问题仅有零解即可. 假设 λ i = 0 , 0 ≤ i ≤ n \lambda_i=0, 0 \le i \le n λi=0,0≤i≤n. 下证:
I ≡ ∫ a b [ S ( m + 1 ) ( x ) ] 2 d x = 0 , I \equiv \int_a^b [S^{(m+1)}(x)]^2 \mathrm{d}x=0, I≡∫ab[S(m+1)(x)]2dx=0,
其中 a = t 0 , b = t n a=t_0,b=t_n a=t0,b=tn. 利用分部积分可以得到:
I = S ( m + 1 ) ( x ) S ( m ) ( x ) ∣ a b − ∫ a b S ( m ) ( x ) S ( m + 2 ) ( x ) d x = − ∫ a b S ( m ) ( x ) S ( m + 2 ) ( x ) d x , I = S^{(m+1)}(x) S^{(m)}(x)|_a^b - \int_a^b S^{(m)}(x)S^{(m+2)}(x)\mathrm{d}x=-\int_a^b S^{(m)}(x)S^{(m+2)}(x)\mathrm{d}x, I=S(m+1)(x)S(m)(x)∣ab−∫abS(m)(x)S(m+2)(x)dx=−∫abS(m)(x)S(m+2)(x)dx,
其中最后一个等式成立的原因是 S ( k ) ( a ) = S ( k ) ( b ) = 0 , k > m S^{(k)}(a)=S^{(k)}(b)=0, k>m S(k)(a)=S(k)(b)=0,k>m. 重复上述操作可得:
I = ( − 1 ) m ∫ a b S ( 1 ) ( x ) S ( 2 m + 1 ) ( x ) d x . I = (-1)^m \int_a^b S^{(1)}(x)S^{(2m+1)}(x) \mathrm{d}x. I=(−1)m∫abS(1)(x)S(2m+1)(x)dx.
因为 S ( 2 m + 1 ) ( x ) S^{(2m+1)}(x) S(2m+1)(x)是分段常值函数,所以:
I = ( − 1 ) m ∑ i = 1 n ∫ t i − 1 t i c i S ′ ( x ) d x = ( − 1 ) m ∑ i = 1 n c i [ S ( t i ) − S ( t i − 1 ) ] = 0. I = (-1)^m \sum_{i=1}^n\int_{t_{i-1}}^{t_i} c_i S'(x) \mathrm{d}x = (-1)^m \sum_{i=1}^nc_i[S(t_i)-S(t_{i-1})]=0. I=(−1)mi=1∑n∫ti−1ticiS′(x)dx=(−1)mi=1∑nci[S(ti)−S(ti−1)]=0.
由此,我们可知 S ( m + 1 ) ≡ 0 S^{(m+1)} \equiv 0 S(m+1)≡0. 因此, S S S是一个次数至多是 m m m次的多项式,但 S S S有 n + 1 > m n+1>m n+1>m个不同的零点,所以 S = 0 S=0 S=0, 所以 a i , b i = 0 a_i, b_i=0 ai,bi=0. 至此,唯一性得证.
考虑偶数次样条,我不知道是怎么定义的,也不想去查,假设是 2 m , m 2m, m 2m,m的类型,那么我们依然要证明(或者 m + 2 , m + 3 , … m+2,m+3,\ldots m+2,m+3,…):
I ≡ ∫ a b [ S ( m + 1 ) ( x ) ] 2 d x = 0 , I \equiv \int_a^b [S^{(m+1)}(x)]^2 \mathrm{d}x=0, I≡∫ab[S(m+1)(x)]2dx=0,
不然利用分部积分的时候,没法消项, 能顺利推导到:
I = ( − 1 ) m − 1 ∫ a b S ( 2 ) ( x ) S ( 2 m ) ( x ) d x . I = (-1)^{m-1} \int_a^b S^{(2)}(x)S^{(2m)}(x) \mathrm{d}x. I=(−1)m−1∫abS(2)(x)S(2m)(x)dx.
此时 S ( 2 m ) S^{(2m)} S(2m)已然是分段常值函数,则:
I = ( − 1 ) m − 1 ∑ i = 1 n ∫ t i − 1 t i c i S ′ ′ ( x ) d x = ( − 1 ) m − 1 ∑ i = 1 n c i [ S ′ ( t i ) − S ′ ( t i − 1 ) ] . I = (-1)^{m-1} \sum_{i=1}^n\int_{t_{i-1}}^{t_i} c_i S''(x) \mathrm{d}x = (-1)^{m-1} \sum_{i=1}^nc_i[S'(t_i)-S'(t_{i-1})]. I=(−1)m−1i=1∑n∫ti−1ticiS′′(x)dx=(−1)m−1i=1∑nci[S′(ti)−S′(ti−1)].
所以没办法证明其为0. m + 2 , m + 3 , … m+2, m+3, \ldots m+2,m+3,…更不必证明,因为没法保证 n + 1 > m + 1 n+1>m+1 n+1>m+1等.
如果是 2 m , m − 1 2m,m-1 2m,m−1类型的,则需要证明:
I ≡ ∫ a b [ S ( m ) ( x ) ] 2 d x = 0 , I \equiv \int_a^b [S^{(m)}(x)]^2 \mathrm{d}x=0, I≡∫ab[S(m)(x)]2dx=0,
可以顺利推导到:
I = ( − 1 ) m − 1 ∫ a b S ( 1 ) ( x ) S ( 2 m − 1 ) ( x ) d x . I = (-1)^{m-1} \int_a^b S^{(1)}(x)S^{(2m-1)}(x) \mathrm{d}x. I=(−1)m−1∫abS(1)(x)S(2m−1)(x)dx.
显然也没法往下推.
定理4(奇数次自然样条最优性定理): 设 m ≤ n m\le n m≤n及 f ∈ C m + 1 [ a , b ] . f \in C^{m+1}[a,b]. f∈Cm+1[a,b]. 假设 S S S是在结点 a = t 0 < t 1 < ⋯ < t n = b a=t_0
∫ a b [ S ( m + 1 ) ( x ) ] 2 d x ≤ ∫ a b [ f ( m + 1 ) ( x ) ] 2 d x . \int_a^b [S^{(m+1)}(x)]^2 \mathrm{d}x \le \int_a^b [f^{(m+1)}(x)]^2 \mathrm{d}x. ∫ab[S(m+1)(x)]2dx≤∫ab[f(m+1)(x)]2dx.
这一节专门讨论样条函数系统,使得其他所有样条函数都可以由它的线性组合得到. 这些样条构成某些样条空间的基. 所以称为 B B B样条. 一旦给定结点, B B B样条就很容易通过递归关系产生. 而且算法也比较简单. B B B 样条以其优美的理论和数值计算中的典型性质著称. 此外, B B B杨i套还可以得到进一步的推广.
我们在无限集上讨论:
⋯ < t − 2 < t − 1 < t 0 < t 1 < t 2 < ⋯ \cdots < t_{-2} < t_{-1}
但是,在后面,我们会发现,在实际使用中,我们都只会用到有限个结点,在无限集上只是便于讨论.
首先给出0次 B B B样条的定义:
B i 0 ( x ) = { 1 x ∈ [ t i , t i + 1 ) 0 e l s e . B^0_i (x) = \left \{ \begin{array}{ll} 1 & x \in [t_i, t_{i+1}) \\ 0 & else \end{array} \right. . Bi0(x)={10x∈[ti,ti+1)else.
容易得到 ∑ i = − ∞ ∞ B i 0 ( x ) = 1 \sum_{i=-\infty}^{\infty} B_i^0(x)=1 ∑i=−∞∞Bi0(x)=1.
高次 B B B样条由递归定义:
B i k ( x ) = ( x − t i t i + k − t i ) B i k − 1 ( x ) + ( t i + k + 1 − x t i + k + 1 − t i + 1 ) B i + 1 k − 1 ( x ) ( k ≥ 1 ) . B_i^k(x) = (\frac{x-t_i}{t_{i+k}-t_i})B_i^{k-1}(x)+(\frac{t_{i+k+1}-x}{t_{i+k+1}-t_{i+1}})B^{k-1}_{i+1}(x) \quad (k\ge 1). Bik(x)=(ti+k−tix−ti)Bik−1(x)+(ti+k+1−ti+1ti+k+1−x)Bi+1k−1(x)(k≥1).
若令
V i k ( x ) = x − t i t i + k − t i , V_i^k (x) = \frac{x-t_i}{t_{i+k}-t_i}, Vik(x)=ti+k−tix−ti,
则
B i k = V i k B i k − 1 + ( 1 − V i + 1 k ) B i + 1 k − 1 . B_i^k = V_i^k B_i^{k-1} + (1-V_{i+1}^k)B^{k-1}_{i+1}. Bik=VikBik−1+(1−Vi+1k)Bi+1k−1.
引理1(B样条的支撑引理): 若 k ≥ 1 k\ge1 k≥1并且 x ∉ ( t i , t i + k + 1 ) x \not \in (t_i, t_{i+k+1}) x∈(ti,ti+k+1), 则 B i k ( x ) = 0 B_i^k(x)=0 Bik(x)=0.
引理2(B样条正性引理): 设 k ≥ 0 k\ge 0 k≥0. 若 x ∈ ( t i , t i + k + 1 ) x \in (t_i, t_{i+k+1}) x∈(ti,ti+k+1), 则 B i k ( x ) > 0 B_i^k(x)> 0 Bik(x)>0.
引理3(B样条的递归关系引理): 对一切 k ≥ 0 k\ge 0 k≥0, 我们有
∑ i = − ∞ ∞ c i B i k = ∑ i = − ∞ ∞ [ c i V i k + c i − 1 ( 1 − V i k ) ] B i k − 1 . \sum_{i=-\infty}^{\infty} c_iB_i^k = \sum_{i=-\infty}^{\infty} [c_iV_i^k+c_{i-1}(1-V_i^k)]B_i^{k-1}. i=−∞∑∞ciBik=i=−∞∑∞[ciVik+ci−1(1−Vik)]Bik−1.
**引理4(B样条单位分解引理):**对一切 k ≥ 0 k \ge 0 k≥0, 我们有
∑ i = − ∞ ∞ B i k ( x ) = 1. \sum_{i=-\infty}^{\infty} B_i^k(x) = 1. i=−∞∑∞Bik(x)=1.
记 α i k = 1 t i + k − t i \alpha_i^k = \frac{1}{t_{i+k}-t_i} αik=ti+k−ti1, 有
d d x V i k ( x ) = α i k α i k V i k + 1 = α i k + 1 V i k α i + 1 k ( 1 − V i k + 1 ) = α i k + 1 ( 1 − V i + 1 k ) . \frac{\mathrm{d}}{\mathrm{d}x} V_i^k(x) = \alpha_i^k \\ \alpha_i^k V_i^{k+1} = \alpha_i^{k+1}V_i^k \\ \alpha_{i+1}^k (1-V_i^{k+1})=\alpha_i^{k+1} (1-V_{i+1}^k). dxdVik(x)=αikαikVik+1=αik+1Vikαi+1k(1−Vik+1)=αik+1(1−Vi+1k).
引理5(B样条导数引理): 对于 k ≥ 2 k\ge 2 k≥2, B样条函数的导数可如下计算:
d d x B i k ( x ) = ( k t i + 1 − t i ) B i k − 1 ( x ) − ( k t i + k + 1 − t i + 1 ) B i + 1 k − 1 ( x ) . \frac{\mathrm{d}}{\mathrm{d}x} B_i^k(x) = (\frac{k}{t_{i+1}-t_i}) B_i^{k-1}(x) - (\frac{k}{t_{i+k+1}-t_{i+1}})B_{i+1}^{k-1}(x). dxdBik(x)=(ti+1−tik)Bik−1(x)−(ti+k+1−ti+1k)Bi+1k−1(x).
引理6(B样条光滑性引理): 对于 k ≥ 1 k \ge 1 k≥1, B 样条 B i k B_i^k Bik属于连续函数类 C k − 1 ( R ) C^{k-1}(\R) Ck−1(R).
从与B样条导数相关的引理,可得:
d d x ∑ i = − ∞ ∞ c i B i k ( x ) = k ∑ i = − ∞ ∞ ( c i − c i − 1 t i + 1 − t i ) B i k − 1 ( x ) ( k ≥ 2 ) . \frac{\mathrm{d}}{\mathrm{d}x} \sum_{i=-\infty}^{\infty} c_i B_i^k(x) = k \sum_{i=-\infty}^{\infty} (\frac{c_i-c_{i-1}}{t_{i+1}-t_i})B_i^{k-1}(x) \quad (k \ge 2). dxdi=−∞∑∞ciBik(x)=ki=−∞∑∞(ti+1−tici−ci−1)Bik−1(x)(k≥2).
引理7(B样条积分引理) B样条函数的积分可如下计算:
∫ − ∞ x B i k ( s ) d s = ( t i + k + 1 − t i k + 1 ) ∑ j = i ∞ B j k + 1 ( x ) . \int_{-\infty}^x B_i^k(s) \mathrm{d}s = (\frac{t_{i+k+1}-t_i}{k+1})\sum_{j=i}^{\infty}Bj^{k+1}(x). ∫−∞xBik(s)ds=(k+1ti+k+1−ti)j=i∑∞Bjk+1(x).
引理8(B样条线性无关性引理): B 样条集合 { B j k , B j + 1 k , ⋯ , B j + k k } \{B_j^k, B_{j+1}^k, \cdots, B_{j+k}^k\} {Bjk,Bj+1k,⋯,Bj+kk}在 ( t k + j , t k + j + 1 ) (t_{k+j},t_{k+j+1}) (tk+j,tk+j+1)上线性无关.
引理9(B样条线性无关性引理): B样条集合 { B − k k , B − k + 1 k , ⋯ , B n − 1 k } \{B_{-k}^k, B_{-k+1}^k, \cdots, B_{n-1}^k\} {B−kk,B−k+1k,⋯,Bn−1k}在 ( t 0 , t n ) (t_0, t_n) (t0,tn)上线性无关.
记由在区间 [ t 0 , t 1 ] , [ t 1 , t 2 ] , ⋯ , [ t n − 1 , t n ] [t_0, t_1], [t_1, t_2], \cdots, [t_{n-1}, t_n] [t0,t1],[t1,t2],⋯,[tn−1,tn]上的 k k k次样条函数所构成线性空间为 S n k \mathcal{S}_n^k Snk.
定理1(空间 S n k \mathcal{S}_n^k Snk的基定理): 空间 S n k \mathcal{S}_n^k Snk的一个基是
{ B i k ∣ [ t 0 , t n ] : − k ≤ i ≤ n − 1 } \{ B_i^k| [t_0, t_n]:-k\le i \le n-1\} {Bik∣[t0,tn]:−k≤i≤n−1}
从而, S n k \mathcal{S}_n^k Snk的维数是 k + n k+n k+n.
插值矩阵A的定义:
A i j = B j k ( x i ) ( i ≤ i , j ≤ n ) . A_{ij} = B_j^k(x_i) \quad (i \le i,j \le n). Aij=Bjk(xi)(i≤i,j≤n).
引理1 (插值矩阵引理1): 若插值矩阵非奇异,则 A i i ≠ 0 , 1 ≤ i ≤ n A_{ii} \not = 0, \: 1 \le i \le n Aii=0,1≤i≤n.
引理2(插值矩阵引理2): 若 k = 1 k=1 k=1并且对于 1 ≤ i ≤ n 1 \le i \le n 1≤i≤n有 t i < x i < t i + 2 t_i < x_i < t_{i+2} ti<xi<ti+2, 则 A A A非奇异.
定理2 (Schoenberg-Whitney定理): 设 x 1 < x 2 ⋯ < x n x_1 < x_2 \cdots < x_n x1<x2⋯<xn. 已知 A i j = B j k ( x i ) A_{ij}=B_j^k(x_i) Aij=Bjk(xi),则矩阵 A A A非奇异当且仅当其主对角线上不含零元.
定理3(B样条插值定理): 若 [ t 0 , t n ] [t_0,t_n] [t0,tn]中的结点 x 1 , x 2 , ⋯ , x n + k x_1 , x_2, \cdots, x_{n+k} x1,x2,⋯,xn+k满足
t i − k − 1 < x i < t i ( 1 ≤ i ≤ n + k ) , t_{i-k-1}< x_i < t_i \quad (1 \le i \le n+k), ti−k−1<xi<ti(1≤i≤n+k),
则能用样条空间 S n k \mathcal{S}_n^k Snk插值这组节点上的任意一组数据.
注意到,如果我们的插值结点恰好就是 t 0 , ⋯ , t n t_0, \cdots, t_n t0,⋯,tn, 那么仅有 n + 1 n+1 n+1个方程,还有 k − 1 k-1 k−1个自由度,此时方程的解是不唯一的。