For a matrix $A$, one computes the $ij$-$th$ matrix elements in a basis $\{|e_i\rangle\}$ as
$$A_{ij} = \langle e_i|A|e_j\rangle$$
How can one implement this in Mathematica? As an example, consider a matrix A = ( { {a11, a12}, {a21, a22} } );
, how can one compute its matrix elements with respect to the basis $\{|e_1\rangle, |e_2\rangle\}$ where $|e_{1(2)}\rangle$ are the eigen vectors of matrix B= ( { {b11, b12}, {b21, b22} } );
Note that $|e \rangle$ is the Dirac "ket-vector" notation for the column vector, and $\langle e|$ is its Hermitian conjugate (a row vector) called as "bra-vector".
Failed attempt: I tried computing $A_{11}$ as follows (which doesn't seem to work):
A11 = ConjugateTranspose[
Eigenvectors[B][[1]]].A.Eigenvectors[B][[1]]
displays following:
ConjugateTranspose: The first two levels of {-((-b11+b22+Sqrt[b11^2+4 b12 b21-2 b11 b22+b22^2])/(2 b21)),1} cannot be transposed.
Conjugate[v].A.v
should suffice. $\endgroup$row.A.column
? $\endgroup$v = Eigenvectors[B][[1]];
then runConjugate[v].A.v
. Is the result not what you expect? If not, then please explain why not by editing the question like @JM had mentioned. $\endgroup$