Guest User

Untitled

a guest
Jul 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. # assign matrices
  2. A <- matrix(c(.8, .4, .1, .5), 2, 2)
  3. X <- matrix(c( 1, .5, .5, 2), 2)
  4.  
  5. # compute with above formulas
  6. eg <- eigen(A)
  7. U <- eg$vectors
  8. U_t <- t(U)
  9. las <- eg$values
  10. T. <- crossprod(U, X %*% U)
  11. Z <- T. / (1 - tcrossprod(las))
  12. S <- solve(U_t, t(solve(U_t, t(Z))))
  13.  
  14. # naive solution
  15. nai <- X
  16. for(i in 1:1000)
  17. nai <- crossprod(A, nai %*% A) + X
  18.  
  19. nai - S
  20. #R [,1] [,2]
  21. #R [1,] -3.55e-15 -4.44e-16
  22. #R [2,] -8.88e-16 0.00e+00
Add Comment
Please, Sign In to add comment