From help-octave-request at bevo dot che dot wisc dot edu Wed Dec 17 14:17:19 2003 Subject: Octave QR factorization From: "John W. Eaton" To: Bart Vandewoestyne Cc: help-octave at bevo dot che dot wisc dot edu Date: Wed, 17 Dec 2003 14:16:55 -0600 On 17-Dec-2003, Bart Vandewoestyne wrote: | While I was checking the correctness of an exercise given to my | students during one of my algebra exercise sessions, i found the | following curiosity: | | The purpose of the exercise was for students to calculate the QR | factorization of a given matrix A. Now all I wanted to do is enter | the factorization we found by hand into Octave and see if the product | of Q and R is again the original matrix A. | | What I found is that when I multiply the matrices Q and R we've found | by hand and then check for Q*R==A, Octave tells me that Q*R is not | equal to A, most probably due to rounding errors I guess... | | If I run the same script in Matlab, Matlab *does* give me that | Q*R=A... so it doesn't experience the rounding errors as much as | Octave does??? | | So now my question is: why does Matlab gives different results than | Octave? Is there a big difference in the implementation of QR between | Matlab and Octave? Is there a way to decrease the rounding errors | made by Octave so we get the same accuracy as Matlab? | | The script I used can be found at | http://www.cs.kuleuven.ac.be/~bartv/p370_oef1_6_17.m You don't provide details about your installation of Octave, but I'm going to guess that it is on x86 hardware. I ran your test on an AMD Athlon system and it "failed". I also ran it on a SPARC system and it "succeeded". I'm fairly certain that the difference is in the way that floating point operations are implemented on different machines (unfortunately, there are differences even for systems that mostly conform to the IEEE standard for floating point arithmetic). You might find this message http://www.octave.org/mailing-lists/help-octave/2003/2185 helpful. jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------