←
PDF 1016 / 1160 Calculating the integrals for $a2$ and $a4$ numerically, we obtain the ‘least squares approximat
→
English · PDF 1016
Original PDF page 1016
中文 · PDF 1016

$$\begin{aligned} a_2 &= \frac{2}{\pi} \int_0^\pi \cos 2\theta \sqrt{(9 - \sin^2 \theta)} d\theta \ a_3 &= \frac{2}{\pi} \int_0^\pi \cos 3\theta \sqrt{(9 - \sin^2 \theta)} d\theta \ &= 2 \int_0^\pi \cos \theta d\theta \end{aligned}$$

$$a_3 = \frac{2}{\pi} \int_0^\pi \cos 3\theta \sqrt{9 - \sin^2 \theta} d\theta = 0$$

$$\begin{aligned} a_3 &= \frac{2}{\pi} \int_0^\pi \cos 3\theta \sqrt{(9 - \sin^2 \theta)} d\theta \ a_4 &= \frac{2}{\pi} \int_0^\pi \cos 4\theta \sqrt{(9 - \sin^2 \theta)} d\theta \end{aligned}$$

计算积分 $a_2$ 和 $a_4$ 的数值,我们得到 $x(\theta)$ 的“最小二乘逼近”,形式为

$$x(\theta) \approx 2.9148 + \cos\theta + 0.0858 \cos 2\theta - 0.0006 \cos 4\theta$$

我们可以继续这一过程以求出 a5 和 a6。注意到这些系数恰好就是用傅里叶级数系数的标准公式所求得的系数,因此我们不必每次都经历上述最小化过程。事实上,可以将该例子推广,以证明截断傅里叶级数给出了周期函数的“最佳”逼近。

使用梯形法则,MATLAB 命令

a = 0; b = pi/2; n = 8; h = (b – a)/n; x = (a:h:b); y = 2.*((9 – (sin(x)).^2).^(1/2))./pi; h*trapz(y)

返回答案 2.9148。

同样,命令

$$a = 0; b = pi; n = 8; h = (b-a)/n; x = (a:h:b); y = 2.\cos(2.x).((9 - (\sin(x)).^2).^{1/2})./pi; htrapz(y)$$

返回答案 0.0858。

而命令

$$a = 0; b = pi; n = 8; h = (b - a)/n; x = (a:h:b); y = 2.\cos(4.x).((9 - (\sin(x)).^2).^{1/2})./pi; htrapz(y)$$

返回答案 –6.3119e – 004。

回顾一下,这与 $-6.3119 \times 10^{-4}$ 相同。

一种有趣的替代方法是尝试以符号形式求积分。使用符号数学工具箱(Symbolic Math Toolbox),可以符号化地求出这些积分,其中一些答案以椭圆函数表示。使用 double 命令,所有答案都可以表示为数值形式。例如,考虑 a 的积分0 ,命令

syms x y y = 2*cos(2*x)*sqrt(9 – (sin(x))^2)/pi; int(y,0,pi); double(ans)