On Nov 4, 2009, at 11:08 AM, Michael Orlitzky wrote:

>
> Jason Grout wrote:
>>
>> I don't think it's an issue of irrational versus rational.  It's
>> numerical precision and inexact floating point numbers.  This  
>> matrix is
>> terribly ill-conditioned.  It is right on the border line between  
>> being
>> invertible or not, numerically speaking:
>
> No, it isn't. *My* matrix contains nine integer multiples of 0.1,  
> which
> any high school student can show represents a linearly-dependent  
> system
> in a few seconds.

Technically, your matrix does not contain integer multiples of 0.1, it  
contains approximations to integer multiples of 0.1, represented base  
2, truncated to 53 bits of precision.

sage: (0.1).exact_rational()
3602879701896397/36028797018963968

As you pointed out, you could do this over the rationals (where they  
are actual integer multiples of 0.1) and it works fine. Doing it with  
floating point numbers introduces rounding error, whence the  
discrepancy. I would highly recommend

http://docs.sun.com/source/806-3568/ncg_goldberg.html

at least the first couple of sections.

>
>> sage: m.change_ring(RDF).SVD()[1]
>>
>> [   0.772642968023               0.0               0.0]
>> [              0.0    0.450580563234               0.0]
>> [              0.0               0.0 3.13289758759e-17]
>>
>> As you probably know, the ratio between the smallest and largest
>> eigenvalues being so high gives us an indication that this matrix is
>> really a messy one numerically, and deserves the strictest of  
>> attention.
>
> I don't know that. Why would I know that? Why would I compute the
> smallest and largest eigenvalues when I just want the RREF of the  
> thing?
> The original matrix is *not* messy. It's only messy once SAGE  
> handles it
> in a messy way.

It's messy the instant you type it in with decimal points, as it  
starts using floating point numbers internally.

> What's worse is that there is no indication that the results of
> echelon_form() are incorrect. If I didn't know that matrix was  
> singular,
> I would have happily continued my work with results that were
> essentially made up. Sure, I could check each matrix by hand, but
> /that's why I'm using SAGE in the first place/.

In your case I would recommend staying away from linear algebra over  
inexact fields (like the reals) and do everything exactly until you  
have a good sense of how rounding errors can be controlled, especially  
if you're dealing with possibly singular matrices (which are ill  
conditioned as indicated above). If you want exact answers, work over  
an exact ring, and the (well known) issues of rounding errors won't  
bite you like this.

>> If we are allowed to do the computations with exact arithmetic (e.g.,
>> using fractions instead of decimals), then we can compute its rank  
>> and
>> echelon form exactly.  You see the same problems in other math  
>> software
>> too, with different matrices.  If pressed, I could come up with an a
>> very nice-looking matrix example from a linear algebra textbook  
>> problem
>> that matlab totally gave the wrong answer to because it was a very
>> ill-conditioned matrix.
>
> I concede that MATLAB et al. can under certain circumstances produce
> incorrect results, but that doesn't mean that SAGE should give up on
> correctness completely. No other software fails on this example.

Eventually, using floating point, they're going to give incorrect  
results. It's unclear whether its better to have consistent failure  
right away, or work for some simple cases but give bad results later on.

- Robert



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to