Trace of a Product Property Let $B,C,D \in \mathbb{R}^{n\times n}$. 
If $\forall D \in \mathbb{R}^{n\times n}$; tr($BD$) = tr($CD$), does it hold that $B=C$?
I was attempting to prove it by writing the double sums of the definition of trace, but can't reach a suitable change of indexes. 
Is there a shorter alternative of proving this by building some $D_i$ matrices and iteratively doing $BD_i$ and $CD_i$?
 A: Here is a nice way of rephrasing your question. Indeed, consider two matrices $B$ and $C$ of the same dimension. Then if for all $D$ of the same dimension, we have $\operatorname{tr}BD =\operatorname{tr} CD$, then by linearity of the trace, we have $\operatorname{tr}((B-C)D) = 0$ for all $D$. Write $(B-C) = M$, then $\operatorname{tr}MD = 0$ for all $D$.
Therefore, the question of whether $B=C$ or not, boils down to whether $M=0$ or not. Indeed, the answer to the question is that $M=0$ if the above happens.
To see this, suppose for contradiction that $M_{ij} \neq 0$ for some $1 \leq i,j \leq n$. Then, let $D$ be the matrix such that $D_{ji} = 1$ and zero everywhere else. Then, calculate $MD$. We have : $(MD)_{kl} = \sum_{m} M_{km}D_{ml}$ by matrix multiplication. This is zero whenever $l \neq i$, and if $l = i$ then $(MD)_{ki} = M_{kj}$ for all $k$, by the fact that $m=i$ is the only non-zero term in the summation in that case.
But then, the trace of $MD$ is exactly $MD_{ii}$ which is the only nonzero entry along the diagonal, and this is equal to $M_{ij}$, which is non-zero.
So, we have found a non-zero matrix $D$ such that the trace of $MD$ is non-zero. It follows that $M = 0$ if there is no such non-zero $D$. 
A: It turns out that the operation
$$ \langle A, B \rangle := \operatorname{tr}(A B^T) $$
forms an inner product on $M_{n\times n}(\mathbb{R})$.  In fact, if you calculate this trace, it is equal to $\sum_{i,j=1}^n A_{ij} B_{ij}$, so this inner product space is trivially isometric to $\mathbb{R}^{n^2}$ with the standard Euclidean inner product.
Therefore, the original question reduces to: if $\langle B, D^T \rangle = \langle C, D^T \rangle$ for all $D$, does it follow that $B = C$?  Since each matrix is the transpose of another matrix, this easily reduces to be equivalent to the question: if $\langle B, E \rangle = \langle C, E \rangle$ for all $E$, does it follow that $B = C$?  The answer is affirmative: it is a well-known result about inner product spaces.
(The other current answers essentially reiterate the proof of this statement that substitutes vectors in an orthonomal basis in place of $E$.  Another common proof is to substitute $E := B - C$, and observe that then we get $\langle B - C, E \rangle = 0 = \langle B - C, B - C \rangle$, so $B - C = 0$.)
A: Since $\text{tr}(AB) = \text{tr}(BA)$, the following statement is equivalent.

If $\text{tr}(DB) = \text{tr}(DC)$ for every $D \in M_n(\mathbb{R})$, then $B=C$.

Let $E_{ij}$ denote the $n$-by-$n$ matrix whose $(i,j)$-entry is one, and zero otherwise.
If $B \in M_n(\mathbb{R})$ and $b_i$ denotes the $i^\text{th}$-row of $B$, then the only nonzero row of the product $E_{ji}B$ is the $j^\text{th}$-row, which is $b_i$. Thus, the $(j,j)$ entry of $E_{ji}B$ is $b_{ij}$ (the remaining diagonal entries are zero). 
Thus,
$$
b_{ij} = \text{tr}(E_{ji}B) = \text{tr}(E_{ji}C) = c_{ij},~\forall 1\le i,j \le n,
$$
i.e., $B=C$.  
