ä»®æ°é¨ã®ç²¾åº¦ã 53 bits ã®æµ®åå°æ°ç¹æ°åã§è¨ç®ããã¨ä¸è¨ã®ããã«ãªãã¾ãã
>>> 1 / 49 * 49 0.9999999999999999 >>> f'{1/49*49:.100g}' '0.99999999999999988897769753748434595763683319091796875'
ä»åã¯ããã«ã¤ãã¦æãä¸ãã¾ãã
è¨æ³ã»åæç¥è
ãã®æèã«ãããæµ®åå°æ°ç¹æ°åã¨ä¸¸ãæ¹åã«ããã¦ãå®æ° $x$ ã丸ããå¤ã $\roundp{x}$ ã¨æ¸ããã¨ã«ãã¾ãã
åã¨ãã¦ã¯ double
ï¼IEEE 754 ã§è¨ãã¨ããã® binary64ï¼ãç¨ãã¦ã丸ãæ¹åã« roundTiesToEven ãæ¡ç¨ãã¦ããè¨èªã»å¦çç³»ãå¤ãã®ã§ãããã§ã¯ãããèãã¾ãã
ç¥ããªã人åãï¼è¡¨ãããã®ã®ãã¡ã§ä¸çªè¿ããã®ã«ä¸¸ããã¢ã¼ãããã®è¨äºã®å 容ã§ã¯ãã¡ããã©ä¸éã«ããã±ã¼ã¹ã¯åå¨ããªãã®ã§ããããããã¨ã¯æ°ã«ããªãã¦å¤§ä¸å¤«ã詳ããã¯å¥ã®è¨äºã§è§£èª¬ãã¾ãã
ã¾ããæµ®åå°æ°ç¹æ° $x$, $y$ ã«å¯¾ãã¦ã$x\otimes y \triangleq \roundp{x\times y}$ ããã³ $x\oslash y\triangleq \roundp{x\div y}$ ã¨ãã¾ãã
ãã¨ãã°ãä¸è¨ã®ä¾ãã $$ \begin{aligned} \roundp{\tfrac1{49}}\otimes 49 &= {\footnotesize 0.999999999999999888}{\scriptsize 97769753748434595763}{\tiny 683319091796875} \\ \end{aligned} $$ ã§ããã¾ããç°¡åãªä¾ã¨ã㦠$\roundp1=1$ ãããã¾ãã
$\gdef\hlog#1{\log_2\hfloor{#1}}$
æ£ã®å®æ° $x$ ã«å¯¾ããæ´æ° $i$ ãç¨ã㦠$2^i$ ã¨æ¸ããæçæ°ã®ãã¡ã$x$ 以ä¸ã§æ大ã®ãã®ã $\hfloor x$ ã§è¡¨ãã¾ãã ãã¨ãã° $\hfloor{3.5} = 2$ã$\hfloor1 = 1$ã$\hfloor{0.4} = 0.25$ ãªã©ã§ãã ä¸è¨ã§ã¯ãæ£ã®å®æ° $x$ ã«å¯¾ãã$2^e \le x \lt 2^{e+1}$ ãªãå¯ä¸ã®æ´æ° $e$ ãèããããã¨ããå±é¢ãå¤ããããã $\hlog{x}$ ã¨æ¸ãã¦ä¾¿å©ã§ãã
$\hlog{x} = i$ ã®ã¨ãã$2^{i+1-p}$ ã®ä½ã¾ã§ãä¿æããã$2^{i-p}$ 以ä¸ã®æ¡ã¯ä¸¸ãããã¾ãã
double
ã«ããã¦ã¯ $p=53$ ã§ãã
解説
ã¾ãã1 / 49
ã®é¨åãèãã¾ãã
$$ \begin{aligned} \roundp{\tfrac1{49}} &= {\footnotesize 0.020408163265306}{\scriptsize 12082046367561360966}{\tiny 64704382419586181640625} \\ &= \texttt{14e5e0a72f0539}_{(16)} \times 2^{-58} \\ &= \tfrac1{49}\cdot(1-23\cdot 2^{-58}) \end{aligned} $$ ã¨ãªãã¾ãã10 é²ã®å°æ°è¡¨è¨ã»16 é²ã®ææ°è¡¨è¨ã¨ã誤差ã«çç®ããå½¢å¼ãæãã¾ããã ããã§ã¯ä¸çªä¸ã®è¡¨è¨ã§èããã®ãããããããã¨æãã¾ãããããã¤ãã®è¡¨ç¾æ¹æ³ããããã¨ãè¦ãã¦ãããç¶æ³ã«å¿ãã¦é©åãªãã®ãé¸ã¹ãã¨ããã§ãããã æ°å¦å¯ãã®æèã§è§£æãããã¨ãã¯ä¸çªä¸ã®å½¢ãå¦çããããæ°ããã¾ãã
ãã¦ã$\roundp{\tfrac1{49}}\otimes49$ ãèãã¾ãã $$ \roundp{\tfrac1{49}}\otimes 49 = \roundp{\roundp{\tfrac1{49}}\times 49} = \roundp{1-23\cdot 2^{-58}}. $$ $\tfrac12 \lt 1-23\cdot 2^{-58} \lt 1$ ããã$\hlog{\roundp{\tfrac1{49}}\otimes 49}=-1$ ã¨ãããã¾ããããªãã¡ã$2^{-53}$ ã®ä½ã¾ã§ä¸¸ãããã¾ãã
誤差ã«é¢ãã¦ã$23\cdot 2^{-58} = \tfrac{23}{16}\cdot 2^{-54}$ ããã$1\cdot 2^{-54} \lt 23\cdot 2^{-58} \lt 2\cdot 2^{-54}$ ã¨ãããã¾ãã ãã£ã¦ã$\roundp{\tfrac1{49}}\times49$ 㯠$1$ ããã $1-2^{-53}$ ã«è¿ãã$1-2^{-53}$ ã«ä¸¸ãããã¾ãã
çåã»èå³
ããã§ãããã¤ãã®çåãèªç¶ã«åºã¦ããã¨æãã¾ãã
- $\roundp{\tfrac1x}\otimes x \gt 1$ ã¨ãªããã㪠$x$ ã¯ããï¼
- ãã ã $\infty$ ã«ãªãã±ã¼ã¹ã¯é¤ã
- $x\in[1\ldots 2)$ ãªã $x$ ã®ãã¡ã§ $\roundp{\tfrac1x}\otimes x\lt 1$ ã¨ãªãæå°ã®ãã®ã¯ï¼
- ããªãã¡ $\hlog x=0$ ã®ç¯å²
- $49$ ã®ä¾ãã $x = \tfrac{49}{32}$ ã§ãæãç«ã¤ãã¨ã¯ãããã®ã§ãåå¨æ§ã¯ããã
ãã¿ãã¬
- $\texttt{10000004e62386}_{(16)}\times 2^{970}$ ãªã©
- $\roundp{\tfrac1x}$ ãæ£è¦åæ°ã«ãªãç¯å²ã§ã¯åå¨ããªã
- $\texttt{1000000f5cbf2a}_{(16)}\times 2^{-52}$
ããã«ã¤ãã¦èå¯ãã¦ããã¾ãã
çå 1 ã®è§£ç
$\gdef\emin{e_{\text{min}}}$ $\gdef\emax{e_{\text{max}}}$
ã¾ããæ£è¦åæ°ã®æå°å¤ã $1\times 2^{\emin}$ãæ£è¦åæ°ã®æ大å¤ã $(2-2^{1-p})\times 2^{\emax}$ ã¨ããã¾ãã
double
ã«ããã¦ã¯ã$1\times 2^{-1022}$ ããã³ $(2-2^{-52})\times 2^{1023}$ ã§ãã
ä¸è¬ã«ã$|\emin|+1 = \emax$ ãæãç«ã¡ã¾ãã
証æãªã©ã¯æããããã§ãã¾ãã
Claim 1: $x\in(1\ldots 2)$ ã®ã¨ãã$\roundp{\tfrac1x}\otimes x\in \{1-2^{-p}, 1\}$ ãæãç«ã¤ã
Proof
ãã®ã¨ã $\tfrac1x\in(\tfrac12\ldots1)$ ã§ããã$\hlog{\tfrac1x}=-1$ ã§ããã ãã®ããããã $|\varepsilon|\le 2^{-1-p}$ ãç¨ã㦠$$ \roundp{\tfrac1x} = \tfrac1x + \varepsilon $$ ã¨æ¸ããããã£ã¦ã $$ \begin{aligned} \roundp{\tfrac1x}\times x &= (\tfrac1x + \varepsilon)\times x \\ &= 1 + \varepsilon x \end{aligned} $$ ã¨ãªãã$\varepsilon$ 㨠$x$ ã®ç¯å²ããã$|\varepsilon x|\lt 2^{-p}$ ã¨ãããã
$1$ ã¨é£ãåãäºæ°ã¯ $1-2^{-p}$ 㨠$1+2^{1-p}$ ã§ããã$1$ ã«ä¸¸ããããç¯å²ã¯ $$[1-2^{-1-p}\ldots 1+2^{-p}]$$ ã§ããããã$1+\varepsilon x\lt 1+2^{-p}$ ãã $\roundp{\tfrac1x}\otimes x\le 1$ ã¨ãªãã åæ§ã«ã㦠$\roundp{\tfrac1x}\otimes x\ge 1-2^{-p}$ ããããã$\qed$
Lemma 2: æµ®åå°æ°ç¹æ° $x\in(1\ldots2)$ ã«å¯¾ãã$\roundp{\tfrac1x}\in(\tfrac12\ldots1)$ ãæãç«ã¤ã
Proof
$1\oslash(1+2^{1-p})\lt 1$ ããã³ $1\oslash(2-2^{1-p})\gt\tfrac12$ ã示ãã°ååã
$$ \begin{aligned} 1\div(1+2^{1-p}) &= 1 - 2^{1-p} + 2^{2(1-p)}\cdot (1+2^{1-p})^{-1} \\ &= 1 - 2^{-p} - 2^{-p} + 2^{-p}\cdot 2^{2-p}\cdot (1+2^{1-p})^{-1} \\ &= (1-2^{-p}) - 2^{-p}\cdot (1 - 2^{2-p}\cdot (1+2^{1-p})^{-1}) \\ &= (1-2^{-p}) - 2^{-p}\cdot (1 - 2\cdot (2^{p-1}+1)^{-1}) \\ &\lt 1-2^{-p}; \\ 1\div(2-2^{1-p}) % &= \tfrac12 \div (1-2^{-p}) \\ &= \tfrac12 \cdot (1+2^{-p}+2^{-2p}\cdot(1-2^{-p})^{-1}) \\ &\gt \tfrac12 \cdot (1+2^{-p}) \end{aligned} $$ ããå¾ãã$\qed$
Claim 3: $e \in[\emin\ldots\emax-2]$ ã«å¯¾ãã¦ã$x\in(2^e\ldots2^{e+1})$ ã®ã¨ãã$\roundp{\tfrac1x}\otimes x\in \{1-2^{-p}, 1\}$ ãæãç«ã¤ã
Proof
ããæµ®åå°æ°ç¹æ° $\alpha\in(1\ldots2)$ ãç¨ã㦠$x = \alpha\times 2^e$ ã¨æ¸ããã ã¾ããLemma 2 ãã $\roundp{\tfrac1\alpha}\in(\tfrac12\ldots1)$ ãæãç«ã¤ãã¨ã«æ³¨æãã¤ã¤ $$ \begin{aligned} \roundp{\tfrac1x} &= \roundp{\tfrac1\alpha\times 2^{-e}} \\ &= \roundp{\tfrac1\alpha}\times 2^{-e} \\ &= \roundp{\tfrac2\alpha}\times 2^{-1-e} \end{aligned} $$ ãæãç«ã¤ã ãã㧠$\emin\le -1-e\le \emax$ ãæãç«ã£ã¦ãããã¨ã«æ³¨æããããã¦ã $$ \begin{aligned} \roundp{\tfrac1x}\times x &= (\roundp{\tfrac1\alpha}\times 2^{-e})\times (\alpha\times 2^e) \\ &= \roundp{\tfrac1\alpha}\times \alpha \end{aligned} $$ ãæãç«ã¤ã®ã§ãClaim 1 ããå¾ãã$\qed$
Conjecture 4: $x\in(2^{\emax-1}\ldots 2^{\emax+1})$ ã®ã¨ãã$\roundp{\tfrac1x}\otimes x\in\{1-2^{-p}, 1\}$ ãæãç«ã¤ã
Disproof
double
ã«ããã¦ã$x = \texttt{10000004e62386}_{(16)}\times 2^{970}$ ã¨ããã¨
$$\roundp{\tfrac1x}\otimes x = 1+2^{-52}\gt 1$$ ãæãç«ã¤ã
$\tfrac1x\lt 2^{-(\emax-1)} = 2^{\emin}$ ãããæ£è¦åæ°ã®æå°å¤ä»¥ä¸ã«ä¸¸ããããã®ã§ããã $|\varepsilon|\le 2^{\emin-p}$ ãç¨ã㦠$$ \roundp{\tfrac1x} = \tfrac1x + \varepsilon $$ ã¨æ¸ããããã£ã¦ã $$ \begin{aligned} \roundp{\tfrac1x}\times x &= (\tfrac1x+\varepsilon)\times x \\ &= 1 + \varepsilon x \end{aligned} $$ ã¨ãªãã$|\varepsilon x| \lt 2^{\emax+1+\emin-p} = 2^{2-p}$ ã§ããæãããããé©å㪠$x$ ãé¸ã¶ãã¨ã§åä¾ãä½ãããã§ããã
Claim 5: $e\in[-(\emax+1)\ldots\emin)$ ã«å¯¾ãã¦ã$x\in(2^e\ldots 2^{e+1})$ ã®ã¨ãã$\roundp{\tfrac1x}\otimes x\in\{1-2^{-p}, 1\}$ ãæãç«ã¤ã
Proof
ãã®ã¨ã $\tfrac1x\in(2^{-(e+1)}\ldots2^{-e})$ ã§ããã$\hlog{\tfrac1x}=-(e+1)$ ã§ããã ãã®ããããã $|\varepsilon|\le 2^{-(e+1)-p}$ ãç¨ã㦠$$ \roundp{\tfrac1x} = \tfrac1x + \varepsilon $$ ã¨æ¸ããããã£ã¦ã
$$ \begin{aligned} \roundp{\tfrac1x}\times x &= (\tfrac1x + \varepsilon)\times x \\ &= 1 + \varepsilon x \end{aligned} $$ ã¨ãªãã$\varepsilon$ 㨠$x$ ã®ç¯å²ããã$|\varepsilon x|\lt 2^{-p}$ ã¨ãããã Claim 1 åæ§ã«ãã¦ãæãç«ã¤ãã¨ããããã$\qed$
note: Claim 3 ã§ã¯ $x$ ãæ£è¦åæ°ã®ç¯å²ãã¾ã¨ãã¦æ±ã£ãããClaim 5 ã® $e$ ã®ç¯å²ãåºãããã¨ã§ã示ãããã§ããã
Claim 6: $e\in[\emin\ldots\emax]$ ã«å¯¾ãã¦ã$x=1\times2^e$ ã®ã¨ã $\roundp{\tfrac1x}\otimes x=1$ ãæãç«ã¤ã
Proof
$\roundp{\tfrac1x}=2^{-e}$ ããå¾ãã$\qed$
Claim 7: $\roundp{\tfrac10}\otimes0$ ããã³ $\roundp{\tfrac1{\infty}}\otimes\infty$ 㯠NaN ã¨ãªããã¾ãã$x\in(0\ldots 2^{-(\emax+2)}]$ ã§ã¯ $\roundp{\tfrac1x}\otimes x = \infty$ ã¨ãªãã
Proof
ååã¯ã$\roundp{\tfrac10}=\infty$ ããã³ $\roundp{\tfrac1{\infty}}=0$ ã§ãããã¨ã¨ $0\otimes \infty$ ã NaN ã§ãããã¨ããå¾ãã å¾åã¯ã該å½ã®ç¯å²ã§ $\roundp{\tfrac1x}=\infty$ ã§ãããã¨ã¨ $x\gt 0$ ã§ãããã¨ããå¾ãã $\qed$
ãã£ã¦ã$\roundp{\tfrac1x}$ ãæ£è¦åæ°ã¨ãªãç¯å²ã§ã¯ $\roundp{\tfrac1x}\otimes x\in\{1-2^{-p}, 1\}$ ã§ãããã¨ããããã¾ããããããã§ãªãç¯å²ã«ããã¦ã¯åä¾ããããã¨ããããã¾ããã
ãã¨ãã°ã$x = \texttt{10000004e62386}_{(16)}\times 2^{970}$ ã«å¯¾ã㦠$\roundp{\tfrac1x}\otimes x = 1 + 2^{1-p}$ ã¨ãªãã¾ãã ã¾ããæå°æ§ã¯ç¤ºãã¦ãã¾ãããã$x = \texttt{18000003000000}_{(16)}\times 2^{970}$ ã«å¯¾ã㦠$\roundp{\tfrac1x}\otimes x = 1 - 2\cdot 2^{-p}$ ã¨ãªãã¾ãã
çå 2 ã®è§£ç
$\roundp{\tfrac1x}\otimes x \lt 1$ ãªã $x\in(1\ldots2)$ ã®æå°å¤ã«ã¤ãã¦èãã¾ãã
Claim 8: $\varepsilon^2\lt 2^{-(p+1)}$ ã«å¯¾ã㦠$x=1+\varepsilon$ ã¨æ¸ããã¨ãã$\roundp{\tfrac1x}\otimes x=1$ ãæãç«ã¤ã
Proof
çæ¯ç´æ°ã®åã®å ¬å¼ããã $$ \begin{aligned} \tfrac1x &= \tfrac1{1+\varepsilon} \\ &= 1 - \varepsilon + \tfrac{\varepsilon^2}{1+\varepsilon} \end{aligned} $$ ã§ããã ããã§ã$\tfrac{\varepsilon^2}{1+\varepsilon} \le \varepsilon^2 \lt 2^{-(p+1)}$ ããã $1\oslash x = 1-\varepsilon$ ã¨ãªã*1ã ãã®ç¯å²ã§ã¯ $$ \begin{aligned} \roundp{\tfrac1x}\times x &= (1-\varepsilon)\times(1+\varepsilon) \\ &= 1-\varepsilon^2 \end{aligned} $$ ã¨ãªãã$\varepsilon^2\lt 2^{-(p+1)}$ ãã $\roundp{\tfrac1x}\otimes x=1$ ã¨ãªãã $\qed$
Claim 8 ã®è¨¼æããã$\tfrac{\varepsilon^2}{1+\varepsilon}$ ã«ãã誤差ãååã«å¤§ãããªãã° $\roundp{\tfrac1x}\otimes x\lt 1$ ãæãç«ã¡ããã§ãã $1+2^{-(p+1)/2}$ ä»è¿ã«è§£ããããã¨ã«æå¾ ãã¦ãä»®æ°é¨ãæé ã«å ¨æ¢ç´¢ãã¦ãããããããã¾ããã
å®éãä»®æ°é¨ã 53 bits ã§ãã double
ããlong double
ã®ãã¡ä»®æ°é¨ã 64 bits ã§ãããã®ã«ã¤ãã¦ã¯æ¯è¼çããè¦ã¤ããã¾ãããä¸æ¹ãä»®æ°é¨ã 113 bits ã§ãã __float128
ï¼ãããã¯ããããå¦ç系㮠long double
ï¼ã§ã¯ãã¾ãããã¾ããã§ãããããã§ãããå°ãèå¯ãé²ãã¾ãã
ã¾ããæ´æ° $m\in(2^{p-1}\ldots 2^p)$ ã«å¯¾ã㦠$x = m\times 2^{1-p}$ ã¨è¡¨ããã¨ãã§ãã $$ \begin{aligned} \tfrac1x &= \tfrac{2^p}x\times 2^{-p} \\ &= \tfrac{2^{2p-1}}m\times 2^{-p} \end{aligned} $$ ã§ããããã§ã$m$ ã®ç¯å²ãã $\tfrac{2^{2p-1}}m\in(2^{p-1}\ldots 2^p)$ ã§ãããã¨ããããã¾ãã ãã£ã¦ã $$ \roundp{\tfrac1x}\in\left\{\floor{\tfrac{2^{2p-1}}m}\times 2^{-p}, \ceil{\tfrac{2^{2p-1}}m}\times 2^{-p}\right\} $$ ã¨ãªãã¾ãã ã¾ãã $$ \Floor{\frac{2^{2p-1}}m} = \frac{2^{2p-1} - (2^{2p-1}\bmod m)}m $$ ã§ãã
丸ãã®éã¯è¿ãæ¹ãæ¡ç¨ãããããã$(2^{2p-1}\bmod m) \lt \tfrac m2$ ã®ã¨ã㯠$\floor{\ldots}\times 2^{-p}$ ã®æ¹ãæ¡ç¨ããã$(2^{2p-1}\bmod m)\gt \tfrac m2$ ã®ã¨ã㯠$\ceil{\ldots}\times 2^{-p}$ ã®æ¹ãæ¡ç¨ããã¾ãã$m$ ã®ç¯å²ãã $\tfrac{2^{2p-1}}m$ ãï¼2 é²æ³ã§ï¼ç¡éå°æ°ã¨ãªããã¨ããããã$(2^{2p-1}\bmod m)=\tfrac m2$ ã¨ãªãã±ã¼ã¹ã¯åå¨ããªããã¨ãå¾ãã¾ãã
ãã£ã¦ã次ã®ããã«ãªãã¾ãã
Claim 9: $r = 2^{2p-1}\bmod m$ ã $r\gt\tfrac m2$ ãæºããã¨ãã$\roundp{\tfrac1x}\otimes x=1$ ãæãç«ã¤ã
Proof
該å½ã®æ¡ä»¶ã®ã¨ãã $$ \begin{aligned} \roundp{\tfrac1x}\times x &= \ceil{\tfrac{2^p}x}\times 2^{-p} \\ &\gt \tfrac{2^p}x\times 2^{-p} \\ &= \tfrac1x \end{aligned} $$ ã§ãããã¨ã¨ãClaim 1 ããå¾ãã$\qed$
ããªãã¡ã$\floor{\ldots}\times 2^{-p}$ ãæ¡ç¨ãããæ¹ã®ã¿èããã°ããã§ãã
Claim 10: $r = 2^{2p-1}\bmod m$ ã $2^{p-2}\lt r\lt \tfrac m2$ ãæºããã¨ãã$\roundp{\tfrac1x}\otimes x=1-2^{-p}$ ã¨ãªãã
Proof
$r\lt \tfrac m2$ ã®ç¯å²ã§èããã $$ \begin{aligned} \roundp{\tfrac1x}\times x &= \left(\floor{\tfrac{2^{2p-1}}m}\times 2^{-p}\right)\cdot (m\times 2^{1-p}) \\ &= \left(\tfrac{2^{2p-1}-r}m\times 2^{-p}\right)\cdot (m\times 2^{1-p}) \\ % &= (2^{2p-1}-r)\cdot 2^{-(2p-1)} \\ &= 1 - r\cdot 2^{-(2p-1)} \end{aligned} $$ ããã$r\cdot 2^{-(2p-1)} \gt 2^{-(p+1)}$ ã§ããã° $1-2^{-p}$ ã«ä¸¸ããããã ããªãã¡ã$r\gt 2^{p-2}$ ã§ãããã¨ãå¿ è¦ååã§ããã$\qed$
Observation 11: $r = 2^{2p-1}\bmod m$ ã¯æ¬¡ã®ããã«ãªã£ã¦ããã
$p=53$ ã¨ãããã¾ãã$m = 2^{p-1}+i$ ã¨ããã
$i$ | $0$ | $1$ | $2$ | $3$ | $\cdots$ | $47453132$ | $47453133$ | $47453134$ | $47453135$ |
---|---|---|---|---|---|---|---|---|---|
$r$ | $0$ | $2$ | $8$ | $18$ | $\cdots$ | ${\tiny 4503599473218848}$ | ${\tiny 4503599663031378}$ | ${\scriptsize 178020282}$ | ${\scriptsize 367832819}$ |
ãã $k$ ã«å¯¾ãã$r = 2i^2 - k\cdot(2^{p-1}+i)$ ã¨ãªã£ã¦ããã
Proof
$$ \begin{aligned} 2^{2p-1} &= (2^p-2i)\times(2^{p-1}+i) + 2i^2 \\ &= (2^p-2i)\times(2^{p-1}+i) + \Floor{\tfrac{2i^2}{2^{p-1}+i}}\cdot (2^{p-1}+i) + (2i^2\bmod (2^{p-1}+i)) \\ &= \left(2^p-2i+\Floor{\tfrac{2i^2}{2^{p-1}+i}}\right)\times(2^{p-1}+i) + \left(2i^2-\Floor{\tfrac{2i^2}{2^{p-1}+i}}\cdot(2^{p-1}+i)\right) \end{aligned} $$ ã§ããã$k$ 㯠$2i^2\div(2^{p-1}+i)$ ã®åã«ä»ãªããªãã$\qed$
ããã§ã次ã®ãããªæ¹éãèãããã¾ãã
- $k$ ãåºå®ããã
- ãã®ç¯å²ã§ $r\gt 2^{p-2}$ ãæºãã $i$ ã®æå°å¤ $i^{\star}$ ãæ±ããã
- ããã¯äºåæ¢ç´¢ã§ããã
- $i^{\star}$ ã§è¨ç®ãããã¾ã $r^{\star}$ ã $r^{\star}\lt\tfrac m2$ ãæºããã¦ããã°ãããçãã
- æºããã¦ããªããã°æ¬¡ã® $k$ ã試ãã
$k$ ã®ä¸çã¯ããããããªããã®ã®ãããã¤ã試ããã¨ããã§ã¯ååå°ãã $k$ ã§åæ¢ãã¾ãããä»åã®ç®çã¯è¨ç®éæ¹åã§ã¯ãªãã®ã§ããã¨ãã¾ãã
Example 12:
ã¡ã¸ã£ã¼ãªå¦çç³»ã«ããã _Float16
, float
, double
, long double
, __float128
ãæ³å®ããä¸è¨ã®è¨ç®ãããã
type | minimum $x\in(1\ldots2)$ subject to $\roundp{\tfrac1x}\otimes x\lt 1$ | $p$ | $k$ |
---|---|---|---|
_Float16 |
$\texttt{41c}_{(16)}\times2^{-10}$ | $11$ | $1$ |
float |
$\texttt{801467}_{(16)}\times2^{-23}$ | $24$ | $6$ |
double |
$\texttt{1000000f5cbf2a}_{(16)}\times2^{-52}$ | $53$ | $29$ |
long double |
$\texttt{800000005a82799a}_{(16)}\times2^{-63}$ | $64$ | $0$ |
__float128 |
$\texttt{1000000000000022df0668c89bf13}_{(16)}\times2^{-112}$ | $113$ | $9$ |
long double
以ä¸ã®åã«ã¤ãã¦ã¯ã$1$ ããæé ã«å
¨æ¢ç´¢ãããã®ã¨å¤ãä¸è´ãããã¨ã確èªããã
ã¾ããååã®å¤ã«ã¤ãã¦ãå®éã« $\roundp{\tfrac1x}\otimes x\lt 1$ ã¨ãªããã¨ã確èªããã
ãã¨ãã
ãæµ®åå°æ°ç¹æ°åãã«å¯¾ãã¦ããè¬ã®èª¤å·®ãåºã¦å¤ãªæãã«ãªããã¨ãããããªæè¦ãæã£ã¦ãã人ã¯ããããå¤ãã®ã§ã¯ãªããã¨æã£ã¦ãã¾ããããããã解æã§éãã§ããã¨ããç¨åº¦ãæ°å¦å´ã®ããæ¹ã§ï¼æéã¯å¤å°ããã£ã¦ãï¼ããç¨åº¦ã¾ã¨ãã«æ±ãããã¨ããæ°æã¡ã«ãªã£ã¦ããã®ã§ã¯ãªãã§ãããããå°ãªãã¨ããã³ã¡ããã®ä¸ã§ã¯ããããæãã«ãªã£ã¦ãã¾ãããã³ã³ãã¹ãä¸ã«ãªã«ãã§ããããªæ°ã¯ã¾ã ãã¾ããã
ã¨ã¯ããã¾ã åºç¤ãã¼ãã®è§£èª¬è¨äºãæ¸ãã¦ããªãã®ã§ãåã£ããããæ´ãã¦ããªã段éã®äººã«ã¯ã¾ã ããã¨ããæ°ã¯ãã¦ãã¾ãã ããå°ãå¾ ã£ã¦ãã¦ããããã¨ããããã§ãã
ã¨ããã®ããããç¨åº¦èªåã親ããã§ããªã段éã§ã¯åºç¤ç¨ã®è¨äºã«ãªã«ãæ¸ãã¹ããå¤æããããããã§ãã ããã«ãªã£ãä¸æ¸ããäºã¤ãä¸ã¤ãããããã¾ãã
ãã®ç·´ç¿ã®ããã«æ¸ããã®ããSqrt Inequality ã®è¨äº 㨠floor(n * 0.1) ã®è¨äº ã¨ä»åã®è¨äºã§ããï¼æåã«ããã«ãã¦ã¯éããªããï¼ï¼ã ããä¸ã¤ç·´ç¿ã«æ¸ããã¨ãã¦ããã®ãããã®ã§ããããçµãããåºç¤ç¨ã®è¨äºãæ¸ããã¨æã£ã¦ãã¾ãã
ããããç´°ã ã¨ããè©°ãè©°ããªè§£æã楽ãããã§ããã競ããæèã§ï¼ã³ã³ãã¹ãä¸ã«è¨ç®éã®ãªã¼ãã¼ãè¦ç©ãããããã®æ軽ãã§ï¼èª¤å·®ã®è¦ç©ãããã§ããããã«ããªãããããããã®ã§ãããããã¨ããã®ãåå¼·ããã¦ããããã§ãã
ãã¾ãå¤ãã®ç«¶ãã er ãèå³ãæããªãã¨ããã«èå³ãæã£ã¦ãã¾ãã¨ããããã³ã¡ããã®ããã¨ããã§ããæ°ã¯ãã¦ãã¾ãããèªåã¨ãã¦ã¯ãã¿ããã¨ããã§ãããã¾ãã
ãã¾ã
#include <cstdio> #include <string> #include <quadmath.h> using f16 = _Float16; using f32 = float; using f64 = double; using f80 = long double; using f128 = __float128; std::string q(f128 x) { char buf[1000]; quadmath_snprintf(buf, sizeof buf, "%.999Qg", x); return std::string(buf); } int main() { int x = 27355; printf("%.99g\n", f16(f16(f16(1.0) / f16(x)) * f16(x))); printf("%.99g\n", f32(f32(1.0F / f32(x)) * f32(x))); printf("%.99g\n", 1.0 / f64(x) * f64(x)); printf("%.99Lg\n", 1.0L / f80(x) * f80(x)); printf("%s\n", q(f128(1.0) / f128(x) * f128(x)).data()); }
0.99951171875 0.999999940395355224609375 0.99999999999999988897769753748434595763683319091796875 0.9999999999999999999457898913757247782996273599565029144287109375 0.99999999999999999999999999999999990370350278063820734720110287075363407309491758923059023800306022167205810546875
5 ã¤ã®åãã¹ã¦ã§ $\roundp{\tfrac1x}\otimes x\lt 1$ ã«ãããæå°ã®éè² æ´æ°ã§ããå®éã«ã¯ _Float16
ã§ã¯ $\roundp{x}\ne x$ ãªã®ã§ã¡ãã£ã¨ãããã§ãã
èªåã§ä»®æ°é¨ $p$ bits ã®æµ®åå°æ°ç¹æ°åãã¨ãã¥ã¬ã¼ãããåãä½ããããã以å¤ã®åã«ã¤ãã¦éã¶ãã¨ãã§ãã¾ãï¼éã³ã¾ããï¼ã
ããã
ãããã§ãã
*1:$1+\varepsilon\lt 2$ ã該å½ã®æµ®åå°æ°ç¹æ°åã§è¡¨ãã¦ãããã¨ããã$\roundp{1-\varepsilon} = 1-\varepsilon$ ã§ãã