If $v^TAv = v^TBv$ for all constant vectors $v$ and $A,B$ are matrices of size $n$ by $n$, is it true that $A=B$?
I have thought about using basis vectors but cannot get system of equations uniquely. Is there a trick here?
It is not true. Take $A$ to be the zero matrix, and $B$ to be any nonzero skew-symmetric matrix. You can prove that both sides are always zero, but $A$ and $B$ are not equal.
If you assume that both $A$ and $B$ are symmetric real matrices, then they are equal. You can see that $v^TAv = v^TBv$ is equivalent to $v^T(A-B)v=0$. We know that $A-B$ is also a symmetric matrix. When the last equality holds for all vectors $v$, $A-B$ must be a zero matrix. This is due to the spectral theorem, as the existence of eigenvectors of $A-B$ is justified by the spectral theorem. See the details in another post. Now get any eigenvector $v$ of $A-B$ to see that $v^T(A-B)v=\lambda\left\lVert v \right\rVert^2$, where $\lambda$ is the eigenvalue of $A-B$ corresponding to the eigenvector $v$. Since eigenvectors are by definition nonzero, it must be the eigenvalue that is zero. So all eigenvalues of $A-B$ are zero. $A-B$ is similar to the zero matrix, so that $A-B$ itself is also the zero matrix.
The question is the same as:
Is it true $A=0$, if $v^TAv=0$, for all vectors $v$?
If $A$ is anti-symmetric, it is not.
If you assume that the matrices are symmetric then it is true. Otherwise not. In fact, $M=A-B$ may be any anti-symmetric matrix, i.e. $M^T=-M$.
If $M$ is symmetric on the other hand it is diagonaliable with real eigenvalues and in an orthonormal basis. Picking an eigenvector $v$ for eigenvalue $\lambda$ you see that $0=v^T M v = \lambda v^T v$ so $\lambda=0$. Thus, all eigenvalues are zero and for a diagonalizable matrix this implies that the matrix is the zero matrix.