Probability that two random matrices span the full matrix algebra Given two matrices $A$ and $B$ drawn at random in $\mathbb{R}^{n\times n}$, what is the probability that the matrix algebra generated by $A$ and $B$ is the full matrix algebra $\mathbb{R}^{n\times n}$? 
That is, if $\mathcal{A}$ is the set of matrices defined by


*

*$A,B\in \mathcal{A}$ and

*$XY\in \mathcal{A}$ for all $X,Y\in\mathcal{A}$,


what is the probability that $\mathcal{A}$ contains $n^2$ linearly independent matrices?
I have the intuition that this should occur with probability one, but I can't manage to prove it. If that helps, using Burnside's theorem I think that this is equivalent to the fact that there are no common invariant subspaces for all matrices in $\mathcal{A}$ except for $\{0\}$ and $\mathbb{R}^n$.
 A: *

*An algebra $\mathcal{A}$ satisfies: $XY,X+Y,\lambda X\in \mathcal{A}$.

*The Burnside's theorem gives a NS condition when the underlying field $K$ is algebraically closed. In particular, it is false over $\mathbb{R}$. Thus, if you study real matrices, you must consider theirs COMPLEX common invariant subspaces.
EDIT 1. I wrote too fast (because Lemma 2 is valid only if $A,B\in M_n(K)$ where $K$ is a subfield of $\mathbb{C}$ as $\mathbb{Q}$ or $\mathbb{Q}(i)$). 
We consider a discrete distribution of probability over $\mathbb{Q}$ s.t., for every $q\in\mathbb{Q}$, $P(\{q\})>0$.
Here $A,B\in M_n(\mathbb{Q})$ and $\mathcal{A}$ is the COMPLEX subalgebra of $M_n(\mathbb{C})$ generated by $A,B$.
Lemma 1. Let $U=[u_{ij}]\in M_n$ where the $(u_{ij})$ are commuting indeterminates and $K=\mathbb{Q}((a_{ij}))$. Then $\chi_U$, the characteristic polynomial of $U$, is irreducible over $K$ and, $Galois(U)$,  its Galois group over $K$ is $S_n$.
Proof. Let $P(x)\in\mathbb{Q}[x]$ that has degree $n$ and $S_n$ as Galois group (such a polynomial exists for every $n$). We specialize $U$ into $U_0$ so that $U_0$ is the companion matrix of $P$. Then $Galois(U_0)$ is a subgroup of $Galois(U)$ and, consequently, $Galois(U)=S_n$.
Assume that the $(u_{ij})$ are randomly chosen in $\mathbb{Z}\cap [-\delta,\delta]$; according to the Hilbert's irreducibility theorem, $Prob(Galois(U)\not= S_n)\approx O(1/\sqrt{\delta})$. Thus, if the $(u_{ij})$ are chosen in $\mathbb{Q}$, then $Prob(Galois(U)\not= S_n)=0$.
Lemma 2. If $A,B\in M_n(\mathbb{Q})$, $AB\not= BA$ and $Galois(A)=S_n$, then $A,B$ admit no common invariant proper subspaces over $\mathbb{C}$.
Proof. cf. Theorem 3, in my paper (published in linear and multilinear algebra):  http://arxiv.org/pdf/1206.3630.pdf
Proposition 1. If $A,B$ are randomly chosen in $M_n(\mathbb{Q})$, then $Prob(\mathcal{A}\not= M_n(\mathbb{C}))=0$.
Proof. Randomly choose $A$ ($A$ has a.s. $n$ distinct eigenvalues; then, a.s. $dim(C(A))=n$). Use Lemma 1. (a.s. $Galois(A)=S_n$). Randomly choose $B$. Then, a.s. $B\notin C(A)$. Use Lemma 2. and Burnside's theorem.
Remark. If you use the "RandomMatrix" of maple (for example) for $U$, then the $(u_{ij})$ are random integers that are between $-100$ and $100$; $Prob(Galois(U)\not= S_n)$ is very low (in fact much smaller than the bound specified by Hilbert Theorem) but is not $0$.
EDIT 2. Since the moderator is unhappy about our discussion, I give the following proof.
Proposition 2. Assume that the entries of $A,B\in M_n(\mathbb{C})$ are iid random variables that follow the normal law. Then $Prob(\mathcal{A}\not= M_n(\mathbb{C}))=0$.
Proof. According to the answer-comment below, it suffices to prove that: let $A\in M_n(\mathbb{C})$ be fixed with $n$ distinct eigenvalues. Then the set of $B\in M_n(\mathbb{C})$ that has distinct eigenvalues and an eigenvector in a proper invariant subspace of A has Lebesgue-measure $0$.
We may assume that $A=diag((a_i))$ in the basis $\mathcal{B}=(e_i)$. Then a proper invariant subspace of $A$ is included in $span(\mathcal{B}\setminus e_j)$ for some $j$. Then it suffices to prove that $Z=\{B|B\;\text{has }\; n\; \text{eigenvalues and has an eigenvector }\;u\in span(\mathcal{B}\setminus e_n)\}$ is negligible in $M_n(\mathbb{C})$.
Put $B=\begin{pmatrix}B_{n-1}&c\\l&b\end{pmatrix},u=[v,0]^T$ where $v\in \mathbb{R}^{n-1}\setminus 0$. If $Bu=\lambda u$, then $B_{n-1}v=\lambda v$; thus the polynomials $p(x)=\det(B-xI_n)$ and $q(x)=\det(B_{n-1}-xI_{n-1})$ have a common root, that implies that their resultant $result(p,q)$ is $0$. Note that $result(p,q)$ is a polynomial in the $(b_{ij})$ with coefficients in $\mathbb{Q}$, that $Z\subset \{B|result(p,q)=0\}$ and consequently, that $Z$ is Zariski-closed. It remains to prove that $result(p,q)$ is not identically $0$ over $\mathbb{Q}$. Consider $B_n=J_n+J_n^T$ where $J_n$ is the nilpotent Jordan block of dimension $n$. Then $spectrum(B_n)=\{2\cos(\dfrac{j\pi}{n+1}),j=1,\cdots,n\}$ has no common entries with $spectrum(B_{n-1})$ and $result(p,q)\not=0$ for $B_n$
A: I think I have a proof... I am not sure that it is very rigorous (especialy for the last paragraph), so any comments are welcome.
I will try to show that the set of couple of matrices having a (non-trivial) common invariant subspace has Lebesgue measure 0. Using Burnside's theorem this is equivalent to the fact that the set of couple of matrices $(A,B)$ for which the algebra $\mathcal{A}$ has dimension strictly less than $n^2$ has Lebesgue measure 0.
Let 
$\mathcal{S} = \{(A,B)\in \mathbb{C}^{n\times n} \times  \mathbb{C}^{n\times n} \ | \ \exists U\subsetneq \mathbb{C}^n, U\not = \{0\} : Au\in U \text{ and } Bu\in U \text{ for all } u \in U\}$. 
Given a matrix $A$, let $\mathcal{S}(A) = \{B \in \mathbb{C}^{n\times n} \ | \ (A,B)\in \mathcal{S}\}$. 
For any set $X$, let $\mathbb{I}[X]$ denotes the indicator function of the set $X$.
Finally, for any integer $k$ let $\mathcal{M}_k$ bet the set of $n\times n$ matrices with Frobenius norm less than $k$. We will use the notations  $\mathcal{S}_k = \mathcal{S}\cap \mathcal{M}_k$ and $\mathcal{S}(A)_k = \mathcal{S}(A) \cap \mathcal{M}_k$.
Using Fubini's theorem for the Lebesgue measure (which is positive), we have
for any integer $k$
$$\int_{(A,B)} \mathbb{I}[\mathcal{S}_k]=\int_{(A,B)\in\mathcal{M}_k\times \mathcal{M}_k}\mathbb{I}[\mathcal{S}] = \int_{A\in\mathcal{M}_k}\int_{B\in\mathcal{M}_k}\mathbb{I}[\mathcal{S}(A)_k] .$$
Thus if we show that $ \int_{B\in\mathcal{M}_k}\mathbb{I}[\mathcal{S}(A)_k] = 0$ for any matrix $A\in \mathcal{M}_k$, this will imply that $\int \mathbb{I}[\mathcal{S}_k]=0$. Using the monotone convergence theorem we will have
$$ \int \mathbb{I}[\mathcal{S}] = \int \lim_{k\to \infty} \mathbb{I}[\mathcal{S}_k] = \lim_{k\to\infty} \int \mathbb{I}[\mathcal{S}_k] =\lim_{k\to\infty} 0 = 0$$
hence showing that the set $\mathcal{S}$ has Lebesgue measure 0.
It remains to show that $\mathcal{S}(A)$ has Lebesgue measure 0 for any matrix $A$, which will imply $\int_{B\in\mathcal{M}_k}\mathbb{I}[\mathcal{S}(A)_k] = 0$ for any integer $k$. Let $A$ be a matrix and let $V_1,\cdots,V_p\subsetneq \mathbb{C}^n$ be its non-trivial invariant subspaces. Now let $B\in\mathbb{C}^{n\times n}$. Since the set of non-diagonalizable matrices has measure 0 in $\mathbb{C}^{n\times n}$, we assume that $B$ is diagonalizable. Then, a necessary condition for $B\in\mathcal{S}(A)$ is that there exists an eigenvector of $B$ that lies in one of the $V_i$. Since $\bigcup_i V_i$ has measure $0$ in $\mathbb{C}^{n\times n}$, it follows that $\mathcal{S}(A)$ also has measure 0.
It remains to show that for a generic matrix $A$, $\mathcal{S}(A)$ has Lebesgue measure 0...
A: I think I have a proof that does not rely on Burnside's theorem. Any comments are welcome.
Theorem. For any couple of matrices $(A,B)\in \mathbb{C}^{n\times n}\times \mathbb{C}^{n\times n}$, let $P(A,B) = \{A^iB^j : 0\leq i,j <n\}$. Then the set $S = \{(A,B) : P(A,B) \text{ is not a basis of } \mathbb{C}^{n\times n}\}$ has Lebesgue measure zero in $\mathbb{C}^{n\times n}\times \mathbb{C}^{n\times n}$.
Proof. For any couple of matrices $(A,B)$ let $M(A,B) \in \mathbb{C}^{n^2\times n^2}$ be the matrix whose columns are the vectorizations of $A^iB^j$ for $0\leq i,j<n$. Then $(A,B)\in S$ if and only if $det(M(A,B)) = 0$. Since $det(M(A,B))$ is a polynomial in the coefficents of $A$ and $B$, $S$ is an algebraic subvariety of $(\mathbb{C}^{n\times n})^2$. We now show that the polynomial $det(M(A,B))$ is not $0$. Let $U$ be the upper $n\times n$ shift matrix, we claim that $det(M(U,U^\top))\not = 0$, which is equivalent to $P(U,U^\top)$ being a basis of $\mathbb{C}^{n\times n}$. Let $(E_{ij})_{1\leq i,j \leq n}$ be the canonical basis of $\mathbb{C}^{n\times n}$, one can check that $E_{ij} = U^{n-i}(U^\top)^{n-j}- U^{n-i+1}(U^\top)^{n-j+1}$ for all $1\leq i,j\leq n$ (note that  $U^{n-i+1}(U^\top)^{n-j+1}$ is either in $P(U,U^\top)$ or equal to $0$). In conclusion, $S$ is a proper algebraic subvariety of $(\mathbb{C}^{n\times n})^2$, thus of Lebesgue measure zero.
