<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV></DIV>
<DIV><BR>Woww ... Manjsha, it works !</DIV>
<DIV> </DIV>
<DIV>Interesting command !</DIV>
<DIV> </DIV>
<DIV>Thnx.</DIV>
<DIV> </DIV>
<DIV>Reinaldo.<BR></DIV>
<DIV>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><BR>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><FONT size=2 face=Tahoma>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Manjusha Joshi <manjusha.joshi@gmail.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> users@lists.scilab.org<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Thu, December 30, 2010 4:33:37 AM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [scilab-Users] Problem with Floating point and determinant of a matrix<BR></FONT><BR>
<DIV class=gmail_quote>
<DIV>Hello, </DIV>
<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class=gmail_quote> <BR> <BR> <BR>-->det(A)<BR> ans =<BR> <BR> 6.661D-16 <---------- it should be 0<BR> <BR>-->inv(A)<BR> ans =<BR> <BR> 10^15 *<BR> <BR> - 4.5035996 9.0071993 - 4.5035996 <BR> 9.0071993 - 18.014399 9.0071993 <BR> - 4.5035996 9.0071993 - 4.5035996 <---------- it should appear<BR>an error message because the matrix A is not invertible (or singular).<BR><BR> <BR>-->det(inv(A))<BR> ans =<BR> <BR> 9.007D+15 <-------------- The determinant of invertible matrix A^(-1)<BR>does not
exist.<BR> <BR>Other example:<BR><BR>-->B = [1 1; 1 1]<BR>B =<BR> <BR> 1. 1. <BR> 1. 1. <BR> <BR>-->det(B)<BR> ans =<BR> <BR> 0. <-------- it is correct !!<BR> <BR>-->inv(B)<BR> !--error 19 <-------- it is correct !!<BR><BR> <BR>The previously examples show two integer matrices A and B. The determinant of<BR>matrix A is quite zero, but not,<BR>and this can propagate an error in case the Scilab developer uses that result<BR>into other future calculations or algorithms.<BR>The determinant of matrix B is equal to 0 and the answer is correct. In case the<BR>Scilab developer uses that value,<BR>he or she can use the simple statement for testing like to:<BR> if ( det(matrix) <> 0 ) then<BR><action
1> // The Scilab developer knows that the matrix is<BR>invertible (or nonsingular)<BR>else<BR><action 2> // The Scilab developer knows that the matrix is<BR>not invertible (or singular)<BR>end<BR> <BR>My doubt: "How can I proceed to design any algorithm, which uses matrix, if the<BR>determinant of<BR><BR>the matrix could not be zero and, as the same time, that matrix is not<BR>invertible ?".<BR>How can I manage this uncertainty ?<BR> <BR></BLOCKQUOTE></DIV>clean(det(A))<BR>clean(inv(B))<BR clear=all><BR>
<DIV>This will return value as zero if it is near to zero.<BR>-- <BR>Manjusha S. Joshi <BR>P.I. of project on Use of Open source software for Teaching Maths,<BR> http://fossme.bprim.org<BR>Lecturer in Computational Mathematics, <BR>BIM, Pune, India. <A href="http://www.bprim.org/" rel=nofollow target=_blank>www.bprim.org</A><BR>Mobile: 09822 319328<BR>blog:http://manjushajoshi.wordpress.com/<BR><BR> <BR></DIV></DIV></DIV></DIV></div><br>
</body></html>