Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

1.How to make following equation have sense?

{+,-}::Symbol.
ex:=f_{-}+f_{+};

2.How to make all commutators

[a b... , c d...] or \commutaor{a b... }{ c d...]

become

a b... c d... - c d... a b...
in General questions by (1.5k points)

1 Answer

+2 votes
 
Best answer

Use fm and fp and define

fm{#}::LaTeXForm("{f_{-}}").
fp{#}::LaTeXForm("{f_{+}}").

To expand, use

substitute(_, $\commutator{A??}{B??} -> A?? B?? - B?? A??$);

Does that help?

by (76.7k points)
selected by

Yes, it does. I'm so sorry that I have not give more details about problems. In fact, I want make following equation have sense:

ex:=f_{-\mu\nu}+f_{+\mu\nu}+f_{+}^{\mu\nu};

So write that with the above as

ex:= fm_{\mu\nu} + fp_{\mu\nu} + fp^{\mu\nu};

(and declare your indices with position=free to allow you to have expressions where the index positions do not match up. So in full,

fm{#}::LaTeXForm("{f_{-}}").
fp{#}::LaTeXForm("{f_{+}}").
{\mu,\nu}::Indices(position=free);
ex:= fm_{\mu\nu} + fp_{\mu\nu} + fp^{\mu\nu};

to give

$$f_{-\mu\nu} + f_{+\mu\nu} + {f_{+}}^{\mu\nu}$$

Thanks a lot. It is what I want.

...