I have this code in matlab
b = 0.25*ones(4)
a = [0 1 1 1 ; 1/3 0 0 0 ; 1/3 0 0 0; 1/3 0 0 0]
m = .85*a + .15*b
v = [1/4 1/4 1/4 1/4]
m^1e308*v'
- How does matlab run
m^1e308*v'so quickly? it should mutiply the
matrix1e300times, but it probably do some other calculation,
what is it? -
why does
m^1e309*v'gives :ans =
NaN NaN NaN NaN -
how can I see what
m^infis without using symbolic variables?
I can’t tell you what the internals of Matlab are doing, but note that in general,
A^ncan be done inO(log n)time, notO(n)time.For example,
A^16 = (((A^2)^2)^2)^2.You can also use the eigendecomposition to turn this into scalar powering, i.e. if
A = U*V*U', then the power isU * V^N * U', whereVis a diagonal matrix.Double-precision cannot represent
1e309.Use the eigendecomposition described above. If any of the eigenvalues are smaller than 1, they will go to 0, if any of them are greater than 1, they will go to infinity.