最佳平方逼近
∑
k
=
0
n
W
k
(
f
(
x
k
)
−
ϕ
(
x
k
)
)
2
=
min
\sum_{k=0}^{ n}W_k (f(x_k)-\phi (x_k))^2=\min
k=0∑nWk(f(xk)−ϕ(xk))2=min
→
节点非常多时
∫
a
b
ρ
(
x
)
(
f
(
x
)
−
ϕ
(
x
)
)
2
d
x
=
min
\xrightarrow[]{\text{节点非常多时}} \int_a^b \rho(x)(f(x)-\phi(x))^2 \mathrm dx=\min
节点非常多时∫abρ(x)(f(x)−ϕ(x))2dx=min
ϕ
(
x
)
为拟合函数
,
ρ
(
x
)
为权函数
,
都已知
\phi(x)\text{为拟合函数} \,\,,\,\, \rho(x) \text{为权函数} \,\,,\,\,都已知
ϕ(x)为拟合函数,ρ(x)为权函数,都已知
解正规方程组:
[
(
ϕ
0
,
ϕ
0
)
⋯
(
ϕ
0
,
ϕ
m
)
⋮
⋱
⋮
(
ϕ
m
,
ϕ
0
)
⋯
(
ϕ
m
,
ϕ
m
)
]
[
a
0
⋮
a
m
]
=
[
(
ϕ
0
,
f
)
⋮
(
ϕ
m
,
f
)
]
\begin{bmatrix} (\phi_0,\phi_0) & \cdots & (\phi_0,\phi_m) \\ \vdots & \ddots & \vdots \\ (\phi_m,\phi_0) & \cdots & (\phi_m,\phi_m) \end{bmatrix}\begin{bmatrix} a_0\\\vdots\\a_m \end{bmatrix} = \begin{bmatrix} (\phi_0,f)\\ \vdots \\ (\phi_m,f) \end{bmatrix}
(ϕ0,ϕ0)⋮(ϕm,ϕ0)⋯⋱⋯(ϕ0,ϕm)⋮(ϕm,ϕm)
a0⋮am
=
(ϕ0,f)⋮(ϕm,f)
其中
(
h
,
g
)
=
∫
a
b
ρ
(
x
)
h
(
x
)
g
(
x
)
d
x
(h,g)=\int_{a}^b \rho(x)h(x)g(x) \mathrm dx
(h,g)=∫abρ(x)h(x)g(x)dx
解出的
ϕ
(
x
)
\phi(x)
ϕ(x) 为
f
(
x
)
f(x)
f(x) 的最佳平方逼近函数。
[!example]-
求 f ( x ) = x 4 f(x)=x^4 f(x)=x4 在 [ − 1 , 1 ] {[-1,1]} [−1,1] 上关于权函数 ρ ( x ) = 1 {\rho(x)=1} ρ(x)=1 的二次最佳平方逼近多项式。
解:设 ϕ ( x ) = a + b x + c x 2 {\phi(x)=a+bx+cx^2} ϕ(x)=a+bx+cx2 ,则基函数
ϕ 0 ( x ) = 1 , ϕ 1 ( x ) = x , ϕ 2 ( x ) = x 2 \phi_0(x)=1 \,\,,\,\, \phi_1(x)=x \,\,,\,\, \phi_2(x)=x^2 ϕ0(x)=1,ϕ1(x)=x,ϕ2(x)=x2
内积空间:
M = span { 1 , x , x 2 } M= \text{span}\lbrace 1,x,x^2\rbrace M=span{1,x,x2}
对应的法方程组:
[ ( ϕ 0 , ϕ 0 ) ( ϕ 0 , ϕ 1 ) ( ϕ 0 , ϕ 2 ) ( ϕ 1 , ϕ 0 ) ( ϕ 1 , ϕ 1 ) ( ϕ 1 , ϕ 2 ) ( ϕ 2 , ϕ 0 ) ( ϕ 2 , ϕ 1 ) ( ϕ 2 , ϕ 2 ) ] [ a b c ] = [ ( ϕ 0 , f ) ( ϕ 1 , f ) ( ϕ 2 , f ) ] \begin{bmatrix} (\phi_0,\phi_0) & (\phi_0,\phi_1) & (\phi_0,\phi_2)\\ (\phi_1,\phi_0) & (\phi_1,\phi_1) & (\phi_1,\phi_2)\\ (\phi_2,\phi_0) & (\phi_2,\phi_1) & (\phi_2,\phi_2) \end{bmatrix} \begin{bmatrix} a\\b\\c \end{bmatrix}= \begin{bmatrix} (\phi_0,f)\\(\phi_1,f)\\(\phi_2,f) \end{bmatrix} (ϕ0,ϕ0)(ϕ1,ϕ0)(ϕ2,ϕ0)(ϕ0,ϕ1)(ϕ1,ϕ1)(ϕ2,ϕ1)(ϕ0,ϕ2)(ϕ1,ϕ2)(ϕ2,ϕ2) abc = (ϕ0,f)(ϕ1,f)(ϕ2,f)
用内积公式:
( h , g ) = ∫ − 1 1 h ( x ) g ( x ) d x (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∫−11x2dx=32∫−11x4dx=52∫−11x4dx=52∫−11x5dx=0∫−11x6dx=72
所以法方程组为:
[ 2 0 2 / 3 0 2 / 3 0 2 / 3 0 2 / 5 ] [ a b c ] = [ 2 / 5 0 2 / 7 ] \begin{bmatrix} 2 & 0 & 2/3 \\ 0 & 2/3 & 0 \\ 2/3 & 0 & 2/5 \end{bmatrix} \begin{bmatrix} a\\b\\c \end{bmatrix}= \begin{bmatrix} 2/5\\0\\2/7 \end{bmatrix} 202/302/302/302/5 abc = 2/502/7
解得:
a = − 3 35 , b = 0 , c = 6 7 a=- \frac{3}{35} \,\,,\,\, b=0 \,\,,\,\, c= \frac{6}{7} a=−353,b=0,c=76
∴ ϕ ( x ) = − 3 35 + 6 7 x 2 \therefore \phi(x)=- \frac{3}{35}+ \frac{6}{7}x^2 ∴ϕ(x)=−353+76x2
最佳逼近
勒让德多项式逼近
因为用
ϕ
0
,
ϕ
1
,
ϕ
2
(
1
,
x
,
x
2
)
\phi_0,\phi_1,\phi_2(1,x,x^2)
ϕ0,ϕ1,ϕ2(1,x,x2) 计算量大,而且易出现病态方程(解不出)
所以需要一种法方程矩阵简单的基函数,所以用勒让德多项式
p
0
=
1
p
1
=
x
p
2
=
1
2
(
3
x
2
−
1
)
p
3
=
1
2
(
5
x
3
−
3
x
)
p
4
=
1
8
(
35
x
4
−
30
x
2
+
3
)
p
n
+
1
=
2
n
+
1
n
+
1
x
p
n
−
n
n
+
1
p
n
−
1
\begin{align*} p_0=&1\\ p_1=&x\\ p_2= &\frac{1}{2}(3x^2-1)\\ p_3=& \frac{1}{2}(5x^3-3x)\\ p_4=& \frac{1}{8}(35x^4-30x^2+3) \\ \\ p_{n+1} = & \frac{2n+1}{n+1}xp_n- \frac{n}{n+1}p_{n-1} \end{align*}
p0=p1=p2=p3=p4=pn+1=1x21(3x2−1)21(5x3−3x)81(35x4−30x2+3)n+12n+1xpn−n+1npn−1
(
p
i
,
p
j
)
=
{
0
,
i
≠
j
2
/
(
2
j
+
1
)
,
i
=
j
(p_i,p_j)= \begin{cases} 0&,i \ne j \\\\ 2/(2j+1)&,i=j \end{cases}
(pi,pj)=⎩
⎨
⎧02/(2j+1),i=j,i=j
使得发方程矩阵为对角阵。
适用条件
[
−
1
,
1
]
{[-1,1]}
[−1,1]
对于
f
(
x
)
,
x
∈
[
a
,
b
]
{f(x),x\in[a,b]}
f(x),x∈[a,b] 可以将
x
=
(
a
+
b
)
2
+
(
b
−
a
)
2
t
x= \frac{(a+b)}{2}+ \frac{(b-a)}{2}t
x=2(a+b)+2(b−a)t
用
t
{t}
t 替代,则
t
∈
[
−
1
,
1
]
{t\in[-1,1]}
t∈[−1,1]
[!example]-
求 f ( x ) = x 4 f(x)=x^4 f(x)=x4 在 [ − 1 , 1 ] {[-1,1]} [−1,1] 上关于权函数 ρ ( x ) = 1 {\rho(x)=1} ρ(x)=1 的二次最佳平方逼近多项式。
解:使用勒让德多项式列出法方程组
[ 2 0 0 0 2 / 3 0 0 0 2 / 5 ] [ a b c ] = [ ( p 0 , f ) ( p 1 , f ) ( p 2 , f ) ] \begin{bmatrix} 2 & 0 & 0 \\ 0 & 2/3 & 0 \\ 0 & 0 & 2/5 \end{bmatrix}\begin{bmatrix} a\\b\\c \end{bmatrix}= \begin{bmatrix} (p_0,f)\\(p_1,f)\\(p_2,f) \end{bmatrix} 20002/30002/5 abc = (p0,f)(p1,f)(p2,f)
( p 0 , f ) = ∫ − 1 1 1 ⋅ x 4 d x = 2 5 ( p 1 , f ) = ∫ − 1 1 x ⋅ x 4 d x = 0 ( p 2 , f ) = ∫ − 1 1 1 2 ( 3 x 2 − 1 ) x 4 d x = 8 35 \begin{align*} (p_0,f)=&\int_{-1}^1 1 \cdot x^4 \mathrm dx= \frac{2}{5}\\ (p_1,f)=&\int_{-1}^1 x \cdot x^4 \mathrm dx=0 \\ (p_2,f)=&\int_{-1}^1 \frac{1}{2}(3x^2-1)x^4 \mathrm dx= \frac{8}{35} \end{align*} (p0,f)=(p1,f)=(p2,f)=∫−111⋅x4dx=52∫−11x⋅x4dx=0∫−1121(3x2−1)x4dx=358
[ 2 0 0 0 2 / 3 0 0 0 2 / 5 ] [ a b c ] = [ 2 / 5 0 8 / 35 ] \begin{bmatrix} 2 & 0 & 0 \\ 0 & 2/3 & 0 \\ 0 & 0 & 2/5 \end{bmatrix}\begin{bmatrix} a\\b\\c \end{bmatrix}= \begin{bmatrix} 2/5\\0\\8/35 \end{bmatrix} 20002/30002/5 abc = 2/508/35
解出
a = 1 5 , b = 0 , c = 4 7 a= \frac{1}{5} \,\,,\,\, b=0 \,\,,\,\, c= \frac{4}{7} a=51,b=0,c=74
逼近函数
S ( x ) = 1 5 + 2 7 ( 3 x 2 − 1 ) = − 3 35 + 6 7 x 2 S(x)= \frac{1}{5}+ \frac{2}{7}(3x^2-1)= - \frac{3}{35} + \frac{6}{7}x^2 S(x)=51+72(3x2−1)=−353+76x2
与最佳平方逼近得到的结果是一样的。
切比雪夫多项式逼近
针对权函数为
1
1
−
x
2
\frac{1}{ \sqrt{1-x^2}}
1−x21
范围
x
∈
[
−
1
,
1
]
{x\in[-1,1]}
x∈[−1,1] ,
T
n
(
x
)
=
cos
(
n
⋅
arccos
(
x
)
)
=
2
x
T
n
−
1
(
x
)
−
T
n
−
2
(
x
)
T_n(x)=\cos(n \cdot \arccos(x))=2xT_{n-1}(x)-T_{n-2}(x)
Tn(x)=cos(n⋅arccos(x))=2xTn−1(x)−Tn−2(x)
(
T
0
,
T
0
)
=
π
(
T
1
,
T
1
)
=
π
2
=
(
T
2
,
T
2
)
\begin{align*} (T_0,T_0)=&\pi\\ (T_1,T_1)=& \frac{\pi}{2}=(T_2,T_2)\\ \end{align*}
(T0,T0)=(T1,T1)=π2π=(T2,T2)
T
0
=
1
T
1
=
x
T
2
=
2
x
2
−
1
T
3
=
4
x
3
−
3
x
\begin{align*} T_0=&1\\ T_1=&x\\ T_2=&2x^2-1\\ T_3=&4x^3-3x \end{align*}
T0=T1=T2=T3=1x2x2−14x3−3x
(
T
0
,
f
)
=
∫
−
1
1
f
(
x
)
⋅
1
⋅
1
1
−
x
2
d
x
(
T
1
,
f
)
=
∫
−
1
1
f
(
x
)
⋅
x
⋅
1
1
−
x
2
d
x
(
T
2
,
f
)
=
∫
−
1
1
f
(
x
)
⋅
(
2
x
2
−
1
)
⋅
1
1
−
x
2
d
x
\begin{align*} (T_0,f)=&\int_{-1}^1f(x) \cdot 1 \cdot \frac{1}{ \sqrt{1-x^2}} \mathrm dx\\ (T_1,f)=&\int_{-1}^1 f(x) \cdot x \cdot \frac{1}{ \sqrt{1-x^2}} \mathrm dx\\ (T_2,f)=&\int_{-1}^1 f(x) \cdot (2x^2-1) \cdot \frac{1}{ \sqrt{1-x^2}} \mathrm dx\\ \end{align*}
(T0,f)=(T1,f)=(T2,f)=∫−11f(x)⋅1⋅1−x21dx∫−11f(x)⋅x⋅1−x21dx∫−11f(x)⋅(2x2−1)⋅1−x21dx
P
n
(
x
)
=
T
0
(
T
0
,
f
)
(
T
0
,
T
0
)
+
T
1
(
f
,
T
1
)
(
T
1
,
T
1
)
+
⋯
+
T
n
(
f
,
T
n
)
(
T
n
,
T
n
)
=
(
T
0
,
f
)
π
+
⋯
\begin{align*} P_n(x)=& T_0 \frac{(T_0,f)}{(T_0,T_0)}+T_1 \frac{(f,T_1)}{(T_1,T_1)}+ \cdots +T_n \frac{(f,T_n)}{(T_n,T_n)} \\ =& \frac{(T_0,f)}{\pi}+ \cdots \end{align*}
Pn(x)==T0(T0,T0)(T0,f)+T1(T1,T1)(f,T1)+⋯+Tn(Tn,Tn)(f,Tn)π(T0,f)+⋯
matlab画切比雪夫多项式的函数图像
xx = linspace(-1,1,100)
a = ones(size(xx));
T(1,:) = a
T(2,:) = xx
for i = 3:6
T(i,:) = 2.*xx.*T(i-1,:)-T(i-2,:)
end
for i = 1:5
plot(xx,T(i,:));
hold on
end