I have: $$p=iab$$ $p,a,b$ are operators. So in mathematica I am writing this as:


Conjugate of above is $$-iba$$ In mathematica I tried ConjugateTranspose, but not working on p to find it's conjugate transpose.

  • 2
    $\begingroup$ NonCommutativeMultiply (i.e., **) has essentially no built-in meaning. You have to either give it that meaning or develop replacement rules for transforming expressions involving **. Alternatively, you might try the NCAlgebra package. $\endgroup$
    – march
    Sep 7, 2021 at 22:23
  • $\begingroup$ If I define conj[Ia_ ** b_] := -Ib ** a, This rule isn't working. $\endgroup$
    – Jasmine
    Sep 8, 2021 at 3:49
  • $\begingroup$ Jasmine, you’ll need to individually define all of your replacement rules. What you suggest is close, but still not sufficient. Check the documentation of NonCommutativeMultiply for some hints on how to do this. Also I recommend you search the function name on this SE for related questions (they do exist). $\endgroup$ Sep 8, 2021 at 14:57
  • $\begingroup$ @Jasmine. That rule works just fine. I suspect you didn't leave a space between the I and a on the left-hand side and the I and the b on the right-hand side. An alternative thing to do (which is what I do when doing these kinds of calculations), is to define replacement rules instead. I.e., make a list of things like conj[I a_**b_] :> -I b**a and then using ReplaceAll (/.) to transform the expressions. $\endgroup$
    – march
    Sep 8, 2021 at 21:58
  • 1
    $\begingroup$ Here are some ideas for how to go about doing this. You can ignore the first part about the basis elements if you want (unless you're actually doing geometric algebra!), but the set of rules later for implementing linearity and such might be useful. $\endgroup$
    – march
    Sep 8, 2021 at 22:17

1 Answer 1


As @march pointed out, NCAlgebra is able to handle this issue out of the box. Indeed

aj[I a ** b]

evaluates to

I aj[b] ** aj[a]

as you want.


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.