条件数(じょうけんすう、英: condition number)は、問題のコンピュータでの数値解析しやすさの尺度であり、その問題がどれだけ数値解析に適しているかを表す。条件数が小さい問題は「良条件 (well-conditioned)」であり、条件数が大きい問題は「悪条件 (ill-conditioned)」である。
たとえば A x = b {\displaystyle Ax=b} という方程式の条件数は、 x {\displaystyle x} を近似的に求める際の不正確さの上限を与える。なお、これには丸め誤差の影響は考慮しない。条件数は行列の属性であって、計算に使うシステムの浮動小数点数の精度やアルゴリズムとは無関係である。この場合(非常に大まかに言って)、 b {\displaystyle b} の変化によって解である x {\displaystyle x} が変化する率が条件数である。従って、条件数が大きければ b {\displaystyle b} の小さな誤差も x {\displaystyle x} の大きな誤差となって現れる。一方、条件数が小さければ、 x {\displaystyle x} における誤差は b {\displaystyle b} における誤差より大きくなることはない。
より正確に条件数を定義すると、 x {\displaystyle x} の相対誤差を b {\displaystyle b} の相対誤差で割った最大比率である。
b {\displaystyle b} の誤差を e {\displaystyle e} とする。すると解 A − − --> 1 b {\displaystyle A^{-1}b} の誤差は A − − --> 1 e {\displaystyle A^{-1}e} となる。解の相対誤差と b {\displaystyle b} の相対誤差の比率は、次のようになる。
‖ ‖ --> A − − --> 1 e ‖ ‖ --> / ‖ ‖ --> A − − --> 1 b ‖ ‖ --> ‖ ‖ --> e ‖ ‖ --> / ‖ ‖ --> b ‖ ‖ --> {\displaystyle {\frac {\Vert A^{-1}e\Vert /\Vert A^{-1}b\Vert }{\Vert e\Vert /\Vert b\Vert }}}
これは容易に次のように書き換えられる。
( ‖ ‖ --> A − − --> 1 e ‖ ‖ --> / ‖ ‖ --> e ‖ ‖ --> ) ⋅ ⋅ --> ( ‖ ‖ --> b ‖ ‖ --> / ‖ ‖ --> A − − --> 1 b ‖ ‖ --> ) {\displaystyle (\Vert A^{-1}e\Vert /\Vert e\Vert )\cdot (\Vert b\Vert /\Vert A^{-1}b\Vert )}
( b {\displaystyle b} と e {\displaystyle e} がゼロでないとき)その最大値は明らかに2つの作用素ノルムの積となる。
κ κ --> ( A ) = ‖ ‖ --> A − − --> 1 ‖ ‖ --> ⋅ ⋅ --> ‖ ‖ --> A ‖ ‖ --> {\displaystyle \kappa (A)=\Vert A^{-1}\Vert \cdot \Vert A\Vert }
同様の定義は、任意の行列ノルムに当てはまる。この数は数値線型代数学にはよく使われるので、行列の条件数 (condition number of a matrix) と名づけられている。
もちろん、この定義はノルムの選択に依存している。
特異値分解の条件数、多項式の解を求める際の条件数、固有値の条件数など、様々な問題について条件数を定義できる。
一般に数値問題が良設定なら、それを関数 f {\displaystyle f} で表すことができ、 m {\displaystyle m} -タプルの実数 x {\displaystyle x} から n {\displaystyle n} -タプルの実数 f ( x ) {\displaystyle f(x)} への写像となる。
するとその条件数は、問題の定義域における解の相対誤差とデータの相対誤差の比の最大値と定義される。
max { | f ( x ) − − --> f ( x ∗ ∗ --> ) f ( x ) | / | x − − --> x ∗ ∗ --> x | : | x − − --> x ∗ ∗ --> | < ϵ ϵ --> } {\displaystyle \max \left\{\left|{\frac {f(x)-f(x^{*})}{f(x)}}\right|\left/\left|{\frac {x-x^{*}}{x}}\right|\right.:|x-x^{*}|<\epsilon \right\}}
ここで ϵ ϵ --> {\displaystyle \epsilon } は問題のデータの変化における何らかの適度に小さい値である。
f {\displaystyle f} が可微分であれば、次のように近似できる。
| f ′ ( x ) f ( x ) | ⋅ ⋅ --> | x | {\displaystyle \left|{\frac {f'(x)}{f(x)}}\right|\cdot \left|x\right|}