find a nonsingular matrix p such that p^{-1}ap is a diagonal matrix, use sym(a) to get elements of p. in matlab in matlab
main.m
% Given matrix AA = [1, 2; 3, 4];
% Calculate the symmetric part of AsymA = 0.5*(A + A');
% Find the nonsingular matrix P using eigendecomposition[V, D] = eig(symA);
P = V;
% Calculate P^-1P_inv = inv(P);
% Calculate P^-1 * A * PP_inv * A * P