William Stein wrote: > On Thu, Apr 2, 2009 at 6:23 PM, Jason Grout <[email protected]> > wrote: >> kcrisman wrote: >>>> Incidentally, doing everything with floats would I >>>> think be *very* inappropriate for an undergrad class in linear >>>> algebra, where most of the by hand problems require the students to >>>> use rational numbers. >>> Yes, which is why he only uses Octave for half the semester, I think, >>> or something like that. >>> >> >> Remember that both octave and matlab have a "format rat" mode, which >> displays fractions instead of floating point numbers. Rounding to get >> these nice displayed numbers is another issue, but it does look prettier >> and closer to what you do by hand. >> >> Jason > > And Octave and Matlab give different answers by default and both > blatantly *lie* whenever there is overflow. Matlab and Octave are in > my opinion totally unsuitable for undergraduate linear algebra > teaching, except in a numerical analysis course. As a person who > actually knows what a rational number is, the behavior of Matlab makes > me cringe. > > For example, in Octave: > > octave:1> format rat; > octave:2> a = [-86/17,40/29,-68/43,-20/11;-24/17,-1/38,-2/25,49/17] > a = > -86/17 40/29 -68/43 -20/11 > -24/17 -1/38 -2/25 49/17 > octave:3> rref(a) > ans = > 1 0 155/2122 -725/384 > 0 1 -152/173 -6553/795 > > and in Matlab: > >>> format rat; >>> a = [-86/17,40/29,-68/43,-20/11;-24/17,-1/38,-2/25,49/17] > a = > -86/17 40/29 -68/43 -20/11 > -24/17 -1/38 -2/25 49/17 >>> rref(a) > ans = > 1 0 13/178 -725/384 > 0 1 -152/173 -1426/173 > > The truth has little to do with either of the two different outputs above: > > sage: a = matrix(2,[-86/17, 40/29, -68/43, -20/11, -24/17, -1/38, -2/25, > 49/17]) > sage: a.echelon_form() > [ 1 0 306034/4189705 -404710/214357] > [ 0 1 -18405604/20948525 -30037214/3644069]
Just today, I was diagonalizing a matrix in matlab (yeah, okay, it was a class of engineers and everyone knew matlab). So I did an example of a non-diagonalizable matrix, and asked for the matrix of eigenvectors. I was surprised to see matlab print some of the entries of the eigenvectors as "*", which I had never seen before. One of the students said that that signified a very small value (which made sense in the context). Of course, when asking for the inverse, matlab complained, but still gave us a totally false answer. Needless to say, I fired up Sage, which correctly showed zeros and correctly refused to invert the matrix of eigenvectors because it wasn't invertible. So, in short, I totally agree with you. I just wanted to point out that if pretty output was an issue, there was a command to give nice answers that seems to work for the by-hand problems students are given in the textbooks. Jason --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
