[scilab-Users] Problem with Floating point and determinant of a matrix

Prof. Dr. Reinaldo Golmia Dante tiraduvidascefet at yahoo.com
Mon Dec 27 23:43:22 CET 2010


Hi Calixte,

Thank you for your comment.

However, I do not still understand your suggestion: "--> 
n=10;T=floor(rand(n,n-1)*200-100);A=[T,sum(T,2)];det(A)"

A does not show as a singular matrix for Scilab. I executed it on Scilab, as 
follows:

-->n=10;T=floor(rand(n,n-1)*200-100);A=[T,sum(T,2)];det(A)
 ans  =
 
  - 12228.029  


What does it mean ? The determinant of A is different to zero, so A is 
nonsingular matrix. Could you be clear in your
example ?

In regards to the paper, I am going to read it.

Thank you for your attention.

All best,
Reinaldo.



----- Original Message ----
From: Calixte Denizet <calixte at contrib.scilab.org>
To: users at lists.scilab.org
Sent: Mon, December 27, 2010 7:52:05 PM
Subject: Re: [scilab-Users] Problem with Floating point and determinant of a 
matrix

Hi Reinaldo,

Try that:
--> n=10;T=floor(rand(n,n-1)*200-100);A=[T,sum(T,2)];det(A)

A is built to be singular...

Have a look at this article, it could interested you:
http://www.eng.nus.edu.sg/civil/REC2010/documents/papers/038.pdf

Calixte

Le lundi 27 décembre 2010 à 13:15 -0800, Prof. Dr. Reinaldo Golmia Dante
a écrit :
> Hi all,
> 
> I understand that Scilab stores the real numbers with foating point numbers, 
> that is, with limited precision, and the computed value (answer) is not exactly 
>
> equal to 0 (page 23 - manual "Introduction to Scilab").
>  
> Take at look for those examples:
>  
> A = [1 2 3; 4 5 6; 7 8 9]
> A  =
>  
>    1.    2.    3.  
>    4.    5.    6.  
>    7.    8.    9.  
>  
> -->det(A)
>  ans  =
>  
>    6.661D-16  <---------- it should be 0
>  
> -->inv(A)
>  ans  =
>  
>  10^15 *
>  
>  - 4.5035996    9.0071993  - 4.5035996  
>    9.0071993  - 18.014399    9.0071993  
>  - 4.5035996    9.0071993  - 4.5035996            <---------- it should appear 

> an error message because the matrix A is not invertible (or singular).
> 
>  
> -->det(inv(A))
>  ans  =
>  
>    9.007D+15    <-------------- The determinant of invertible matrix A^(-1) 
> does not exist.
>  
> Other example:
> 
> -->B = [1 1; 1 1]
> B  =
>  
>    1.    1.  
>    1.    1.  
>  
> -->det(B)
>  ans  =
>  
>    0.  <-------- it is correct !!
>  
> -->inv(B)
>        !--error 19    <-------- it is correct !!
> 
>  
> The previously examples show two integer matrices A and B. The determinant of 
> matrix A is quite zero, but not,
> and this can propagate an error in case the Scilab developer uses that result 
> into other future calculations or algorithms.
> The determinant of matrix B is equal to 0 and the answer is correct. In case 
>the 
>
> Scilab developer uses that value,
> he or she can use the simple statement for testing like to:
>  if ( det(matrix) <> 0 ) then
> <action 1>                    // The Scilab developer knows that the matrix is 

> invertible (or nonsingular)
> else
> <action 2>                    // The Scilab developer knows that the matrix is 

> not invertible (or singular)
> end
>  
> My doubt: "How can I proceed to design any algorithm, which uses matrix, if the 
>
> determinant of 
> 
> the matrix could not be zero and, as the same time, that matrix is not 
> invertible ?".
> How can I manage this uncertainty ?
>  
> I appreciate to hearing from you some hints to solve this uncertainty.
>  
> Thank you in advance.
>  
> All best,
> Reinaldo.
>  
> PS: I am not MATLAB user, but has MATLAB got this limited precision for 
> determinants ?
> 
> 
>      


      



More information about the users mailing list