What is the difference between the calculation in numpy.linalg.matrix_power and directly multiplying the matrix by itself those many times? This is what I observed and was confused about.
>> Matrix A:
[[2 4 5],
[4 4 5],
[8 3 1]]
>> numpy.linalg.matrix_power(A, 3)
[[556 501 530]
[676 579 600]
[708 500 471]]
>> (A * A) * A
[[556 501 530]
[676 579 600]
[708 500 471]]
But
>> A = normalize(A, axis=1, norm='l1')
[[0.18181818 0.36363636 0.45454545]
[0.30769231 0.30769231 0.38461538]
[0.66666667 0.25 0.08333333]]
>> numpy.linalg.matrix_power(A, 3)
[[0.34477471 0.31773179 0.3374935],
[0.36065187 0.31371769 0.32563044],
[0.42154896 0.2984543 0.27999674]]
>> (A * A) * A
[[0.00601052 0.04808415 0.09391435]
[0.02913063 0.02913063 0.05689577]
[0.2962963 0.015625 0.0005787 ]]
Why are the results different? Which one is the correct (expected) computation?
This is the simple code I am checking
import numpy as np
A = np.matrix([[2, 4, 5], [4, 4, 5], [8, 3, 1]])
#A = normalize(A, axis=1, norm='l1') #uncommented for the 2nd part
print(A)
print(np.linalg.matrix_power(A, 3))
print((A * A) * A)