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

Hi, Sorry for the simplistic question, but what is the proper way to generate a Cadabra expression with absolute value?

I tried

ex := \sqrt{g} -> \abs(Z) \sqrt{h}

but I get an error, also using sympy.Abs doesn't seem to generate an output with |Z|

in General questions by (430 points)
edited by

1 Answer

+1 vote

No algorithms in cadabra are currently aware of absolute values, so you can give it any name you want. But because \abs will not get converted to abs by the sympy bridge , it is probably best to simply use abs. In order to make it print as you want, use something like

abs{A??}::LaTeXForm("\left|", A??, "\right|");

The above will make the following work and print correctly:

ex := abs( -3 );
simplify(ex);
by (86.5k points)

Thank you very much! quick correction to your last code segment - the colon is spaced from the equal sign

ex := abs(-3);
...