assert_sumcond — Computes the condition number of the sum function.
[c,y] = assert_sumcond ( x )
a n-by-m matrix of doubles
a n-by-m matrix of doubles, the condition number
a n-by-m, matrix of doubles, the function values
Computes the condition number of the sum function. The sum function has a large condition number if the sum is small, but the values are of opposite sign and of very different magnitudes.
<latex> \begin{eqnarray} c(x) = \frac { \sum_{i=1,n} |x_i|}{\left| S(x) \right|} \end{eqnarray} </latex>
where
<latex> \begin{eqnarray} S(x) = \sum_{i=1,n} x_i \end{eqnarray} </latex>
// A badly conditionned sum, with inaccurate result xl = 10^(1:15); x = [-xl xl+0.1]; [c,y] = assert_sumcond ( x ) expected = 1.5 // A badly conditionned sum, with accurate result ! // The bad conditionning does not imply that the result is not accurate. xl = 10^(1:15); x = [-xl xl]; [c,y] = assert_sumcond ( x ) expected = 0