0
$\begingroup$

I am trying to manipulate a Hamiltonian with non-commutative operators, $a_j,a_j^\dagger$. After some algebra using NCAlgebra package in Mathematica, I have an expression like, $$H = C_1 (b**a) + C_2 (a**a^\dagger) + C_3 (d^\dagger d) + \cdots $$ How do I extract/collect coefficients like $C_1,C_2$? I have tried NCCollect[H, b**a], but it does not give me the desired answer $C_1$? I am new to this and appreciate any help. Thank you.

$\endgroup$
3
  • 2
    $\begingroup$ Welcome to the Mathematica Stack Exchange. This question lacks a minimal working example. Please paste (enough) Mma code that replicates your problem. $\endgroup$ Commented Oct 18, 2021 at 20:33
  • $\begingroup$ Maybe NCCoefficientList[expr, {a, b}]? $\endgroup$ Commented Oct 19, 2021 at 17:16
  • $\begingroup$ Thank you @march and @Syed. It turns out, there was a simple solution. The commandCoefficient[expr, SuperStar[b1] ** b2] did the job. $\endgroup$ Commented Oct 19, 2021 at 19:07

1 Answer 1

1
$\begingroup$

You can do this with NCCoefficientList as in:

H = C1 b ** a + C2 a ** aj[a] + C3 d ** aj[d] NCCoefficientList[H, {a, aj[a], b, d, aj[d]}] 

which returns

{C1, C2, C3}

Note that you have to add also aj[a] and aj[d] to the list of variables.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.