数值分析复习——绪论

一、绪论

误差的基本概念

绝对误差
  • x∗x^*x 为准确值,xxxx∗x^*x 的一个近似值,记 e(x)=x∗−x\pmb{{e(x)}=x^*-x}e(x)=xxe(x)=xxe(x)=xx,称 e(x)e(x)e(x) 为近似值 xxx绝对误差
  • 绝对误差不是误差的绝对值
  • 若存在 ϵ>0\epsilon > 0ϵ>0,使得 ∣e(x)∣=∣x∗−x∣≤ϵ\pmb{|e(x)|=|x^*-x| \leq \epsilon}e(x)=xxϵe(x)=xxϵe(x)=xxϵ,则 ϵ\epsilonϵ 称为近似值的绝对误差限
相对误差
  • x∗x^*x 为准确值,xxxx∗x^*x 的一个近似值,记 er(x)=x∗−xx∗=e(x)x∗\pmb{e_r(x)=\frac{x^*-x}{x^*}=\frac{e(x)}{x^*}}er(x)=xxx=xe(x)er(x)=xxx=xe(x)er(x)=xxx=xe(x),则称 er(x)e_r(x)er(x) 为近似值 xxx相对误差
  • 由于精确值难以求得,通常以 e‾r(x)=x∗−xx\pmb{\overline{e}_r(x)=\frac{x^*-x}{x}}er(x)=xxxer(x)=xxxer(x)=xxx 作为相对误差
有效数
  • 如果近似值 xxx 的绝对误差限是其某一位的半个单位,且该位直到 xxx 的第一个非零数字之间共有 n 位,则称 xxx 具有 n 位有效数字,用这 n 位有效数字表示的近似值称为有效数
  • π\piπ 的近似值取 x1=3.14x_1=3.14x1=3.14,则 ∣π−x1∣=0.00159...<0.005=12×10−2|\pi-x_1|=0.00159...<0.005=\frac{1}{2} \times 10^{-2}πx1=0.00159...<0.005=21×102,所以 x1x_1x1 有 3 位有效数字

数据误差对函数值的影响

x1∗, x2∗x^*_1,\ x^*_2x1, x2 为准确值,y∗=f(x1∗,x2∗), x1, x2y^*=f(x^*_1, x^*_2),\ x_1,\ x_2y=f(x1,x2), x1, x2 为对应的近似值,y=f(x1, x2)y=f(x_1,\ x_2)y=f(x1, x2),由二元函数 Taylor 展开得
e(y)=y∗−y=f(x1∗,x2∗)−f(x1,x2)≈∂f(x1,x2)∂x1(x1∗−x1)+∂f(x1,x2)∂x2(x2∗−x2)≈∂f(x1,x2)∂x1e(x1)+∂f(x1,x2)∂x2e(x2) ①er(y)=e(y)y≈∂f(x1,x2)∂x1x1f(x1,x2)er(x1)+∂f(x1,x2)∂x2x2f(x1,x2)er(x2) ② \begin{aligned} e(y) &= y^*-y=f(x_1^*,x_2^*)-f(x_1, x_2) \\ &\approx \frac{\partial f(x_1, x_2)}{\partial x_1}(x^*_1-x_1)+\frac{\partial f(x_1, x_2)}{\partial x_2}(x^*_2-x_2) \\ &\approx \frac{\partial f(x_1, x_2)}{\partial x_1}e(x_1)+\frac{\partial f(x_1, x_2)}{\partial x_2}e(x_2) \ ①\\ \\ e_r(y) &= \frac{e(y)}{y} \approx \frac{\partial f(x_1, x_2)}{\partial x_1} \frac{x_1}{f(x_1, x_2)}e_r(x_1)+\frac{\partial f(x_1, x_2)}{\partial x_2}\frac{x_2}{f(x_1, x_2)}e_r(x_2)\ ② \end{aligned} e(y)er(y)=yy=f(x1,x2)f(x1,x2)x1f(x1,x2)(x1x1)+x2f(x1,x2)(x2x2)x1f(x1,x2)e(x1)+x2f(x1,x2)e(x2) =ye(y)x1f(x1,x2)f(x1,x2)x1er(x1)+x2f(x1,x2)f(x1,x2)x2er(x2) 
利用 ① 和 ② 可得
e(x1+x2)=e(x1)+e(x2)e(x1−x2)=e(x1)−e(x2)e(x1x2)≈x2e(x1)+x1e(x2)e(x1x2)≈1x2e(x1)−x1x22e(x2)er(x1+x2)≈x1x1+x2er(x1)+x2x1+x2er(x2)er(x1−x2)≈x1x1−x2er(x1)−x2x1−x2er(x2)er(x1x2)≈er(x1)+er(x2)er(x1x2)≈er(x1)−er(x2) \begin{aligned} &e(x_1+x_2)=e(x_1)+e(x_2) \\ &e(x_1-x_2) = e(x_1)-e(x_2) \\ &e(x_1x_2) \approx x_2e(x_1)+x_1e(x_2) \\ &e(\frac{x_1}{x_2}) \approx \frac{1}{x_2}e(x_1)-\frac{x_1}{x_2^2}e(x_2) \\ &e_r(x_1+x_2) \approx \frac{x_1}{x_1+x_2}e_r(x_1)+\frac{x_2}{x_1+x_2}e_r(x_2) \\ &e_r(x_1-x_2) \approx \frac{x_1}{x_1-x_2}e_r(x_1)-\frac{x_2}{x_1-x_2}e_r(x_2) \\ &e_r(x_1x_2) \approx e_r(x_1)+e_r(x_2) \\ &e_r(\frac{x_1}{x_2}) \approx e_r(x_1)-e_r(x_2) \end{aligned} e(x1+x2)=e(x1)+e(x2)e(x1x2)=e(x1)e(x2)e(x1x2)x2e(x1)+x1e(x2)e(x2x1)x21e(x1)x22x1e(x2)er(x1+x2)x1+x2x1er(x1)+x1+x2x2er(x2)er(x1x2)x1x2x1er(x1)x1x2x2er(x2)er(x1x2)er(x1)+er(x2)er(x2x1)er(x1)er(x2)

例子

x=0.1230, y=1.234x=0.1230,\ y=1.234x=0.1230, y=1.234 均为有效数字,试分析 (x−y)(x-y)(xy)x2cos⁡(y)x^2 \cos(y)x2cos(y) 得绝对误差限、相对误差限和有效数字

:由条件有 ∣e(x)∣≤12×10−4, ∣e(y)∣≤12×10−3|e(x)| \leq \frac{1}{2} \times 10^{-4},\ |e(y)| \leq \frac{1}{2} \times 10^{-3}e(x)21×104, e(y)21×103,则
∣e(x−y)∣=∣e(x)−e(y)∣≤∣e(x)∣+∣e(y)∣≤0.55×10−3∣er(x−y)∣=∣e(x−y)x−y∣≤∣0.55×10−30.123−1.234∣=0.4950×10−3∣e(x2cos⁡y)∣≈∣2xcos⁡ye(x)−x2sin⁡ye(y)∣≤2x∣cos⁡y∣∣e(x)∣+x2∣sin⁡y∣∣e(y)∣≤0.1120×10−4∣er(x2cos⁡y)∣=∣e(x2cos⁡y)x2cos⁡y∣≤0.2240×10−2 \begin{aligned} |e(x-y)| &= |e(x)-e(y)| \leq |e(x)|+|e(y)| \leq 0.55 \times 10^{-3} \\ |e_r(x-y)| &= |\frac{e(x-y)}{x-y}| \leq |\frac{0.55 \times 10^{-3}}{0.123-1.234}|=0.4950 \times 10^{-3} \\ |e(x^2\cos{y})| &\approx |2x\cos{y}e(x)-x^2\sin{y}e(y)| \\ &\leq 2x|\cos{y}||e(x)|+x^2|\sin{y}||e(y)| \leq 0.1120 \times 10^{-4} \\ |e_r(x^2\cos{y})| &= |\frac{e(x^2\cos{y})}{x^2\cos{y}}| \leq 0.2240 \times 10^{-2} \end{aligned} e(xy)er(xy)e(x2cosy)er(x2cosy)=e(x)e(y)e(x)+e(y)0.55×103=xye(xy)0.1231.2340.55×103=0.4950×1032xcosye(x)x2sinye(y)2xcosye(x)+x2sinye(y)0.1120×104=x2cosye(x2cosy)0.2240×102
由上可知,

∣e(x−y)∣≤0.55×10−3<12×10−2, x−y=−1.111|e(x-y)|\leq0.55 \times10^{-3} \lt \frac{1}{2} \times 10^{-2}, \ x-y=-1.111e(xy)0.55×103<21×102, xy=1.111,所以 (x−y)(x-y)(xy) 具有 3 位有效数字

∣e(x2cos⁡y)∣<12×10−4, x2cos⁡y=0.0049996|e(x^2\cos{y})| \lt \frac{1}{2} \times 10^{-4},\ x^2\cos{y}=0.0049996e(x2cosy)<21×104, x2cosy=0.0049996,所以 x2cos⁡yx^2\cos{y}x2cosy 具有 2 位有效数字

数值稳定性

  • 对于某一算法,如果初始数据很小的误差仅使最终结果产生较小的误差,则称该算法是数值稳定的,否则称为数值不稳定
  • :建立计算积分 ∫01xnx+5dx, n=0,1,2,...,10\int_0^1\frac{x^n}{x+5}dx,\ n=0,1,2,...,1001x+5xndx, n=0,1,2,...,10 的递推公式,并研究其误差传播

In=∫01xn+5xn−1−5xn−1x+5dx=∫01xn−1dx−5∫01xn−1x+5dx=1n−5In−1→不稳定若上式转换为:In−1=15(1n−In), (n=10,9,...,2,1)→稳定 \begin{aligned} I_n &= \int_0^1\frac{x^n+5x^{n-1}-5x^{n-1}}{x+5}dx \\ &= \int_0^1x^{n-1}dx - 5\int_0^1\frac{x^{n-1}}{x+5}dx \\ &= \frac{1}{n} -5I_{n-1} \rightarrow 不稳定 \\ 若上式转换为:I_{n-1} &= \frac{1}{5}(\frac{1}{n}-I_n),\ (n=10,9,...,2,1) \rightarrow 稳定 \end{aligned} InIn1=01x+5xn+5xn15xn1dx=01xn1dx501x+5xn1dx=n15In1=51(n1In), (n=10,9,...,2,1)

  • 如果输入数据有微小的误差,引起输出数据只有微小的改变,称这类问题为良态的,否则称为病态

实际计算中应注意的一些问题

  • 尽量避免除数绝对值远远小于被除数绝对值
  • 尽量避免两个相近的数相减
  • 防止大数 “吃” 小数
  • 简化计算步骤,减少运算次数

秦九韶算法

将多项式 f(x)=a0xn+a1xn−1+...+an−1x+anf(x)=a_0x^n+a_1x^{n-1}+...+a_{n-1}x+a_nf(x)=a0xn+a1xn1+...+an1x+an 转换为如下嵌套形式:
f(x)=(...((a0x+a1)x+a2)x+...+an−1)x+an f(x) = (...((a_0x+a_1)x+a_2)x+...+a_{n-1})x+a_n f(x)=(...((a0x+a1)x+a2)x+...+an1)x+an
改成表格形式如下:

a0a_0a0a1a_1a1a2a_2a2an−1a_{n-1}an1ana_nan
x=x0x=x_0x=x0b0x0b_0x_0b0x0b1x0b_1x_0b1x0bn−2x0b_{n-2}x_0bn2x0bn−1x0b_{n-1}x_0bn1x0
b0b_0b0b1b_1b1b2b_2b2bn−1b_{n-1}bn1bn=f(x0)b_n=f(x_0)bn=f(x0)

:已知 f(x)=8x5+4x3−9x+1f(x)=8x^5+4x^3-9x+1f(x)=8x5+4x39x+1 用秦九韶法求 f(3)f(3)f(3)

:使用表格可得

888000444000−9-99111
x0=3x_0=3x0=33×8=243\times 8 = 243×8=2424×3=7224 \times 3 = 7224×3=7276×3=22876 \times 3 = 22876×3=228228×3=684228 \times 3 = 684228×3=684675×3=2025675 \times 3=2025675×3=2025
88824+0=2424+0=2424+0=2472+4=7672+4=7672+4=76228+0=228228+0=228228+0=228684+(−9)=675684+(-9)=675684+(9)=6752025+1=f(3)2025+1=f(3)2025+1=f(3)

f(3)=2026f(3)=2026f(3)=2026

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值