From: Andrew Robinson <A.Robinson_at_ms.unimelb.edu.au>

Date: Sat 20 Jan 2007 - 19:15:21 GMT

Date: Sat 20 Jan 2007 - 19:15:21 GMT

Hi Robert,

does this help?

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

A3<-matrix(nrow=3,c(1/(2^.5),1/(2^.5),0))
sum(A3^2)==1

all.equal(sum(A3^2), 1)

Cheers,

Andrew

On Sat, Jan 20, 2007 at 02:00:18PM -0500, Robert Barber wrote:

*> Hi,
**>
*

> I apologize if there is a simple answer to this question that I've

*> missed. I did search the mailing list but I might not have used the
**> right keywords. Why does sum(A3^2) give the result of 1, but
**> sum(A3^2)==1 give the result of FALSE?
**>
**> > A3<-matrix(nrow=3,c(1/(2^.5),1/(2^.5),0))
**> > A3
**> [,1]
**> [1,] 0.7071068
**> [2,] 0.7071068
**> [3,] 0.0000000
**> > sum(A3^2)
**> [1] 1
**> > sum(A3^2)^.5
**> [1] 1
**> > sum(A3^2)==1 # here's the part I don't understand
**> [1] FALSE
**> > sum(A3^2)^.5==1 # here's the part I don't understand
**> [1] FALSE
**>
**> I realize that it has something to do with the conversion of the square
**> roots into decimals. But shouldn't it then give me some number other
**> than 1 as the result for sum(A3^2)? Are there other ways to do this
**> than what I've tried? I'm trying to confirm that A3 is a unit vector.
**>
**> Thank you for your help.
**>
**> Bob B.
**>
**> ______________________________________________
**> R-help@stat.math.ethz.ch mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
**> and provide commented, minimal, self-contained, reproducible code.
*

-- Andrew Robinson Department of Mathematics and Statistics Tel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.Received on Sun Jan 21 06:28:29 2007

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Sat 20 Jan 2007 - 20:30:28 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*