# Diagonalizing a symbolic matrix

I am trying to diagonalize the following matrix $$$$\left(\begin{array}{cccc} { \frac{1-K\left(x_{2}^{2}+x_{3}^{2}\right)}{1-K|x|^{2}}} & { \frac{K x_{1} x_{2}}{1-K |x|^{2} }} & { \frac{K x_{1} x_{3}}{1-K|x|^{2}}} \\ { \frac{K x_{1} x_{2}}{1-K|x|^{2}}} & { \frac{1-K\left(x_{1}^{2}+x_{3}^{2}\right)}{1-K|x|^{2}}} & { \frac{K x_{2} x_{3}}{1-K|x|^{2}}} \\ {\frac{K x_{1} x_{3}}{1-K|x|^{2}}} & { \frac{K x_{2} x_{3}}{1-K|x|^{2}}} & { \frac{1-K\left(x_{1}^{2}+x_{2}^{2}\right)}{1-K|x|^{2}}} \end{array}\right)$$$$ with a quick substitution of the variables from $$x_{1},x_{2},x_{3} \rightarrow x,y,z$$. My attempt is as follows,

B = Norm[{x, y, z}];
r = 1 - K*B^{2}
A =
{{(1 - K (y^{2} + z^{2}))/r, (K*x*y)/r, (K*x*z)/r},
{(K*x*y)/r, (1 - K (x^{2} + z^{2}))/r, (K*y*z)/r},
{(K*x*z)/r, (K*y*z)/r, (1 - K (x^{2} + y^{2}))/r}};
A //  MatrixForm
evecs = Eigenvectors[A];
Inverse[Transpose[evecs]].A.Transpose[evecs] // Chop // MatrixForm;


After attempting to find the eigenvectors of the above matrix I get an error saying

Eigenvectors:Argument\$ "at position 1 is not a non-empty square matrix.

Did I make a mistake when writing the matrix? I apologize as I have near to no experience typing in Mathematica, hence, I am not even sure if Mathematica can perform such symbolic calculations as I was told that it could. Any help would be greatly appreciated.

Just remove all the extra {} stuff you have in exponents. i.e. do not write x^{2} but use x^2 etc.. for all the other places.

B = Norm[{x, y, z}]
r = 1 - K*B^2
A = {
{(1 - K (y^2 + z^2))/r, (K*x*y)/r, (K*x*z)/r},
{(K*x*y)/r, (1 - K (x^2 + z^2))/r, (K*y*z)/r},
{(K*x*z)/r, (K*y*z)/r, (1 - K (x^2 + y^2))/r}
};
A // MatrixForm
evecs = Eigenvectors[A];
Inverse[Transpose[evecs]].A.Transpose[evecs] // Chop // MatrixForm


Btw, to get rid of all the Abs stuff which makes the norm hard to read, replace your first line with this

Compare:

 B = Norm[{x, y, z}]


And

 B = Assuming[Element[{x, y, z}, Reals], Simplify@Norm[{x, y, z}]]


• Thank you so much!! This works – lastgunslinger Feb 6 '20 at 2:03