legendre多项式与gauss-legendre积分

本文详细介绍了Legendre多项式的定义、推导过程、五个关键引理及其应用,包括正交性、模长证明和递推公式。通过引理和数学分析,展示了Legendre多项式的零点分布,并给出了与三对角矩阵谱的关系。此外,还演示了使用高斯-勒让德积分求解特定积分问题的方法。
摘要由CSDN通过智能技术生成

写作目的

最近在学谱方法解偏微分方程,顺便学一下legendre多项式的一些推导,参考了北京大学蓝以中老师的《高等代数学习指南》,发博客以记之。

Legendre多项式定义

P 0 ( x ) = 1 P k ( x ) = 1 2 k k ! d k [ ( x 2 − 1 ) k ] d x k , k = { 1 , 2 , ⋯ } (1) {P_0}\left( x \right) = 1\newline{P_k}\left( x \right) = \frac{1}{{{2^k}k!}}\frac{{{d^k}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^k}}},k = \left\{ {1,2, \cdots } \right\}\tag{1} P0(x)=1Pk(x)=2kk!1dxkdk[(x21)k],k={1,2,}(1)

五个引理

  1. 莱布尼茨求导法则:
    ( u v ) ( k ) = ∑ i = 0 k C k i u ( i ) v ( k − i ) (2) {\left( {uv} \right)^{\left( k \right)}} = \sum\limits_{i = 0}^k {C_k^i{u^{\left( i \right)}}{v^{\left( {k - i} \right)}}} \tag{2} (uv)(k)=i=0kCkiu(i)v(ki)(2)
  2. 利用分部积分,有: ∫ a b u ( m ) v d x = u ( m − 1 ) v ∣ a b − ∫ a b u ( m − 1 ) v ( 1 ) d x = ⋯ = [ u ( m − 1 ) v − u ( m − 2 ) v ( 1 ) + u ( m − 3 ) v ( 2 ) + ⋯ + ( − 1 ) m − 1 u v ( m − 1 ) ] ∣ a b + ( − 1 ) m ∫ a b u v ( m ) d x (3) \int\limits_a^b {{u^{\left( m \right)}}vdx = } {u^{\left( {m - 1} \right)}}v|_a^b - \int\limits_a^b {{u^{\left( {m - 1} \right)}}{v^{\left( 1 \right)}}dx = } \cdots \newline = \left[ {{u^{\left( {m - 1} \right)}}v - {u^{\left( {m - 2} \right)}}{v^{\left( 1 \right)}} + {u^{\left( {m - 3} \right)}}{v^{\left( 2 \right)}} + \cdots + \newline {{\left( { - 1} \right)}^{m - 1}}u{v^{\left( {m - 1} \right)}}} \right]|_a^b \newline+ {\left( { - 1} \right)^m}\int\limits_a^b {u{v^{\left( m \right)}}dx} \tag{3} abu(m)vdx=u(m1)vababu(m1)v(1)dx==[u(m1)vu(m2)v(1)+u(m3)v(2)++(1)m1uv(m1)]ab+(1)mabuv(m)dx(3)
  3. 引理三:(x^2-1)整除关系
    1 ≤ l < k 1 \le l < k 1l<k ( x 2 − 1 ) ∣ d l [ ( x 2 − 1 ) k ] d x l (4) \left( {{x^2} - 1} \right)|\frac{{{d^l}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^l}}} \tag{4} (x21)dxldl[(x21)k](4)
    这里蓝以中老师的书中用了归纳法证明,实际上不需要,很容易看出 ( x 2 − 1 ) k = ( x − 1 ) k ( x + 1 ) k {\left( {{x^2} - 1} \right)^k} = {\left( {x - 1} \right)^k}{\left( {x + 1} \right)^k} (x21)k=(x1)k(x+1)k并利用引理2直接推出
    d l [ ( x 2 − 1 ) k ] d x l = ∑ i = 0 l C l i d i [ ( x + 1 ) k ] d x i d l − i [ ( x − 1 ) k ] d x l − i (4.5) \frac{{{d^l}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^l}}} = \sum\limits_{i = 0}^l {C_l^i\frac{{{d^i}\left[ {{{\left( {x + 1} \right)}^k}} \right]}}{{d{x^i}}}} \frac{{{d^{l - i}}\left[ {{{\left( {x - 1} \right)}^k}} \right]}}{{d{x^{l - i}}}} \tag{4.5} dxldl[(x21)k]=i=0lClidxidi[(x+1)k]dxlidli[(x1)k](4.5)
    直接看出求和项中每一项都可以被(x^2-1)整除即证。
    4.引理4:这个好像挺基础吧
    ∫ 0 π 2 cos ⁡ 2 n + 1 ( x ) d x = 2 n 2 n + 1 × 2 n − 2 2 n − 1 × ⋯ × 2 3 (5) \int\limits_0^{\frac{\pi }{2}} {{{\cos }^{2n + 1}}\left( x \right)} dx = \frac{{2n}}{{2n + 1}} \times \frac{{2n - 2}}{{2n - 1}} \times \cdots \times \frac{2}{3} \tag{5} 02πcos2n+1(x)dx=2n+12n×2n12n2××32(5)
    5.引理5:这个也显然:
    P k ( 1 ) = 1 {P_k}\left( 1 \right) = 1 Pk(1)=1
    事实上,运用展开式(4.5)直接看出

勒让德多项式正交性证明:

1 ≤ l < k 1 \le l < k 1l<k时,可以得到:
∫ − 1 1 P l ( x ) P k ( x ) d x = 1 2 k + l k ! l ! ∫ − 1 1 d k [ ( x 2 − 1 ) k ] d x k d l [ ( x 2 − 1 ) l ] d x l d x \int\limits_{ - 1}^1 {{P_l}} \left( x \right){P_k}\left( x \right)dx = \frac{1}{{{2^{k + l}}k!l!}}\int\limits_{ - 1}^1 {\frac{{{d^k}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^k}}}} \frac{{{d^l}\left[ {{{\left( {{x^2} - 1} \right)}^l}} \right]}}{{d{x^l}}}dx 11Pl(x)Pk(x)dx=2k+lk!l!111dxkdk[(x21)k]dxldl[(x21)l]dx
利用引理2可以得到:
2 k + l k ! l ! ∫ − 1 1 P l ( x ) P k ( x ) d x = d k − 1 [ ( x 2 − 1 ) k ] d x k − 1 × d l [ ( x 2 − 1 ) l ] d x l ∣ − 1 1 − d k − 2 [ ( x 2 − 1 ) k ] d x k − 2 × d l + 1 [ ( x 2 − 1 ) l ] d x l + 1 ∣ − 1 1 + ⋯ + ( − 1 ) l d k − l − 1 [ ( x 2 − 1 ) k ] d x k − l − 1 × d 2 l [ ( x 2 − 1 ) l ] d x 2 l ∣ − 1 1 + ( − 1 ) l + 1 ∫ − 1 1 d k − l − 1 [ ( x 2 − 1 ) k ] d x k − l − 1 × d 2 l + 1 [ ( x 2 − 1 ) l ] d x 2 l + 1 d x {2^{k + l}}k!l!\int\limits_{ - 1}^1 {{P_l}} \left( x \right){P_k}\left( x \right)dx = \frac{{{d^{k - 1}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{k - 1}}}} \times \frac{{{d^l}\left[ {{{\left( {{x^2} - 1} \right)}^l}} \right]}}{{d{x^l}}}|_{ - 1}^1\newline - \frac{{{d^{k - 2}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{k - 2}}}} \times \frac{{{d^{l + 1}}\left[ {{{\left( {{x^2} - 1} \right)}^l}} \right]}}{{d{x^{l + 1}}}}|_{ - 1}^1 + \cdots \newline+ {\left( { - 1} \right)^l}\frac{{{d^{k - l - 1}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{k - l - 1}}}} \times \frac{{{d^{2l}}\left[ {{{\left( {{x^2} - 1} \right)}^l}} \right]}}{{d{x^{2l}}}}|_{ - 1}^1 \newline+ {\left( { - 1} \right)^{l + 1}}\int\limits_{ - 1}^1 {\frac{{{d^{k - l - 1}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{k - l - 1}}}} \times \frac{{{d^{2l + 1}}\left[ {{{\left( {{x^2} - 1} \right)}^l}} \right]}}{{d{x^{2l + 1}}}}dx} 2k+lk!l!11Pl(x)Pk(x)dx=dxk1dk1[(x21)k]×dxldl[(x21)l]11dxk2dk2[(x21)k]×dxl+1dl+1[(x21)l]11++(1)ldxkl1dkl1[(x21)k]×dx2ld2l[(x21)l]11+(1)l+111dxkl1dkl1[(x21)k]×dx2l+1d2l+1[(x21)l]dx
利用引理3,除了积分号之外的结果都是0,积分号下第二项是对一个2l次的多项式求2l+1次导数,故为零,所以证明了legendre多项式的正交性。

模长证明

∫ − 1 1 P k 2 ( x ) d x = ( 1 k ! 2 k ) 2 ∫ − 1 1 d k [ ( x 2 − 1 ) k ] d x k × d k [ ( x 2 − 1 ) k ] d x k d x \int\limits_{ - 1}^1 {P_k^2\left( x \right)} dx = {\left( {\frac{1}{{k!{2^k}}}} \right)^2}\int\limits_{ - 1}^1 {\frac{{{d^k}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^k}}}} \times \frac{{{d^k}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^k}}}dx \newline 11Pk2(x)dx=(k!2k1)211dxkdk[(x21)k]×dxkdk[(x21)k]dx
同样运用引理2得到
( k ! 2 k ) 2 ∫ − 1 1 P k 2 ( x ) d x = d k − 1 [ ( x 2 − 1 ) k ] d x k − 1 × d k [ ( x 2 − 1 ) k ] d x k ∣ − 1 1 − d k − 2 [ ( x 2 − 1 ) k ] d x k − 2 × d k + 1 [ ( x 2 − 1 ) k ] d x k + 1 ∣ − 1 1 + ⋯ + ( − 1 ) k d [ ( x 2 − 1 ) k ] d x × d 2 k − 2 [ ( x 2 − 1 ) k ] d x 2 k − 2 ∣ − 1 1 + ( − 1 ) k + 1 ( x 2 − 1 ) × d 2 k − 1 [ ( x 2 − 1 ) k ] d x 2 k − 1 ∣ − 1 1 + ( − 1 ) k + 2 ∫ − 1 1 ( x 2 − 1 ) 2 d 2 k [ ( x 2 − 1 ) k ] d x 2 k d x (6) {\left( {k!{2^k}} \right)^2}\int\limits_{ - 1}^1 {P_k^2\left( x \right)} dx = \frac{{{d^{k - 1}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{k - 1}}}} \times \frac{{{d^k}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^k}}}|_{ - 1}^1\newline - \frac{{{d^{k - 2}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{k - 2}}}} \times \frac{{{d^{k + 1}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{k + 1}}}}|_{ - 1}^1 + \cdots + \newline {\left( { - 1} \right)^k}\frac{{d\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{dx}} \times \frac{{{d^{2k - 2}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{2k - 2}}}}|_{ - 1}^1 \newline + {\left( { - 1} \right)^{k + 1}}\left( {{x^2} - 1} \right) \times \frac{{{d^{2k - 1}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{2k - 1}}}}|_{ - 1}^1 \newline + {\left( { - 1} \right)^{k + 2}}\int\limits_{ - 1}^1 {{{\left( {{x^2} - 1} \right)}^2}} \frac{{{d^{2k}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{2k}}}}dx \tag{6} (k!2k)211Pk2(x)dx=dxk1dk1[(x21)k]×dxkdk[(x21)k]11dxk2dk2[(x21)k]×dxk+1dk+1[(x21)k]11++(1)kdxd[(x21)k]×dx2k2d2k2[(x21)k]11+(1)k+1(x21)×dx2k1d2k1[(x21)k]11+(1)k+211(x21)2dx2kd2k[(x21)k]dx(6)
同样(6)等式右端只有积分号下不为0,得到:
( k ! 2 k ) 2 ∫ − 1 1 P k 2 ( x ) d x = ( − 1 ) k + 2 ∫ − 1 1 ( x 2 − 1 ) 2 d 2 k [ ( x 2 − 1 ) k ] d x 2 k d x = ( − 1 ) k ( 2 k ) ! ∫ − 1 1 ( x 2 − 1 ) 2 d x (7) {\left( {k!{2^k}} \right)^2}\int\limits_{ - 1}^1 {P_k^2\left( x \right)} dx = {\left( { - 1} \right)^{k + 2}}\int\limits_{ - 1}^1 {{{\left( {{x^2} - 1} \right)}^2}} \frac{{{d^{2k}}\left[ {{{\left( {{x^2} - 1} \right)}^k}} \right]}}{{d{x^{2k}}}}dx = \newline{\left( { - 1} \right)^k}\left( {2k} \right)!\int\limits_{ - 1}^1 {{{\left( {{x^2} - 1} \right)}^2}} dx \tag{7} (k!2k)211Pk2(x)dx=(1)k+211(x21)2dx2kd2k[(x21)k]dx=(1)k(2k)!11(x21)2dx(7)
(7)中最后式子利用三角积分换元与对称性得到:
( − 1 ) k ( 2 k ) ! ∫ − 1 1 ( x 2 − 1 ) 2 d x = 2 × ( − 1 ) 2 k × ( 2 k ) ! ∫ 0 π 2 cos ⁡ 2 k + 1 ( x ) d x (8) {\left( { - 1} \right)^k}\left( {2k} \right)!\int\limits_{ - 1}^1 {{{\left( {{x^2} - 1} \right)}^2}} dx =\newline 2 \times {\left( { - 1} \right)^{2k}} \times \left( {2k} \right)!\int\limits_0^{\frac{\pi }{2}} {{{\cos }^{2k + 1}}\left( x \right)dx} \tag{8} (1)k(2k)!11(x21)2dx=2×(1)2k×(2k)!02πcos2k+1(x)dx(8)
(8)利用引理4得到:
∫ − 1 1 P k 2 ( x ) d x = 1 ( k ! 2 k ) 2 × ( 2 × ( 2 k ) ! ) × 2 k 2 k + 1 × 2 k − 2 2 k − 1 × ⋯ × 2 3 = 2 2 k + 1 (9) \int\limits_{ - 1}^1 {P_k^2} \left( x \right)dx = \frac{1}{{{{\left( {k!{2^k}} \right)}^2}}} \times \left( {2 \times \left( {2k} \right)!} \right) \times \newline\frac{{2k}}{{2k + 1}} \times \frac{{2k - 2}}{{2k - 1}} \times \cdots \times \frac{2}{3} = \frac{2}{{2k + 1}} \tag{9} 11Pk2(x)dx=(k!2k)21×(2×(2k)!)×2k+12k×2k12k2××32=2k+12(9)

递推公式证明

考虑欧氏空间 R [ x ] n + 2 R{\left[ x \right]_{n + 2}} R[x]n+2
存在一组正交基 P 0 ( x ) , P 1 ( x ) , ⋯   , P n + 1 ( x ) {P_0}\left( x \right),{P_1}\left( x \right), \cdots ,{P_{n + 1}}\left( x \right) P0(x),P1(x),,Pn+1(x)
则n+1次多项式可被正交基唯一地线性表示 x P n ( x ) = c n + 1 P 0 ( x ) + c n P 1 ( x ) + ⋯ + c 0 P n + 1 ( x ) (10) x{P_n}\left( x \right) = {c_{n + 1}}{P_0}\left( x \right) + {c_n}{P_1}\left( x \right) + \cdots + {c_0}{P_{n + 1}}\left( x \right) \tag{10} xPn(x)=cn+1P0(x)+cnP1(x)++c0Pn+1(x)(10)
则先证明:
c 3 = c 4 = ⋯ = c n + 1 = 0 {c_3} = {c_4} = \cdots = {c_{n + 1}} = 0 c3=c4==cn+1=0
事实上,等式(10)两边乘以P_0(x)并积分得到
∫ − 1 1 x P n ( x ) P 0 ( x ) d x = c n + 1 ∫ − 1 1 P 0 2 ( x ) d x \int\limits_{ - 1}^1 {x{P_n}\left( x \right){P_0}\left( x \right)} dx = {c_{n + 1}}\int\limits_{ - 1}^1 {P_0^2\left( x \right)} dx 11xPn(x)P0(x)dx=cn+111P02(x)dx
且:
∂ ( x P 0 ( x ) ) = 1 < n ⇒ ∫ − 1 1 x P n ( x ) P 0 ( x ) d x = 0 ⇒ c n + 1 = 0 ∂ ( x P 1 ( x ) ) = 2 < n ⇒ ∫ − 1 1 x P n ( x ) P 1 ( x ) d x = 0 ⇒ c n = 0 ⋯ ∂ ( x P n − 2 ( x ) ) = n − 1 < n ⇒ ∫ − 1 1 x P n ( x ) P n − 2 ( x ) d x = 0 ⇒ c 3 = 0 \partial \left( {x{P_0}\left( x \right)} \right) = 1 < n \Rightarrow \int\limits_{ - 1}^1 {x{P_n}\left( x \right){P_0}\left( x \right)} dx = 0 \Rightarrow c_{n+1}=0\newline \partial \left( {x{P_1}\left( x \right)} \right) = 2 < n \Rightarrow \int\limits_{ - 1}^1 {x{P_n}\left( x \right){P_1}\left( x \right)} dx = 0 \Rightarrow c_{n}=0\newline \cdots \newline \partial \left( {x{P_{n-2}}\left( x \right)} \right) = n-1 < n \Rightarrow \int\limits_{ - 1}^1 {x{P_n}\left( x \right){P_{n-2}}\left( x \right)} dx = 0 \Rightarrow c_{3}=0 (xP0(x))=1<n11xPn(x)P0(x)dx=0cn+1=0(xP1(x))=2<n11xPn(x)P1(x)dx=0cn=0(xPn2(x))=n1<n11xPn(x)Pn2(x)dx=0c3=0
因此
x P n ( x ) = c 0 P n + 1 ( x ) + c 1 P n ( x ) + c 2 P n − 1 ( x ) (11) x{P_n}\left( x \right) = {c_0}{P_{n + 1}}\left( x \right) + {c_1}{P_n}\left( x \right) + {c_2}{P_{n - 1}}\left( x \right) \tag{11} xPn(x)=c0Pn+1(x)+c1Pn(x)+c2Pn1(x)(11)
注意到根据勒让德多项式的定义(1):
x 2 n − 1 ∉ ( x 2 − 1 ) n ⇒ x n − 1 ∉ d n [ ( x 2 − 1 ) n ] d x n {x^{2n - 1}} \notin {\left( {{x^2} - 1} \right)^n} \Rightarrow {x^{n - 1}} \notin \frac{{{d^n}\left[ {{{\left( {{x^2} - 1} \right)}^n}} \right]}}{{d{x^n}}} x2n1/(x21)nxn1/dxndn[(x21)n]
又由于 x n ∉ P n + 1 ( x ) , P n − 1 ( x ) ⇒ c 1 = 0 {x^n} \notin {P_{n + 1}}\left( x \right),{P_{n - 1}}\left( x \right) \Rightarrow {c_1} = 0 xn/Pn+1(x),Pn1(x)c1=0
因此 x P n ( x ) = c 0 P n + 1 ( x ) + c 2 P n − 1 ( x ) (12) x{P_n}\left( x \right) = {c_0}{P_{n + 1}}\left( x \right) + {c_2}{P_{n - 1}}\left( x \right) \tag{12} xPn(x)=c0Pn+1(x)+c2Pn1(x)(12)
比较等式(12)两边x^{n+1}次系数可得:
2 n ( 2 n − 1 ) ⋯ ( n + 1 ) 2 n n ! = c 0 ( 2 n + 2 ) ( 2 n + 1 ) ⋯ ( n + 2 ) 2 n + 1 ( n + 1 ) ! ⇒ c 0 = n + 1 2 n + 1 \frac{{2n\left( {2n - 1} \right) \cdots \left( {n + 1} \right)}}{{{2^n}n!}} = {c_0}\frac{{\left( {2n + 2} \right)\left( {2n + 1} \right) \cdots \left( {n + 2} \right)}}{{{2^{n + 1}}\left( {n + 1} \right)!}} \Rightarrow \newline {c_0} = \frac{{n + 1}}{{2n + 1}} 2nn!2n(2n1)(n+1)=c02n+1(n+1)!(2n+2)(2n+1)(n+2)c0=2n+1n+1
最后算c_2时直接利用引理5
1 = n + 1 2 n + 1 + c 2 × 1 ⇒ c 2 = n 2 n + 1 1 = \frac{{n + 1}}{{2n + 1}} + {c_2} \times 1 \Rightarrow {c_2} = \frac{n}{{2n + 1}} 1=2n+1n+1+c2×1c2=2n+1n
故得到
x P n ( x ) = n + 1 2 n + 1 P n + 1 ( x ) + n 2 n + 1 P n − 1 ( x ) (13) x{P_n}\left( x \right) = \frac{{n + 1}}{{2n + 1}}{P_{n + 1}}\left( x \right) + \frac{n}{{2n + 1}}{P_{n-1}}\left( x \right) \tag{13} xPn(x)=2n+1n+1Pn+1(x)+2n+1nPn1(x)(13)
即为递推式的等价形式。

零点分布

n次勒让德多项式有n个实根且分布在(-1,1)开区间内:
证明使用罗德里格斯公式(1):首先注意到 ( x 2 − 1 ) k , k ≥ 1 {\left( {{x^2} - 1} \right)^k},k \ge 1 (x21)k,k1一定有-1,1为根,使用rolle中值定理可以得到 d ( x 2 − 1 ) k d x \frac{{d{{\left( {{x^2} - 1} \right)}^k}}}{{dx}} dxd(x21)k存在 − 1 < ξ 1 , 1 < 1 -1<\xi_{1,1}<1 1<ξ1,1<1为根,同时若 k > 1 k>1 k>1则可导出 d 2 ( x 2 − 1 ) k d x 2 \frac{{{d^2}{{\left( {{x^2} - 1} \right)}^k}}}{{d{x^2}}} dx2d2(x21)k − 1 < ξ 2 , 1 < ξ 2 , 2 < 1 -1<\xi_{2,1}<\xi_{2,2}<1 1<ξ2,1<ξ2,2<1为根,以此类推: d k − 1 ( x 2 − 1 ) k d x k − 1 , k ≥ 1 \frac{{{d^{k - 1}}{{\left( {{x^2} - 1} \right)}^k}}}{{d{x^{k - 1}}}},k \ge 1 dxk1dk1(x21)k,k1 − 1 < ξ k − 1 , 1 < ⋯ < ξ k − 1 , k − 1 < 1 -1<\xi_{k-1,1}<\cdots<\xi_{k-1,k-1}<1 1<ξk1,1<<ξk1,k1<1为根,最后使用的rolle定理使得在这k+1个点形成的k个段内各有一个实根,即证.

等价的三对角矩阵的谱:

注意到递推公式(13):
等价表达式:
P n + 1 ( x ) = 2 n + 1 n + 1 x P n ( x ) − n n + 1 P n − 1 ( x ) (14) {P_{n + 1}}\left( x \right) = \frac{{2n + 1}}{{n + 1}}x{P_n}\left( x \right) - \frac{n}{{n + 1}}{P_{n - 1}}\left( x \right) \tag{14} Pn+1(x)=n+12n+1xPn(x)n+1nPn1(x)(14)
因此等价的行列式为,这里 D n D_{n} Dn为三对角矩阵:
D n + 1 = [ D n n n + 1 n n + 1   2 n + 1 n + 1 x ] D_{n+1} = \left[ \begin{array}{cc} {D_n} & {\sqrt {\frac{n}{{n + 1}}} } \\ {\sqrt {\frac{n}{{n + 1}}} }\ & {\frac{{2n + 1}}{{n + 1}}x} \end{array}\right] Dn+1=[Dnn+1n  n+1n n+12n+1x]
因此推得legendre多项式 P n + 1 P_{n+1} Pn+1的根是下列实对称三对角阵的谱:
T = d i a g ( k 4 k 2 − 1 , 1 ) + d i a g ( k 4 k 2 − 1 , − 1 ) , k ∈ { 1 , 2 , ⋯ n } T = diag\left( {\frac{k}{{\sqrt {4{k^2} - 1} }},1} \right) + diag\left( {\frac{k}{{\sqrt {4{k^2} - 1} }}, - 1} \right),k \in \left\{ {1,2, \cdots n} \right\} T=diag(4k21 k,1)+diag(4k21 k,1),k{1,2,n}
求积系数是对应特征向量模长平方的两倍

matlab求根:

n = 10;%11次勒让德多项式
A = diag((1:n)./sqrt(4*(1:n).^2-1),1)+diag((1:n)./sqrt(4*(1:n).^2-1),-1);
    [v,e] = eig(A);
    diag(e)%11个根

画出图像(python实现)

import numpy as np
import matplotlib.pyplot as plt
n = 10;
P = np.zeros((n+1,n+1));
P[n,0] = 1;
P[n-1,1] = 1;
x = np.linspace(-1, 1, 100)
J = np.zeros((n+1,n+1));
for i in range(n):
    J[i,i+1] = 1
#print(J)
for i in range(1,n):
    P[:,i+1] = ((2*i+1)/(i+1))*np.dot(J,P[:,i]) - i/(i+1)*P[:,i-1];
#print(P)
for i in range(n+1):
    y = np.polyval(P[:,i], x)
    plt.plot(x,y)
plt.show()

在这里插入图片描述

积分实例

尝试计算:
∫ − 1 1 1 x 2 + 1 d x = π 2 \int\limits_{-1}^{1} {\frac{1}{x^2+1}} dx = \frac{\pi}{2} 11x2+11dx=2π

import numpy as np  
import matplotlib.pyplot as plt  
def legendre_polynomial_integral_coefficient(n):  
    DOF = np.zeros((n,n))  
    for iter in range(n-1):  
        DOF[iter,iter+1] = (iter+1)/np.sqrt(4*(iter+1)**2-1)  
        DOF[iter+1,iter] = DOF[iter,iter+1]  
        [xr,v] = np.linalg.eig(DOF)  
        A = 2*v[0,:]**2  
#     print(np.linalg.norm(v@np.diag(xr)@v.T - DOF))  
    return xr,A  
def gauss_legendre_integral(f,xr,A,a=-1,b=1):#高斯勒让德求积  
       xrr = ((a+b) + (b-a)*xr)/2  
       return np.sum(f(xrr)*A*(b-a)/2)  
def grid_on_gauss(f,xr,A,intervals):   #复化高斯求积  
       s = 0.0;  
       for i in range(len(intervals)-1):  
         s = s + gauss_legendre_integral(f,xr,A,intervals[i],intervals[i+1])  
       return s  
def interpolant(x):  
    return 1/(1+x**2)  
if __name__=="__main__":  
    xr,A = legendre_polynomial_integral_coefficient(2) #五次多项式具有9次代数精度  
    print('求积节点和求积系数:',end = '')  
    print(xr,A)  
    err = np.zeros((1,8))  
    for i in range(2,10):  
        intervals = np.linspace(-1,1,i)  
        print('gauss-legendre求积复化节点:',end = '|')  
        print(intervals.round(4))  
        val = grid_on_gauss(interpolant,xr,A,intervals)  
        print('val = {:.16f}'.format(val))  
        err[0,i-2] = val - np.pi/2  
#     print(err[0,1],err[0,3],err[0,7])  
    print('2段和4段复化得到误差阶次{:.4f}'.format(np.log(np.abs(err[0,1]/err[0,3]))/np.log(2)))  
    print('4段和8段复化得到误差阶次{:.4f}'.format(np.log(np.abs(err[0,3]/err[0,7]))/np.log(2))) 

求积节点和求积系数:[ 0.57735027 -0.57735027] [1. 1.]
gauss-legendre求积复化节点:|[-1. 1.]
val = 1.4999999999999998
gauss-legendre求积复化节点:|[-1. 0. 1.]
val = 1.5737704918032787
gauss-legendre求积复化节点:|[-1. -0.3333 0.3333 1. ]
val = 1.5706921944035348
gauss-legendre求积复化节点:|[-1. -0.5 0. 0.5 1. ]
val = 1.5708049465155127
gauss-legendre求积复化节点:|[-1. -0.6 -0.2 0.2 0.6 1. ]
val = 1.5707969907681516
gauss-legendre求积复化节点:|[-1. -0.6667 -0.3333 0. 0.3333 0.6667 1. ]
val = 1.5707966371919944
gauss-legendre求积复化节点:|[-1. -0.7143 -0.4286 -0.1429 0.1429 0.4286 0.7143 1. ]
val = 1.5707964458929606
gauss-legendre求积复化节点:|[-1. -0.75 -0.5 -0.25 0. 0.25 0.5 0.75 1. ]
val = 1.5707963805291514
2段和4段复化得到误差阶次8.4306
4段和8段复化得到误差阶次7.3257

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值