title: Matrix power by Singular Value Decomposition
body: <p>The singular Value Decomposition of a square matrix A is <code>A = U*S*V.T</code>.</p>
  
  <p>We can take the n'th power of A as follows: <code>A^3= U*S^3*V.T</code></p>
  
  <p>Below is some basic python code where I am applying this. </p>
  
  <pre><code>import numpy as np
  A = np.matrix('1 2; 3 4')
  A_3rd = np.linalg.matrix_power(A,3)
  assert np.array_equal(A_3rd,  np.dot(A, np.dot(A,A))  )
  
  # svd for A
  U,s,V = np.linalg.svd(A)
  S = np.zeros(A.shape); S[:2,:2]= np.diag(s) # fill diagonals
  S = np.asmatrix(S) # convert from array to matrix
  print U.shape, S.shape, V.shape # print shapes
  
  A_3rd_by_SVD =np.dot(U, np.dot(np.linalg.matrix_power(S, 3),V)) 
  </code></pre>
  
  <p>However I do not get the same value as numpy.linalg_matrix_power(). Can someone explain why this is happening?</p>
  
  <pre><code>&gt;&gt;A_3rd 
  matrix([[ 37,  54],
          [ 81, 118]])
  &gt;&gt;A_3rd_by_SVD
  matrix([[  38.,   54.],
          [  86.,  122.]])
  </code></pre>