0
$\begingroup$

I'm gonna produce a matrix in which the matrix elements obey the following rules

$\left<n \right|M \left| m \right> = m^2 \delta_{m,n},$

$\left<m \pm 2 \right|M \left| m \right> = (1-m) \delta_{m,m \pm 2}.$

How can I produce such a matrix in Mathematica?

Since I have no idea about it, I could not make any code.

$\endgroup$
4
  • $\begingroup$ You have two different definitions. Do you mean that the matrix you seek is the sum of the ones you've defined? $\endgroup$
    – John Doty
    Commented May 13, 2019 at 11:55
  • $\begingroup$ Did you mean $\langle n\lvert M \rvert m \rangle = m^2 \delta_{m,n}+(1-m)(\delta_{m,n+2}+\delta_{m,n-2})$? As @JohnDoty says, your definitions as they are do not make sense. Also, please add the required ranges of the indices $n$ and $m$. $\endgroup$
    – Roman
    Commented May 13, 2019 at 12:20
  • $\begingroup$ Try KroneckerDelta: for instance the first matrix could be: Range[4]^2 Array[KroneckerDelta, {4, 6}] $\endgroup$
    – bill s
    Commented May 13, 2019 at 12:21
  • $\begingroup$ Your second definition still doesn't make sense. There is no $n$ on the left-hand side; so why is there one on the right? $\endgroup$
    – Roman
    Commented May 13, 2019 at 15:49

1 Answer 1

2
$\begingroup$

Assuming that you meant

$$ \langle n\lvert M \rvert m \rangle = m^2 \delta_{m,n}+(1-m)(\delta_{m,n+2}+\delta_{m,n-2}) $$

and ranges of $n,m\in\{1,2,3,\ldots,a\}$, you can define this matrix with

M[a_] := Table[m^2 KroneckerDelta[n, m] +
           (1 - m) (KroneckerDelta[m, n + 2] + KroneckerDelta[m, n - 2]),
           {n, a}, {m, a}]

or, more efficiently,

M[a_] := SparseArray[{{m_,m_} -> m^2, {n_,m_} /; Abs[n-m]==2 -> 1-m}, {a,a}]

or even

M[a_] := SparseArray[{Band[{1, 1}] -> Range[a]^2, 
                      Band[{3, 1}] -> -Range[0, a - 3], 
                      Band[{1, 3}] -> -Range[2, a - 1]}]

Test:

M[6] // MatrixForm
(*    {{ 1,  0, -2,  0,  0,  0},
       { 0,  4,  0, -3,  0,  0},
       { 0,  0,  9,  0, -4,  0},
       { 0, -1,  0, 16,  0, -5},
       { 0,  0, -2,  0, 25,  0},
       { 0,  0,  0, -3,  0, 36}}    *)

Considering that this matrix isn't Hermitian and that you are using Dirac-notation matrix elements, I suspect that there is something wrong in these definitions.

$\endgroup$
2
  • $\begingroup$ It's perfectly possible to have non-Hermitian operators in quantum mechanics. They just don't represent observables, but combinations of non-Hermitian operators can be Hermitian. Ladder operators are a common example: en.wikipedia.org/wiki/Ladder_operator $\endgroup$ Commented May 13, 2019 at 15:55
  • $\begingroup$ Yes @SjoerdSmit it's possible but feels a bit unlikely here, given the diagonal. Just my suspicion. $\endgroup$
    – Roman
    Commented May 13, 2019 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.