Simultaneous diagonalisation of matrices by diagonalising a random linear combination of these matrices According to a reply on Mathematica SE numerically finding a matrix that simultaneously diagonalizes a set of pairwise commuting diagonalizable finite complex matrices $\{M_1,\ldots,M_n\}$ can be done by diagonalizing a 'random' linear combination $\sum_{i=1}^nc_iM_i$ of these matrices. Of course not all linear combinations work (take, e.g., all $c_i = 0$) but 'most' of them should work.
I have asked for a reference to a more exact statement (with a proof) but all the references given either proved similar statements for very special matrices or just assumed this was a trivial statement.
Does anyone know of a theorem of the form: a matrix that diagonalizes a linear combination of simultaneous diagonalizable matrices also diagonalizes the individual matrices?
(I've chosen to make this statement somewhat vague since I don't know what possible extra conditions or generalizations there might be)
 A: Since they are all simultaneously diagonalizable, there exists a basis in which they are all diagonal. We fix this as our "standard" basis. Suppose in this basis $M_i$ has $d_{j; i}$ on as the $j$th diagonal entry. Then a linear combination $\sum c_i M_i$ is also diagonal and has  $\sum c_i d_{j;i}$ as the $j$th diagonal entry.
Now what we  want will follow from the two lemmas:
Lemma 1: A diagonal matrix stays diagonal in precisely those bases for which the change of basis matrix is block diagonal, with blocks corresponding to the same values on the diagonal.
Lemma 2: For "generic" $(c_1, \ldots, c_n)$ and any fixed pair $j_1, j_2$ we have $\sum c_i d_{j_1;i}=\sum c_i d_{j_2;i}$ if and only if for all individual $i$ we have $d_{j_1;i}=d_{j_2;i}$.
Indeed, the lemmas (which we prove later, making the notion of "generic" clear in the process) imply that for a generic $(c_1, \ldots, c_n)$ the only bases in which the sum is diagonal are those differing from the standard one by block-diagonal change-of-basis matrices which also keep all individual $M_i$ diagonal as well. This is exactly saying that diagonalizing the sum will diagonalize all of the $M_i$s.
Proof of lemma 1: A matrix is diagonal precisely in those bases that consist of eigenvalues. Any two such bases differ by changing bases for each eigenspace separately, meaning the change of bases matrix is block diagonal, with blocks corresponding to distinct eigenvalues. QED.
Proof of lemma 2: One way implication is clear: if individual entries are equal then the linear combinations are equal, for all $\vec{c}=(c_1, \ldots, c_n)$.
Suppose now for a given pair $j_1$ $j_2$ there exists $k$ such that $d_{j_1,k}\neq d_{j_2,k}$. Then the equation $\sum c_i d_{j_1;i}=\sum c_i d_{j_2;i}$ is of the form $c_k(d_{j_1;k}-d_{j_2;k})=\sum_{i\neq k} c_i(d_{j_1;i}-d_{j_2;i})$ and is a non-trivial linear equation. This means it is satisfied by a codimension one set of $\vec{c}$s.
Thus for all $\vec{c}$ outside of a finite collection of hyperplanes an equation $\sum c_i d_{j_1;i}=\sum c_i d_{j_2;i}$  implies $d_{j_1;i}=d_{j_2;i}$ for all $i$. Those are our "generic" $\vec{c}$s, and for them the lemma holds. QED.
