[scilab-Users] Problem with Floating point and determinant of a matrix
Celso Co
celso.co at gmail.com
Thu Dec 30 13:20:14 CET 2010
You can try chopping it off.
> int(A*1d14)/1d14
> 0
On Tue, Dec 28, 2010 at 5:15 AM, Prof. Dr. Reinaldo Golmia Dante
<tiraduvidascefet at yahoo.com> wrote:
> 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 ?
>
>
>
>
--
Eng'r Celso B. Co, PhD ECE
Assistant Professor
Dept. of Electronics, Computer, and Communication Engineering,
Loyola Schools of Science and Engineering, Ateneo De Manila
More information about the users
mailing list