I have been learning diagonalization and SVD. I tried to show by code that doing A^n = A* A* A*……* n is slower than when we use the concept of diagonalization where A^n = P*D^n*P^-1
n = 2;% given a matrix
A = rand(1000,1000);% CASE 1
ticproduct_1 = A^n;T1=toc;fprintf('%f is the time matrix multiplication \n',T1 );% CASE 2
tic[P, D]=eig(X);product_2 = P * (D^n)/(P);T2=toc;fprintf('%f is the time for diagonalization :',T2 );
0.014834 is the time matrix multiplication
1.222272 is the time for diagonalization
Best Answer