TITLE: What is wrong with this proof that symmetric matrices commute?
QUESTION [22 upvotes]: Symmetric matrices represent real self-adjoint maps, i.e. linear maps that have the following property: $$\langle\vec{v},f(\vec{w})\rangle=\langle f(\vec{v}),\vec{w}\rangle$$ where $\langle,\rangle$ donates the scalar (dot) product.
Using this logic:
$$\langle\vec{v},AB\vec{v}\rangle=\langle A\vec{v},B\vec{v}\rangle=\langle BA\vec{v},\vec{v}\rangle$$
Where $A$ and $B$ are symmetric matrices. Using the fact that the real scalar dot product is commutative:
$$\langle BA\vec{v},\vec{v}\rangle=\langle\vec{v},BA\vec{v}\rangle$$ 
We therefore have the result:
$$\langle\vec{v},AB\vec{v}\rangle=\langle\vec{v},BA\vec{v}\rangle$$ 
This holds true for any real vector $\vec{v}$ so therefore $AB=BA$.
However, symmetric matrices do not always commute so something is wrong with this proof.

REPLY [9 votes]: The fallacy in your proof is, as others have observed, in the last step, in which you go from the (correct) equation

$\langle \vec{v}, AB\vec{v} \rangle = \langle \vec{v}, BA\vec{v} \rangle$

to the incorrect conclusion

This holds true for any real vector $\vec{v}$ so therefore $AB = BA$

To see why this is wrong, let's rephrase the underlying assumption here as a question:

Suppose $M, N$ are two matrices such that for all vectors $\vec{v}$, $\langle \vec{v}, M\vec{v} \rangle = \langle \vec{v}, N\vec{v} \rangle$.  What can you conclude?

You would like to conclude that $M = N$.  Is that true?
Because the inner product is bilinear, the assumption that $\langle \vec{v}, M\vec{v} \rangle = \langle \vec{v}, N\vec{v} \rangle$ is equivalent to $\langle \vec{v}, (M-N)\vec{v} \rangle = 0$.  If we introduce a new matrix $K = M-N$, then our question is equivalent to the following:

Suppose $K$ is a matrix such that for all vectors $\vec{v}$,  $\langle \vec{v}, K\vec{v} \rangle = 0$.  What can you conclude about $K$?

Again, you would like to conclude that $K = 0$.  Is that necessarily true?
Stated in this form it is perhaps easier to see where you have made your mistake.  It is true that $\langle \vec{v}, \vec{v} \rangle = 0 \Longrightarrow \vec{v} = 0$
 (this is one of the properties of any inner product), and the property you wish to assert looks sort of like this, if you don't look too closely.  But it is not true in general that if $\langle \vec{v}, K\vec{v} \rangle = 0$ for all $\vec{v}$, then $K = 0$.  Indeed, $\langle \vec{v}, K\vec{v} \rangle = 0$ holds for any antisymmetric matrix $K$.  In the example of the original question $K = AB - BA$, the commutator of the two given symmetric matrices, which is always antisymmetric.