計算機イプシロン
[Wikipedia|▼Menu]

計算機イプシロン(けいさんきイプシロン、: machine epsilon)は、浮動小数点数において、「1より大きい最小の数」と1との差のことである[1]。機械イプシロン(きかいイプシロン)とも言う。また、それぞれの「イプシロン」はエプシロンとも表記される。
概要

コンピュータで扱われる浮動小数点数は、指数部と仮数部に分かれており、単に小さい数を表すだけであれば指数部を小さくすれば表現が可能である。一方、「1より大きい最小の数」のような場合は、仮数部を使って微小な差を表現することとなる。その限界が計算機イプシロンである。

b {\displaystyle b} 進法で p {\displaystyle p} 桁の浮動小数点数の場合、計算機イプシロンは b 1 − p {\displaystyle b^{1-p}} となる[1]。例えば、IEEE 754のbinary32(単精度)では、 b = 2 {\displaystyle b=2} 、 p = 24 {\displaystyle p=24} [2]なので、 ϵ = 2 1 − 24 = 1.192 × 10 − 7 {\displaystyle \epsilon =2^{1-24}=1.192\times 10^{-7}} となる。同様にIEEE 754のbinary64(倍精度)では  ϵ = 2 1 − 53 = 2.220 × 10 − 16 {\displaystyle \epsilon =2^{1-53}=2.220\times 10^{-16}} となり,binary128(四倍精度)では  ϵ = 2 1 − 113 = 1.926 × 10 − 34 {\displaystyle \epsilon =2^{1-113}=1.926\times 10^{-34}} となる。
定義の混乱

元来の定義では上述のとおりとなっているが、一部では「 1 + x ≠ 1 {\displaystyle 1+x\neq 1} となる最小の x {\displaystyle x} 」という定義、あるいは説明をしている例が存在する[3]。後者の定義では、浮動小数点演算の丸め処理の定義に依存して値が変化してしまう[1]ため、厳密には同じでない。
各プログラミング言語での対応
C言語

C言語においては、<float.h>でFLT_EPSILON、DBL_EPSILON、LDBL_EPSILONというマクロ定数が定義されており、それぞれfloat型、double型、long double型の計算機イプシロンの値となっている[1]
C++

C++ではテンプレートを利用したstd::numeric_limits<T>::epsilon()関数が定義されている[4]。返却される値は前述のC言語の定数と同値である。
.NET

Microsoftの.NET Framework基本クラスライブラリに、System.Double.Epsilonという定数フィールドが定義されているが、これは浮動小数点方式で表現可能な最小の正の非正規化数であり、計算機イプシロンではない[5]
Julia

Julia は標準で計算機イプシロンを取得する関数があり eps(Float32) のように使用する。
脚注^ a b c d 奥村晴彦『C言語による最新アルゴリズム事典』技術評論社、1991年、33頁。.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation.cs-ja1 q,.mw-parser-output .citation.cs-ja2 q{quotes:"「""」""『""』"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free a,.mw-parser-output .citation .cs1-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited a,.mw-parser-output .id-lock-registration a,.mw-parser-output .citation .cs1-lock-limited a,.mw-parser-output .citation .cs1-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription a,.mw-parser-output .citation .cs1-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:#d33}.mw-parser-output .cs1-visible-error{color:#d33}.mw-parser-output .cs1-maint{display:none;color:#3a3;margin-left:0.3em}.mw-parser-output .cs1-format{font-size:95%}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}ISBN 4-87408-414-1。 
^ データとしては23桁であるが、正規化数では先頭に1が補われ、24桁の値となる。
^ Data Type Constants 。Microsoft Docs
^ std::numeric_limits<T>::epsilon - cppreference.com
^ Double.Epsilon Field (System) 。Microsoft Docsに「The value of the Epsilon property is not equivalent to machine epsilon, ...」とある。

関連項目


次ページ
記事の検索
おまかせリスト
▼オプションを表示
ブックマーク登録
mixiチェック!
Twitterに投稿
オプション/リンク一覧
話題のニュース
列車運行情報
暇つぶしWikipedia

Size:13 KB
出典: フリー百科事典『ウィキペディア(Wikipedia)
担当:undef