0

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.
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Mike
  • 471
  • 2
  • 6

1 Answers1

3

In MMA the rule for the dot product is: the last index of the left hand side is contracted with the first index of the right hand side. Therefore, no need for row and column vectors.

Let's define some matrix a and a matrix b with orthogonal eigenvectors:

SeedRandom[1];
a = RandomReal[{-1, 1}, {3, 3}];
b = RandomReal[{-1, 1}, {3, 3}]; b = b + Transpose[b];

Now to get the basis of eigenvectors of b (note the eigenvectors are in rows ) and show that they are orthonormal:

ev = Eigenvectors[b];
ev.Transpose[ev]

with this we can easily transform matrix a:

anew = Transpose[ev].a.ev

To show that this is still the same matrix in an other basis, we may compare the eigenvalues:

Eigenvalues /@ {a, anew}

({{1.17276, -1.15262, -0.110618}, {1.17276, -1.15262, -0.110618}}{{1.17276, -1.15262, -0.110618}, {1.17276, -1.15262, -0.110618}})

Daniel Huber
  • 51,463
  • 1
  • 23
  • 57