On 26 jan, 12:47, "D. S. McNeil" <[email protected]> wrote: > > (-6.66133814775094e-16, -1.00000000000000) > > <---------------------------------------??? > > > Why isn't the first coordinate 0??? In theory it should be... > > Such things are basically inevitable with floating point whenever any > number involved can't be perfectly represented-- and in this case > sqrt(2) is irrational to boot. Sometimes you luck out and sometimes > you don't. help(RR) gives a brief warning. Here I think you can > avoid the problem by working not in RR (2^(-53) ~ 1e-16) but the > symbolic ring SR.
I wasn't sure if it was the representation problem... > > sage: V=VectorSpace(RR,2,inner_product_matrix=[[1, -sqrt(2)/2], [- > sqrt(2)/2, 1]]) > sage: V.basis() > [ > (1.00000000000000, 0.000000000000000), > (0.000000000000000, 1.00000000000000) > ] > sage: V=VectorSpace(SR,2,inner_product_matrix=[[1, -sqrt(2)/2], [- > sqrt(2)/2, 1]]) > sage: a,b = V.basis() > sage: a,b > ((1, 0), (0, 1)) > sage: r1=Sigma(a,b);r1 > (sqrt(2), 1) > sage: r2=Sigma(r1,a);r2 > (-1, -sqrt(2)) > sage: r3=Sigma(r2,r1);r3 > (0, -1) > This change does the thing!!! It is perfect for me!! > If you really want to work in floating point you're going to have to > loosen your definition of equality -- see, > e.g.,http://floating-point-gui.de/errors/comparison/-- possibly doing so > rigorously with interval arithmetic. > > Doug > > -- > Department of Earth Sciences > University of Hong Kong Thanks a lot! J-P -- 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 URL: http://www.sagemath.org
