1
$\begingroup$

I am working on a code for a coupled quantum harmonic oscillator and found myself in a hiccup when trying to evaluate the inner product of linear combinations of bras and kets. I have initially defined the CenterDot between a bra and a ket as follows:

CenterDot[
  Bra[n_Integer, m_Integer, o_Integer, p_Integer, q_Integer, 
   r_Integer], 
  Ket[n1_Integer, m1_Integer, o1_Integer, p1_Integer, q1_Integer, 
   r1_Integer]] := 
 KroneckerDelta[n - n1] KroneckerDelta[m - m1] KroneckerDelta[
   o - o1] KroneckerDelta[p - p1] KroneckerDelta[
   q - q1] KroneckerDelta[r - r1]

Although this works for most of my code, I am having trouble extending this definition to make the CenterDot distributive. I was able to define a distributive function of one variable in the same code by doing as follows (thanks to another thread) and it seemed to work:

Fac[x__Plus] := Distribute[Unevaluated[Fac[x]]];

I tried using something similar for CenterDot but I am unsure as how to specify that the data type is composed of bras and kets or if this even works theoretically.

Also Expand and Distribute work well at simplifying the linear combinations of bras and kets but seem to stop when they see parenthesis on either side of the CenterDot. For example:

Expand[CenterDot[2*Bra[1, 0, 0, 0, 0, 0] + 1/2*Bra[0, 1, 0, 0, 0, 0], 
  Ket[1, 0, 0, 0, 0, 0]]]

gives

(1/2 Bra[0, 1, 0, 0, 0, 0] + 2 Bra[1, 0, 0, 0, 0, 0])\[CenterDot]Ket[
 1, 0, 0, 0, 0, 0]

If anyone has ideas on how to make this CenterDot distributive on any linear combinations of bras and kets, please share.

Cheers

$\endgroup$
1
$\begingroup$

Adding

CenterDot[left_, a_ + b_] := CenterDot[left, a] + CenterDot[left, b];
CenterDot[a_ + b_, right_] := CenterDot[a, right] + CenterDot[b, right];

to your definitions should implement distributivity for your scalar product. To get linearity, you could then use

CenterDot[a_ b_Bra, right_] := a CenterDot[b, right];
CenterDot[left_, a_ b_Ket] := a CenterDot[left, b];

You may need to adjust further these definitions according to your specific use-case, but the basic idea usually works...

$\endgroup$
1
  • $\begingroup$ This worked perfectly, thank you :) $\endgroup$
    – balavay
    Apr 5 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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