误差分析

· · 算法·理论

关于 +,\times 的误差分析

tips: 本文分析时采用 4 舍 5 入法舍弃过多的位。

1. a+b

设 a 的误差为 \Delta a , b 的误差为 \Delta b \left(-\dfrac{1}{2}\le\Delta a,\Delta b\le\dfrac{1}{2}\right) , a=\overline{a}\times10^{p},b=\overline{b}\times 10^{p} \left(0\le \overline{a},\overline{b}\le 1,\dfrac{1}{10}\le \max\left(\overline{a},\overline{b}\right),p 为保留的位数\right)

\def\l#1{\rule[0.5ex]{#1}{0pt}} \begin{aligned} \l{1.4em}\hspace{-0.3em}&\color{green}\overbrace{\bullet\hspace{-0.3em}\l{2em}\hspace{-0.3em}\bullet\hspace{-0.3em}\l{2em}\hspace{-0.3em}}^{\dfrac{1}{2}}|\color{red}\overbrace{\l{2em}\hspace{-0.3em}\bullet\hspace{-0.3em}\l{2em}\hspace{-0.3em}\bullet}^{\dfrac{1}{2}}\hspace{-0.3em}\l{0.5em}\hspace{-0.4em}\rightarrow\\[-0.5em] &\hspace{-0.5em}\underbrace{\underbrace{\lfloor x\rfloor \hspace{1.1em} x}_{\Delta x} \l{2.5em}\hspace{-0.4em}\rightarrow x'}_{\Delta x'} \hspace{0.9em} \lceil x\rceil \end{aligned}

如图, \color{green} 绿色 部分表示末位无偏移, \color{red} 红色 部分表示末位偏移 +1

据图可知 P\left(a+b 末位偏移 +1\right)=P\left(\Delta a+\Delta b\ge \dfrac{1}{2}\right)

显然 P\left(a+b 末位偏移 +1\right)=\dfrac{1}{8}

\def\l#1{\rule[0.5ex]{#1}{0pt}} \begin{aligned} \l{1.4em}\hspace{-0.3em}&\color{red}\overbrace{\bullet\hspace{-0.3em}\l{2em}\hspace{-0.3em}\bullet\hspace{-0.3em}\l{2em}\hspace{-0.3em}}^{\dfrac{1}{2}}|\color{green}\overbrace{\l{2em}\hspace{-0.3em}\bullet\hspace{-0.3em}\l{2em}\hspace{-0.3em}\bullet}^{\dfrac{1}{2}}\hspace{-0.3em}\l{0.5em}\hspace{-0.4em}\rightarrow\\[-0.5em] &\hspace{-0.5em}\lfloor x\rfloor \hspace{1.1em} \underbrace{x'\leftarrow \hspace{-0.4em}\l{2.1em}\ \underbrace{x \hspace{1em} \lceil x\rceil}_{\Delta x}}_{\Delta x'} \end{aligned}

如图, \color{green} 绿色 部分表示末位无偏移, \color{red} 红色 部分表示末位偏移 -1

据图可知 P\left(a+b 末位偏移 1\right)=P\left(\Delta a+\Delta b\le -\dfrac{1}{2}\right)

显然 P\left(a+b 末位偏移 -1\right)=\dfrac{1}{8}