1
$\begingroup$

Hello I would like to build a function for the hermitic conjugation of f[i]. When applied to f[i], it should result in f\[Dagger][i], and when applied to f\[Dagger][i], it should result in f[i], where i is some integer. How could I do that please ?

Thank you.

$\endgroup$
  • $\begingroup$ Do you mean conjugate transpose, Hermitian conjugate, Hermitian adjoint? What would the function be operating on? Have you tried anything at all? Give us some more detail. $\endgroup$ – MarcoB Apr 22 '16 at 15:29
  • $\begingroup$ To answer MarcoB: All I need is the symbolic manipulation mentioned in my post. f[i] is an abstract object (second quantization operator). All I need is to toggle the \[Dagger] part of the FullForm. In case you wonder why, I am trying to use the package DiracQ for quantum calculations, but it lacks this simple formal operation. $\endgroup$ – cipocip Apr 22 '16 at 16:07
1
$\begingroup$

I'm not familiar with the package you using, but if by "toggling the \[Dagger]" you mean converting the expression f[i] to (f^\[Dagger])[i], which is equivalent to SuperDagger[f][i], then you need to define something like this:

Dagger[f_] := Operate[SuperDagger, f]
SuperDagger[SuperDagger[x_]] := x
$\endgroup$
0
$\begingroup$

Never mind, I figured it out, converting the argument to String and using StringReplace and RegularExpression inside a Module to toggle the dagger symbol.

Example code:

    ToManipString[a_] := ToString[FullForm[ToBoxes[a]]];
BackToExpres[a_] := 
  ReleaseHold[MakeExpression[ToExpression[a], StandardForm]];

Dag[a_] := 
 Module[{}, 
  newstr = BackToExpres[
    StringReplace[
     ToManipString[a], {"\"\\[Sigma]\"" -> "\"\[Sigma]\[Dagger]\"", 
      "\"b\"" -> "\"b\\[Dagger]\""}]];
  If[newstr == 
    a, {newstr = 
     BackToExpres[
      StringReplace[
       ToManipString[a], {"\"\\[Sigma]\\[Dagger]\"" -> "\"\[Sigma]\"",
         "\"b\\[Dagger]\"" -> "\"b\""}]]}, newstr];

This version works for "b" and "sigma" operators multiplied by symbolic stuff, like sqrt(2).

$\endgroup$
  • 1
    $\begingroup$ You might consider including code in your answer to be useful to others as well. $\endgroup$ – J. M. will be back soon Apr 23 '16 at 11:46
  • $\begingroup$ I suggest that you post some background on what you want to achieve... I am pretty confident that there is a better way to do what you want $\endgroup$ – sebhofer Aug 21 '16 at 17:14

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.