[R] matrix power
(Ted Harding)
Ted.Harding at manchester.ac.uk
Mon Aug 10 23:53:29 CEST 2009
On 10-Aug-09 21:31:30, cindy Guo wrote:
> Hi, All,
> If I have a symmetric matrix, how can I get the negative square root
> of the matrx, ie. X^(-1/2) ?
>
> Thanks,
>
> Cindy
X <- matrix(c(2,1,1,2),nrow=2)
X
# [,1] [,2]
# [1,] 2 1
# [2,] 1 2
E <- eigen(X)
V <- E$values
Q <- E$vectors
Y <- Q%*%diag(1/sqrt(V))%*%t(Q)
Y
# [,1] [,2]
# [1,] 0.7886751 -0.2113249
# [2,] -0.2113249 0.7886751
solve(Y%*%Y) ## i.e. find its inverse
# [,1] [,2]
# [1,] 2 1
# [2,] 1 2
Hence (Y%*%Y)^(-1) = X, or Y = X^(-1/2)
Hopingb this helps,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 10-Aug-09 Time: 22:53:25
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list