Name

assert_sumcond — Computes the condition number of the sum function.

Calling Sequence

   [c,y] = assert_sumcond ( x )
   
   

Parameters

x :

a n-by-m matrix of doubles

c :

a n-by-m matrix of doubles, the condition number

y :

a n-by-m, matrix of doubles, the function values

Description

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>

Examples

// 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

   

Authors

Michael Baudin, DIGITEO, 2010