Question: Bug in ConditionNumber

Hello,

While doing some tests, we encountered an issue with LinearAlgebra[ConditionNumber], possibly caused by another routine in the LinearAlgebra package (MatrixInverse?). I include an example worksheet bug-maple.mw for easy testing.

To reproduce, you should start by creating this matrix:

restart;
with( LinearAlgebra ):
Digits := 50:
n := 4;
M := [ seq( cos( Pi*j/n ), j=0..n ) ];
V := VandermondeMatrix( M );

Now compute the condition number (infinity-norm) of V:

c1 := ConditionNumber(V);
c1 := simplify(%);
evalf(c1); # this gives exactly 40

We can still compute this exactly and get 40.

This is the same result as with linalg[cond]:

c2 := linalg[cond](V);
c2 := simplify(%);
evalf(c2);

Now increase the value of n to 5 and redo the test.
The exact result should be 120, but LinearAlgebra[ConditionNumber] gives the wrong result!
On the other hand, linalg[cond] gives the correct, exact result (after simplification).

n := 5; # this gives a wrong result :-(

We could use Norm(V) * Norm(Inv(v)) since this should be equal to the condition number.
But then it seems there's something bad inside the MatrixInverse routine.
Again, linalg[inverse] gives the correct, exact result.
So compare the two results:

n := 4;
simplify(MatrixInverse(V));
linalg[inverse](V);

Finally, to make matters even worse, ConditionNumber gives completely wrong results when using a float-matrix, while linalg[cond] does not:

n := 3;
V := VandermondeMatrix( evalf(M) );
c1 := ConditionNumber( V );
c2 := linalg[cond]( V );

For n=3, we get c1=10.6 and c2=16.
For n=4, we get c2=5 and c2=40.
For n=5, we get c1=68.07 and c2=119.999.

Is this what it looks like? With it being a really, really ugly bug?

-- Many thanks for your reply,

Franky

Please Wait...