# On determining the angle between two matrices using the Euclidean Inner Product

So I was bored and decided to teach myself about matrices for absolutely no reason, and found out about the Euclidean Inner Product. Assuming matrices $$A_{2,2}$$ and $$B_{2,2}$$, the angle between those two matrices would be calculated as$$\theta=\arccos\left(\dfrac{A\cdot B}{|A||B|}\right)$$where $$|A|$$ and $$|B|$$ are the magnitudes of matrices $$A$$ and $$B$$. Now, assuming that the two matrices $$A_{2,2}$$ and $$B_{2,2}$$ are defined as$$A=\begin{bmatrix}a_1&b_1\\ c_1&d_1\end{bmatrix}$$$$B=\begin{bmatrix}a_2&b_2\\ c_2&d_2\end{bmatrix}$$we then define the formula for finding the angle between the two matrices as$$\theta=\arccos\left(\dfrac{a_1a_2+b_1c_2+a_1b_2+b_1d_2+c_1a_2+d_1c_2+c_1b_2+d_1d_2}{\sqrt{a_1^2+b_1^2+c_1^2+d_1^2}\sqrt{a_2^2+b_2^2+c_2^2+d_2^2}}\right)$$However, something to note here is that this is in degrees. To do this formula in radians, the new formula would be$$\theta=\arccos\left(\dfrac{180(a_1a_2+b_1c_2+a_1b_2+b_1d_2+c_1a_2+d_1c_2+c_1b_2+d_1d_2)}{\pi\sqrt{a_1^2+b_1^2+c_1^2+d_1^2}\sqrt{a_2^2+b_2^2+c_2^2+d_2^2}}\right)$$Now say I have two $$2$$ by $$2$$ matrices,$$A=\begin{bmatrix}2&3\\ 1&2\end{bmatrix}$$$$B=\begin{bmatrix}3&2\\ 1&2\end{bmatrix}$$Then, the angle between them would be calculated as$$\theta=\arccos\left(\dfrac{6+3+4+6+3+2+2+4}{\sqrt{4+9+1+4}\sqrt{9+4+1+4}}\right)$$$$\theta=\arccos\left(\dfrac{30}{\sqrt{18}\sqrt{18}}\right)$$$$\theta=\arccos\left(\dfrac{30}{18}\right)$$$$\theta=\arccos\left(\dfrac{5}{3}\right)$$$$\theta=i\ln(3)\quad\text{in both degrees and radians}$$

### My question

Would my understanding of the Euclidean Inner Product be correct, or what could I do to understand it more easily?

### To clarify

1. How I figured out that the angle of the two matrices would be calculated as $$\theta=\arccos\left(\dfrac{A\cdot B}{|A||B|}\right)$$ is (from what I understand) because two vectors being multiplied together would be calculated as $$|\overrightarrow i||\overrightarrow j||\cos\theta$$, where $$\cos\theta$$ is the angle between the $$2$$ vectors, and I have a feeling that it probably would be similar when it comes to determining the angle between two matrices.
• Note that for any inner product space, you would have $| A \cdot B| \leq |A| |B|$ which is known as the Cauchy-Schwarz inequality. Importantly, you would see that in your particular example that this inequality is violated. I do not know much about the example you have given, but you should probably not be multiplying by $180/\pi$. Essentially, the formula for the inner product is treating the matrix as a regular $4$ vector, so you should probably stick to the formula for that inner product. Commented May 30, 2023 at 18:51
• If you want to change angles, you should be multiplying the $180/\pi$ outside the $\arccos$ otherwise you will be doing $\arccos(\text{"some bizarre value greater than 1"})$ and get complex values. Commented May 30, 2023 at 19:23
• Where did you get that expression for the inner product in the numerator? The denominator looks like it comes from the norm induced by the Frobenius inner product Commented May 30, 2023 at 19:28

A fix to my formula:

we then define the formula for finding the angle between the two matrices as$$\theta=\arccos\left(\dfrac{a_1a_2+b_1c_2+a_1b_2+b_1d_2+c_1a_2+d_1c_2+c_1b_2+d_1d_2}{\sqrt{a_1^2+b_1^2+c_1^2+d_1^2}\sqrt{a_2^2+b_2^2+c_2^2+d_2^2}}\right)$$However, something to note here is that this is in degrees. To do this formula in radians, the new formula would be$$\theta=\arccos\left(\dfrac{180(a_1a_2+b_1c_2+a_1b_2+b_1d_2+c_1a_2+d_1c_2+c_1b_2+d_1d_2)}{\pi\sqrt{a_1^2+b_1^2+c_1^2+d_1^2}\sqrt{a_2^2+b_2^2+c_2^2+d_2^2}}\right)$$

As pointed out by @$$0$$XLR:

If you want to change angles, you should be multiplying the $$\dfrac{180}\pi$$ outside the $$\arccos$$[,] otherwise you will be doing $$\arccos\left(\text{"some bizzare value greater than }1\text{"}\right)$$ and get complex values.

And as pointed out by @mildbison:

Note that for any inner product space, you would have $$|A\cdot B|\leq|A||B|$$ which is known as the Cauchy-Schwarz inequality. Importantly, you would see that in your particular example that this inequality is violated. I do not know much about the example you have given, but you should probably not be multiplying by $$\dfrac{180}\pi$$. Essentially, the formula for the inner product is treating the matrix as a regular $$4$$ vector, so you should probably stick to the formula for that inner product.

Note the fact that I should be treating the matrices as a regular $$4$$ vector as mildbison pointed out. Therefore, the formula should be$$\theta=\arccos\left(\dfrac{a_1a_2+b_1b_2+c_1c_2+d_1d_2}{\sqrt{a_1^2+b_1^2+c_1^2+d_1^2}\sqrt{a_2^2+b_2^2+c_2^2+d_2^2}}\right)$$for calculating this in degrees, and in radians,$$\theta=\dfrac{180}\pi\arccos\left(\dfrac{a_1a_2+b_1b_2+c_1c_2+d_1d_2}{\sqrt{a_1^2+b_1^2+c_1^2+d_1^2}\sqrt{a_2^2+b_2^2+c_2^2+d_2^2}}\right)$$And, when we plug in my example, we get$$\theta=\arccos\left(\dfrac{6+6+1+4}{18}\right)$$$$=\arccos\left(\dfrac{17}{18}\right)\approx19.19\unicode{xB0}$$And in radians,$$\theta\approx0.335\text{rad}$$