[R] package expm: matrix powers within a product of matrices: operation precedence

Rainer Sachs sachs at math.berkeley.edu
Mon Jun 17 22:20:23 CEST 2013


package expm: matrix powers within a product of matrices: operation
precedence

    I want to double check that for M and N kxk mtrices and v a k-vector
    M%^%2%*%N%*%v is not automatically read as (M%^%2)%*%N%*%v or
    M%*%N%^%2%*%v is not automatically read as M%*%(N%^%2)%*%v or
    both

    I had been assuming the usual precedence (powers first, then
multiplication) applies for matrix powers and multiplication in expm. I was
getting unexpected results. In desperation I tried putting in the
parentheses and seem to be getting much more reasonable answers. But I am so
surprised that the matrix power operation is, apparently, not automatically
given precedence over the matrix multiplication operation that I do not
trust that adding parentheses has cured my bug. Maybe I am still making some
other mistake instead. Can anyone confirm that in fact the parentheses are
(sometimes?) essential? I could not find any documentation, one way or the
other, just definitions of the power operator and of matrix exponentials.

    TIA Rainer K. Sachs, Prof emertitus of math 





--
View this message in context: http://r.789695.n4.nabble.com/package-expm-matrix-powers-within-a-product-of-matrices-operation-precedence-tp4669733.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list