> -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of statfan > Sent: Saturday, October 22, 2011 10:45 PM > To: r-help@r-project.org > Subject: [R] symmetric matrix multiplication > > I have a symmetric matrix B (17x17), and a (17x17) square matrix A. If do > the following matrix multiplication I SHOULD get a symmetric matrix, > however > i don't. The computation required is: > > C = t(A)%*%B%*%A > > here are some checks for symmetry > > (max(abs(B - t(B)))) > [1] 0 > > C = t(A)%*%B%*%A > > (max(abs(C - t(C)))) > [1] 3.552714e-15 > > Any help on the matter would be very much appreciated. > >
Welcome to the world of floating-point calculation on finite precision computers. You need to read R FAQ 7.31. Your maximum difference is for all intents and purposes equal to zero. Hope this is helpful, Dan Daniel Nordlund Bothell, WA USA ______________________________________________ R-help@r-project.org 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.