On Monday, July 1, 2013 2:06:54 AM UTC-7, Harald Schilly wrote: > On Monday, July 1, 2013 10:45:36 AM UTC+2, David Ingerman wrote: The > following matrix operation produces wrong answer in online Sage: > M=matrix(RR,[[7,3,10,13],[1,1,2,2],[1,2,3,4],[1,3,5,7]]);det(M);invM=M^(-1);invM*M;det(invM) > > RR stands for the "real numbers" with the usual 53bits of precision, e.g. > 5.123957322…. > QQ are rational numbers where two large integers build up each number, > e.g. 41000041/333000333000333000333000333000333000333 > Therefore, QQ has a much higher precision … but is much slower and uses more > memory. > > In your case, the lack of precision in RR causes you troubles and you have to > find a way to pose the problem you want to solve differently. You cannot rely > on QQ, because in bad cases, the expressions blow up and eat all your memory. > More generally, this is not a Sage related problem, but related to all > calculations your are doing "natively" with your CPU. > > To see in advance when this happens, you have to calculate the > conditional number of the matrix. I think that's only in numpy (or I > haven't found it). > > sage: M=matrix(RR,[[7,3,10,13],[1,1,2,2],[1,2,3,4],[1,3,5,7]]) > sage: import numpy as np > sage: np.linalg.cond(M) > 104.85355762315329 > > http://en.wikipedia.org/wiki/Condition_number > > Here are some decomposition methods that might help: > > http://en.wikipedia.org/wiki/Matrix_decomposition > > H
But this is a very small matrix and conditional number is not large... -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.