Skip to content
Prev 241096 / 398500 Next

matrix limit

zhiji19 <zhiji19 <at> gmail.com> writes:
Here's a more efficient solution. If you *need* to use a repeat { }
loop, then I am guessing this would be a homework problem ... see
?"repeat" (although that does not actually provide very much guidance ...)

library(expm)  ## needs to be installed first

z <- matrix(1:9,nrow=3)

tmpf <- function(M,n) {
  (diag(nrow(M))+M/n)%^%n
}
tmpf(z,1)
tmpf(z,20)
tmpf(z,100)