Numberical Analysis --- Numerical Differentiation and Integration

Welcome file

Numerical Differentiation

Given x0x_0, approximate f(x0)f'(x_0).
f(x0)=limh0f(x0+h)f(x0)hf'(x_0)=\lim\limits_{h\to 0}\frac{f(x_0+h)-f(x_0)}{h}
f(x0)f(x0+h)f(x0)h(forward)\Rightarrow f'(x_0)\approx \frac{f(x_0+h)-f(x_0)}{h}(\text{forward})
f(x0)f(x0)f(x0h)h(backward)\Rightarrow f'(x_0)\approx \frac{f(x_0)-f(x_0-h)}{h}(\text{backward})

Approximate f(x)f(x) by its Lagrange polynomial with interpolating points x0x_0 and x0+hx_0+h:
f(x)=f(x0)(xx0h)x0x0h+f(x0+h)(xx0)x0+hx0+(xx0)(xx0h)2f(ξx)\begin{aligned} f(x)&=\frac{f(x_0)(x-x_0-h)}{x_0-x_0-h}+\frac{f(x_0+h)(x-x_0)}{x_0+h-x_0}\\ &+\frac{(x-x_0)(x-x_0-h)}{2}f''(\xi_x)\\ \end{aligned}

f(x)=f(x0+h)f(x0)h+2(xx0)h2f(ξx)+(xx0)(xx0h)2ddx[f(ξx)]\begin{aligned} f'(x)&=\frac{f(x_0+h)-f(x_0)}{h}+\frac{2(x-x_0)-h}{2}f''(\xi_x)\\ &+\frac{(x-x_0)(x-x_0-h)}{2}\cdot \frac{\,d}{\,dx}[f''(\xi_x)]\\ \end{aligned}
f(x0)=f(x0+h)f(x0)hh2f(ξ)\Rightarrow f'(x_0)=\frac{f(x_0+h)-f(x_0)}{h}-\frac{h}{2}f''(\xi)

Approximate f(x)f(x) by its Lagrange polynomial with interpolating points {x0,x1,...,xn}\{x_0,x_1,...,x_n\}.
f(x)=k=0nf(xk)Lk(x)+(xx0)...(xxn)(n+1)!f(n+1)(ξx)f(x)=\sum\limits_{k=0}^nf(x_k)L_k(x)+\frac{(x-x_0)...(x-x_n)}{(n+1)!}f^{(n+1)}(\xi_x)
f(xj)=k=0nf(xk)Lk(xj)+f(n+1)(ξj)(n+1)!0kn,kj(xjxk)f'(x_j)=\sum\limits_{k=0}^nf(x_k)L_k'(x_j)+\frac{f^{(n+1)}(\xi_j)}{(n+1)!}\prod\limits_{0\leq k\leq n,k\neq j}(x_j-x_k)

Note:

In general, more evaluation points produce greater accuracy.

On the other hand, the number of functional evaluations grows and the roudoff error increases. Hence the numerical differentiation is unstable!

Example: Given three points x0,x0+hx_0,x_0+h and x0+2hx_0+2h, please derive the three-point formulae for each of the points. Then give the best three-point formulae for f(x)f'(x).
f(x0)=1h[32f(x0)+2f(x0+h)12f(x0+2h)]+h23f(3)(ξ0)f'(x_0)=\frac{1}{h}\left[-\frac{3}{2}f(x_0)+2f(x_0+h)-\frac{1}{2}f(x_0+2h)\right]+\frac{h^2}{3}f^{(3)}(\xi_0)
f(x0+h)=1h[12f(x0)+12f(x0+2h)]h26f(3)(ξ1)f'(x_0+h)=\frac{1}{h}\left[-\frac{1}{2}f(x_0)+\frac{1}{2}f(x_0+2h)\right]-\frac{h^2}{6}f^{(3)}(\xi_1)
f(x0)=12h[f(x0+h)f(x0h)]h26f(3)(ξ1)f'(x_0)=\frac{1}{2h}\left[f(x_0+h)-f(x_0-h)\right]-\frac{h^2}{6}f^{(3)}(\xi_1)

Example: Find a way to approximate f(x0)f''(x_0).

Consider Taylor expansion of f(x0+h)f(x_0+h) and f(x0h)f(x_0-h) at x0x_0:
f(x0+h)=f(x0)+f(x0)h+12f(x0)h2+16f(x0)h3+124f(4)(ξ1)h4f(x_0+h)=f(x_0)+f'(x_0)h+\frac{1}{2}f''(x_0)h^2+\frac{1}{6}f'''(x_0)h^3+\frac{1}{24}f^{(4)}(\xi_1)h^4
f(x0h)=f(x0)f(x0)h+12f(x0)h216f(x0)h3+124f(4)(ξ1)h4f(x_0-h)=f(x_0)-f'(x_0)h+\frac{1}{2}f''(x_0)h^2-\frac{1}{6}f'''(x_0)h^3+\frac{1}{24}f^{(4)}(\xi_{-1})h^4

f(x0)=1h2[f(x0h)2f(x0)+f(x0+h)]h212f(4)(ξ)f''(x_0)=\frac{1}{h^2}[f(x_0-h)-2f(x_0)+f(x_0+h)]-\frac{h^2}{12}f^{(4)}(\xi)

Elements of Numerical Integration

Integrate the Lagrange interpolating polynomial of f(x)f(x) instead.

Select a set of distinct nodes ax0<x1<...<xnba\leq x_0<x_1<...<x_n\leq b from [a,b][a,b]. The Lagrange polynomial is Pn(x)=k=0nf(xk)Lk(x)P_n(x)=\sum\limits_{k=0}^nf(x_k)L_k(x)
abf(x)dxk=0nf(xk)abLk(x)dx\int_a^bf(x)\,dx\approx \sum\limits_{k=0}^nf(x_k)\int_a^bL_k(x)\,dx
Ak=abLk(x)dx=abjk(xxj)(xkxj)dxA_k=\int_a^bL_k(x)\,dx=\int_a^b\prod\limits_{j\neq k}\frac{(x-x_j)}{(x_k-x_j)}\,dx
ErrorR[f]=abf(x)dxk=0nAkf(xk)=ab[f(x)Pn(x)]dx=abRn(x)dx=abf(n+1)(ξx)(n+1)!k=0n(xxk)dx\begin{aligned} \text{Error} R[f]&=\int_a^bf(x)\,dx-\sum\limits_{k=0}^nA_kf(x_k)\\ &=\int_a^b[f(x)-P_n(x)]\,dx=\int_a^bR_n(x)\,dx\\ &=\int_a^b\frac{f^{(n+1)}(\xi_x)}{(n+1)!}\prod\limits_{k=0}^n(x-x_k)\,dx\\ \end{aligned}

Definition: The degree of accuracy, or precision, of a quadrature formulae is the largest positive integer nn such that the formulae is exact for xkx^k for each k=0,1,...,nk=0,1,...,n.

Example: Consider the linear interpolation on [a,b][a,b], we have
P1(x)=xbabf(a)+xabaf(b)P_1(x)=\frac{x-b}{a-b}f(a)+\frac{x-a}{b-a}f(b)
A1=A2=ba2abf(x)dxba2[f(a)+f(b)]\Rightarrow A_1=A_2=\frac{b-a}{2}\Rightarrow \int_a^bf(x)\,dx\approx\frac{b-a}{2}[f(a)+f(b)]

Solution: Consider xkx^k for each k=0,1,...k=0,1,...
x0=1:ab1dx=ba=ba2[1+1]x^0=1:\int_a^b1\,dx=b-a=\frac{b-a}{2}[1+1]
x:abxdx=b2a22=ba2[a+b]x:\int_a^bx\,dx=\frac{b^2-a^2}{2}=\frac{b-a}{2}[a+b]
x2:abx2dx=b3a33ba2[a2+b2]x^2:\int_a^bx^2\,dx=\frac{b^3-a^3}{3}\neq \frac{b-a}{2}[a^2+b^2]

For equally spaced nodes: xi=a+ih,h=ban,i=0,1,...,nx_i=a+ih,h=\frac{b-a}{n},i=0,1,...,n
Ai=x0xnji(xxj)(xixj)dx=0nij(tj)h(ij)h×hdt=(ba)(1)n1ni!(ni)!0nij(tj)dt\begin{aligned} A_i&=\int_{x_0}^{x_n}\prod\limits_{j\neq i}\frac{(x-x_j)}{(x_i-x_j)}\,dx\\ &=\int_0^n\prod\limits_{i\neq j}\frac{(t-j)h}{(i-j)h}\times h\,dt\\ &=\frac{(b-a)(-1)^{n-1}}{ni!(n-i)!}\int_0^n\prod\limits_{i\neq j}(t-j)\,dt\\ \end{aligned}

Note: Cotes coefficients does not depend on either f(x)f(x) or [a,b][a,b], and can be determined by nn and ii only. Hence we can find these coefficients from a table. The formulae are called Newton-Cotes formulae.

   n=1n=1: C0(1)=12,C1(1)=12C_0^{(1)}=\frac{1}{2},C_1^{(1)}=\frac{1}{2} Precision=1
Trapezoidal Rule: abf(x)dxba2[f(a)+f(b)]\text{Trapezoidal Rule: }\int_a^bf(x)\,dx\approx\frac{b-a}{2}[f(a)+f(b)]
R[f]=abf(ξx)2!(xa)(xb)dx=112h3f(ξ)ξ[a,b],h=ba\begin{aligned} R[f]&=\int_a^b\frac{f''(\xi_x)}{2!}(x-a)(x-b)\,dx\\ &=-\frac{1}{12}h^3f''(\xi)\\ \end{aligned}\quad \xi\in[a,b],h=b-a

   n=2n=2: C0(2)=16,C1(2)=23,C2(2)=16C_0^{(2)}=\frac{1}{6},C_1^{(2)}=\frac{2}{3},C_2^{(2)}=\frac{1}{6} Precision=3.
Simpson’s Rule: abf(x)dxba6[f(a)+4f(a+b2)+f(b)]\text{Simpson's Rule: }\int_a^bf(x)\,dx\approx \frac{b-a}{6}[f(a)+4f(\frac{a+b}{2})+f(b)]
R[f]=190h5f(4)(ξ),ξ(a,b),h=ba2R[f]=-\frac{1}{90}h^5f^{(4)}(\xi),\quad \xi\in(a,b),h=\frac{b-a}{2}

   n=3n=3: Simpson’s 3/8-Rule. Precision=3.
R[f]=380h5f(5)(ξ)R[f]=-\frac{3}{80}h^5f^{(5)}(\xi)

   n=4n=4: Cotes Rule. Precision=5.
R[f]=8945h7f(6)(ξ)R[f]=-\frac{8}{945}h^7f^{(6)}(\xi)

Theorem: For the (n+1)(n+1)-point closed Newton-Cotes formulae, there exists ξ(a,b)\xi\in(a,b) for which
abf(x)dx=k=0nAkf(xk)+hn+3f(n+2)(ξ)(n+2)!0nt2(t1)...(tn)dt\int_a^bf(x)\,dx=\sum\limits_{k=0}^nA_kf(x_k)+\frac{h^{n+3}f^{(n+2)}(\xi)}{(n+2)!}\int_0^nt^2(t-1)...(t-n)\,dt
if nn is even and fCn+2[a,b]f\in C^{n+2}[a,b], and
abf(x)dx=k=0nAkf(xk)+hn+2f(n+1)(ξ)(n+1)!0nt(t1)...(tn)dt\int_a^bf(x)\,dx=\sum\limits_{k=0}^nA_kf(x_k)+\frac{h^{n+2}f^{(n+1)}(\xi)}{(n+1)!}\int_0^nt(t-1)...(t-n)\,dt
if nn is odd and fCn+1[a,b]f\in C^{n+1}[a,b]

Composite Numerical Integration

Due to the osillatory nature of high-degree polynomials, piecewise interpolation is applied to approximate f(x)f(x)\Rightarrow a piecewise approach that uses the low-order Newton-Cotes formulae.

Composite Trapezoidal Rule:h=ban,xk=a+kh(k=0,...,n)h=\frac{b-a}{n},x_k=a+kh\quad(k=0,...,n)

Apply Trapezoidal Rule on each [xk1,xk][x_{k-1},x_k]:
xk1xkf(x)dxxkxk12[f(xk1)+f(xk)],k=1,...,n\int_{x_{k-1}}^{x_k}f(x)\,dx\approx \frac{x_k-x_{k-1}}{2}[f(x_{k-1})+f(x_k)],k=1,...,n
abf(x)dxk=1nh2[f(xk1)+f(xk)]=h2[f(a)+2k=1n1f(xk)+f(b)]=Tn\int_a^bf(x)\,dx\approx\sum\limits_{k=1}^n\frac{h}{2}[f(x_{k-1})+f(x_k)]=\frac{h}{2}[f(a)+2\sum\limits_{k=1}^{n-1}f(x_k)+f(b)]=T_n
R[f]=k=1n[h312f(ξx)]=h212(ba)k=1nf(ξx)n=h212(ba)f(ξ),ξ(a,b)\begin{aligned} R[f]&=\sum\limits_{k=1}^n\left[-\frac{h^3}{12}f''(\xi_x)\right]=-\frac{h^2}{12}(b-a)\frac{\sum\limits_{k=1}^nf''(\xi_x)}{n}\\ &=-\frac{h^2}{12}(b-a)f''(\xi),\xi\in(a,b)\\ \end{aligned}

Composite Simpson;s Rule:h=ban,xk=a+kh(k=0,...,n)h=\frac{b-a}{n},x_k=a+kh\quad(k=0,...,n)
xkxk+1f(x)dxh6[f(xk)+4f(xk+12)+f(xk+1)]\int_{x_k}^{x_{k+1}}f(x)\,dx\approx \frac{h}{6}[f(x_k)+4f(x_{k+\frac{1}{2}})+f(x_{k+1})]
abf(x)dx=h6[f(a)+4k=0n1f(xk+12)+2k=0n2f(xk+1)+f(b)]=Sn\int_a^bf(x)\,dx=\frac{h}{6}[f(a)+4\sum\limits_{k=0}^{n-1}f(x_{k+\frac{1}{2}})+2\sum\limits_{k=0}^{n-2}f(x_{k+1})+f(b)]=S_n
R[f]=ba180(h2)4f(4)(ξ)R[f]=-\frac{b-a}{180}\left(\frac{h}{2}\right)^4f^{(4)}(\xi)

Note: To simplify the notation, we may let n=2nn'=2n. Then h=ban=h2,xk=a+khh'= \frac{b-a}{n'}=\frac{h}{2},x_k=a+kh' and
Sn=h3[f(a)+4odd kf(xk)+2even kf(xk)+f(b)]S_n=\frac{h'}{3}[f(a)+4\sum\limits_{\text{odd } k}f(x_k)+2\sum\limits_{\text{even } k}f(x_k)+f(b)]

Composite integration techniques are all stable.

Example: Consider the Simpson’s Rule with nn subintervals on [a,b][a,b]. Assume that f(xi)f(x_i) is approximated by f(xi)f^*(x_i) such that f(xi)=f(xi)+ϵif(x_i)=f^*(x_i)+\epsilon_i for each i=0,1,...,ni=0,1,...,n. Then the accumulated error e(h)e(h) is
e(h)=h3[ϵ0+4odd kϵk+2even kϵk+ϵn]e(h)=\left|\frac{h}{3}[\epsilon_0+4\sum\limits_{\text{odd }k}\epsilon_k+2\sum\limits_{\text{even }k}\epsilon_k+\epsilon_n]\right|
If ϵi<ϵ|\epsilon_i|<\epsilon for all i=0,1,...,ni=0,1,...,n, then
e(h)<h3[ϵ+4(n/2)ϵ+2(n/21)ϵ+ϵ]=nhϵ=(ba)ϵe(h)<\frac{h}{3}[\epsilon+4(n/2)\epsilon+2(n/2-1)\epsilon+\epsilon]=nh\epsilon=(b-a)\epsilon

When we refine the partition to ensure accuracy, the increased computation will NOT increase the roundoff error.

Example: Use Trapezoidal rule and Simpson’s rule with n=8n=8 to approximate π=0141+x2dx\pi=\int_0^1\frac{4}{1+x^2}\,dx.

Solution: Set xk=k8x_k=\frac{k}{8}
T8=116[f(0)+2k=17f(xk)+f(1)]=3.138988494T_8=\frac{1}{16}[f(0)+2\sum\limits_{k=1}^7f(x_k)+f(1)]=3.138988494
S4=124[f(0)+4oddf(xk)+2evenf(xk)+f(1)]=3.141592502S_4=\frac{1}{24}[f(0)+4\sum\limits_{\text{odd}}f(x_k)+2\sum\limits_{\text{even}}f(x_k)+f(1)]=3.141592502

When programming we usually keep dividing the subintervals into 2 equally spaced smaller subintervals. That is, take n=2kn=2^k for k=0,1,...k=0,1,.... When k=9,T512=3.14159202k=9,T_{512}=3.14159202
43T813T4=3.141592502=S4\frac{4}{3}T_8-\frac{1}{3}T_4=3.141592502=S_4

Romberg Integration

Since the error of Trapezoidal rule is Rn[f]=h212(ba)f(ξ)R_n[f]=-\frac{h^2}{12}(b-a)f''(\xi), when we reduce the length of each subinterval into a half,
R2n[f]=(h2)2112f(ξ)14Rn[f]R_{2n}[f]=-\left(\frac{h}{2}\right)^2\frac{1}{12}f''(\xi')\approx \frac{1}{4}R_n[f]
IT2nITn14\Rightarrow \frac{I-T_{2n}}{I-T_n}\approx \frac{1}{4}
Solve for II:
I4T2nTn41=43T2n13Tn=SnI\approx \frac{4T_{2n}-T_n}{4-1}=\frac{4}{3}T_{2n}-\frac{1}{3}T_n=S_n
In general:
4T2nTn41=Sn42S2nSn421=Cn43C2nCn431=Rn\frac{4T_{2n}-T_n}{4-1}=S_n\quad \frac{4^2S_{2n}-S_n}{4^2-1}=C_n\quad \frac{4^3C_{2n}-C_n}{4^3-1}=R_n

Richardson’s Extrapolation

Generate high-accuracy results while using lower-order formulae. Suppose that for some h0h\neq 0, we have a formula T0(x)T_0(x) that approximates an unknown II, and that the truncation error has the form:
T0(h)I=α1h+α2h2+...T_0(h)-I=\alpha_1h+\alpha_2h^2+...
Replace hh by half its value, we have
T0(h2)I=α1(h/2)+α2(h/2)2+...T_0\left(\frac{h}{2}\right)-I=\alpha_1(h/2)+\alpha_2(h/2)^2+...

How to improve the accuracy from O(h)O(h) to O(h2)O(h^2)?
2T0(h2)T0(h)21I=12α2h234α3h3...\frac{2T_0(\frac{h}{2})-T_0(h)}{2-1}-I=-\frac{1}{2}\alpha_2h^2-\frac{3}{4}\alpha_3h^3-...

T1(h)=2T0(h2)T0(h)21=I+β1h2+β2h3+...T_1(h)=\frac{2T_0(\frac{h}{2})-T_0(h)}{2-1}=I+\beta_1h^2+\beta_2h^3+...
T2(h)=22T1(h2)T1(h)21=I+γ1h3+γ4h4+...T_2(h)=\frac{2^2T_1(\frac{h}{2})-T_1(h)}{2-1}=I+\gamma_1h^3+\gamma_4h^4+...
Tm(h)=2mTm1(h2)Tm1(h)2m1=I+δ1hm+1+δ2hm+2+...\Rightarrow T_m(h)=\frac{2^mT_{m-1}(\frac{h}{2})-T_{m-1}(h)}{2^m-1}=I+\delta_1h^{m+1}+\delta_2h^{m+2}+...

Adaptive Quadrature Methods

Predict the amount of functional variation and adapt the step size to the varying requirements.

Example: Consider the adaptive method based on Composite Simpson’s rule.
abf(x)dx=S(a,b)h590f(4)(ξ)\int_a^bf(x)\,dx=S(a,b)-\frac{h^5}{90}f^{(4)}(\xi)
where
S(a,b)=h3[f(a)+4f(a+h)+f(b)],h=ba2S(a,b)=\frac{h}{3}[f(a)+4f(a+h)+f(b)],\quad h=\frac{b-a}{2}

Let
S(a,a+b2)=h6[f(a)+4f(a+h2)+f(a+h)]S\left(a,\frac{a+b}{2}\right)=\frac{h}{6}[f(a)+4f\left(a+\frac{h}{2}\right)+f(a+h)]
S(a+b2,b)=h6[f(a+h)+4f(a+3h2)+f(b)]S\left(\frac{a+b}{2},b\right)=\frac{h}{6}[f(a+h)+4f\left(a+\frac{3h}{2}\right)+f(b)]
Then
abf(x)dx=S(a,a+b2)+S(a+b2,b)116×h590f(4)(η)\int_a^bf(x)\,dx=S\left(a,\frac{a+b}{2}\right)+S\left(\frac{a+b}{2},b\right)-\frac{1}{16}\times \frac{h^5}{90}f^{(4)}(\eta)
abf(x)dxS(a,a+b2)S(a+b2,b)115S(a,b)S(a,a+b2)S(a+b2,b)<ϵ\left|\int_a^bf(x)\,dx-S\left(a,\frac{a+b}{2}\right)-S\left(\frac{a+b}{2},b\right)\right|\approx \frac{1}{15}\left|S(a,b)-S\left(a,\frac{a+b}{2}\right)-S\left(\frac{a+b}{2},b\right)\right|<\epsilon

Gaussian Quadrature

Construct a formula abw(x)f(x)dxk=0nAkf(xk)\int_a^bw(x)f(x)\,dx\approx\sum\limits_{k=0}^nA_kf(x_k) of precision degree 2n+12n+1 with n+1n+1 points.

Determine 2n+22n+2 unknowns x0,...,xnx_0,...,x_n and A0,..,AnA_0,..,A_n such that the formula is accurate for f(x)=1,x,x2,...,x2n+1f(x)=1,x,x^2,...,x^{2n+1}. The points x0,...,xnx_0,...,x_n are called Gaussian points, and the method is called Gaussian quadrature.

Example: Approximate 01xf(x)dx\int_0^1\sqrt{x}f(x)\,dx using Gaussian quadrature with n=1n=1.

Solution: Assume 01xf(x)dx=A0f(x0)+A1f(x1)\int_0^1\sqrt{x}f(x)\,dx=A_0f(x_0)+A_1f(x_1)
The formula must be accurate for f(x)=1,x,x2,x3f(x)=1,x,x^2,x^3
{23=A0+A125=A0x0+A1x127=A0x02+A1x1229=A0x03+A1x13{x00.8212x10.2899A00.3891A10.2776\begin{cases} \frac{2}{3}=A_0+A_1\\ \frac{2}{5}=A_0x_0+A_1x_1\\ \frac{2}{7}=A_0x_0^2+A_1x_1^2\\ \frac{2}{9}=A_0x_0^3+A_1x_1^3\\ \end{cases}\Rightarrow \begin{cases} x_0\approx 0.8212\\ x_1\approx 0.2899\\ A_0\approx 0.3891\\ A_1\approx 0.2776\\ \end{cases}

Theorem: x0,...,xnx_0,...,x_n are Gaussian points iff W(x)=k=0n(xxk)W(x)=\prod\limits_{k=0}^n(x-x_k) is orthogonal to all the polynomials of degree no greater than nn.

Proof:

  1. If x0,...,xnx_0,...,x_n are Gaussian points, then the degree of precision of the formula abw(x)f(x)dxk=0nAkf(xk)\int_a^bw(x)f(x)\,dx\approx\sum\limits_{k=0}^nA_kf(x_k) is at least 2n+12n+1. Then for any polynomial Pm(x)P_m(x) with mnm\leq n, the degree of Pm(x)W(x)P_m(x)W(x) must be no greater than 2n+12n+1. Hence the formula is accurate for Pm(x)W(x)P_m(x)W(x). That is
    abw(x)Pm(x)W(x)dx=k=0nAkPm(xk)W(xk)=0\int_a^bw(x)P_m(x)W(x)\,dx=\sum\limits_{k=0}^nA_kP_m(x_k)W(x_k)=0

  2. To prove that x0,...,xnx_0,...,x_n are Gaussian points, we just have to prove that the formula is accurate for any polynomial Pm(x)P_m(x) with m2n+1m\leq 2n+1. Let Pm(x)=W(x)q(x)+r(x)P_m(x)=W(x)q(x)+r(x). Then
    abw(x)Pm(x)dx=abw(x)W(x)q(x)dx+abw(x)r(x)dx=k=0nAkr(xk)=k=0nAkPm(xk)\begin{aligned} \int_a^bw(x)P_m(x)\,dx&=\int_a^bw(x)W(x)q(x)\,dx+\int_a^bw(x)r(x)\,dx\\ &=\sum\limits_{k=0}^nA_kr(x_k)=\sum\limits_{k=0}^nA_kP_m(x_k)\\ \end{aligned}

The set of orthogonal polynomials {φ0,φ1,...,φn,...}\{\varphi_0,\varphi_1,...,\varphi_n,...\} is linearly independent and φn+1\varphi_{n+1} is orthogonal to any polynomial Pm(x)P_m(x) with mnm\leq n.\Rightarrow If we take φn+1\varphi_{n+1} to be W(x)W(x), then the roots of φn+1\varphi_{n+1} are the Gaussian points.

Example: Approximate 01xf(x)dx\int_0^1\sqrt{x}f(x)\,dx using Gaussian quadrature with n=1n=1.

  Step 1:

Construct the orthogonal polynomial φ2\varphi_2. Let φ0(x)=1,φ1(x)=x+a,φ2(x)=x2+bx+c\varphi_0(x)=1,\varphi_1(x)=x+a,\varphi_2(x)=x^2+bx+c
(φ0,φ1)=001x(x+a)dx=0a=35(\varphi_0,\varphi_1)=0\Rightarrow \int_0^1\sqrt{x}(x+a)\,dx=0\Rightarrow a=-\frac{3}{5}
(φ0,φ2)=001x(x2+bx+c)dx=0(\varphi_0,\varphi_2)=0\Rightarrow \int_0^1\sqrt{x}(x^2+bx+c)\,dx=0
(φ1,φ2)=001x(x35)(x2+bx+c)dx=0(\varphi_1,\varphi_2)=0\Rightarrow \int_0^1\sqrt{x}(x-\frac{3}{5})(x^2+bx+c)\,dx=0
{b=109c=521φ2(x)=x2109x+521\Rightarrow \begin{cases} b=-\frac{10}{9}\\ c=\frac{5}{21}\\ \end{cases}\Rightarrow \varphi_2(x)=x^2-\frac{10}{9}x+\frac{5}{21}

   Step 2:

Find the two roots of φ2\varphi_2 which are the Gaussian points x0x_0 and x1x_1:
x0;1=10/9±(10/9)220/212x_{0;1}=\frac{10/9\pm \sqrt{(10/9)^2-20/21}}{2}

   Step 3:

Since the formula must be accurate for f(x)=1,xf(x)=1,x, we can easily solve a linear system of equations for A0A_0 and A1A_1. The results are the same as we have obtained:
x00.8212,x10.2899,A00.3891,A10.2776x_0\approx0.8212,x_1\approx0.2899,A_0\approx0.3891,A_1\approx0.2776

Use this formula to approximate 01xexdx1.2555\int_0^1\sqrt{x}e^x\,dx\approx1.2555

  Some special families of orthogonal functions

1.Legendre Polynomials: Defined on [1,1][-1,1] with w(x)1w(x)\equiv 1.
Pk(x)=12kk!dkdxk(x21)k(Pk,Pl)={0kl22k+1k=lP_k(x)=\frac{1}{2^kk!}\frac{\,d^k}{\,dx^k}(x^2-1)^k\quad (P_k,P_l)=\begin{cases} 0\quad k\neq l\\ \frac{2}{2k+1}\quad k=l\\ \end{cases}

From P0=1P_0=1 and P1=xP_1=x we have (k+1)Pk+1=(2k+1)xPkkPk1(k+1)P_{k+1}=(2k+1)xP_k-kP_{k-1}

The formula that uses the roots of Pn+1P_{n+1} is called the Gauss-Legendre quadrature formula.

2.Chebyshev Polynomials:

Defined on [1,1][-1,1] with w(x)=11x2w(x)=\frac{1}{\sqrt{1-x^2}}

The roots of Tn+1T_{n+1} are xk=cos(2k+12n+2π)x_k=\cos \left(\frac{2k+1}{2n+2}\pi\right) for k=0,...,nk=0,...,n.

The formula 1111x2f(x)dx=k=0nAkf(xk)\int_{-1}^1\frac{1}{\sqrt{1-x^2}}f(x)\,dx=\sum\limits_{k=0}^nA_kf(x_k)
is called the Gauss-Chebyshev quadrature formula.

此博客中的热门博文

Numberical Analysis --- Interpolation & Polynomial Approximation

C++基础碎碎念