[Maxima] abs vs. cabs WAS: Help with Plancherel's theorem

Stavros Macrakis macrakis at alum.mit.edu
Thu May 26 10:03:06 CDT 2011

I haven't read the thread in detail, but here's the quick version of the
difference between abs and cabs (at least in an ideal world), which may be
relevant to the problem:

* abs is a mathematical function which has simplification rules.  It assumes
by default that it is operating over the reals, so that for example
abs(sqrt(x)) => sqrt(x) -- because sqrt is treated as a real-to-real
function with domain and range 0..inf.  But if there is an explicitly
complex quantity (%i or a variable declared complex), that assumption is
invalidated, so abs(z^2) => abs(z)^2, where declare(z,complex).

* cabs is a routine which transforms an expression into another expression,
and does not have simplification rules.  cabs does not appear in
mathematical expressions, but is used in calculations on mathematical
expressions.  cabs assumes that any undeclared variables it encounters are
real, but does not assume that functions are only defined where they are
real-to-real.  Thus cabs(sqrt(x)) => sqrt(abs(x)).

Formerly, cabs tried to reduce all complex calculations to real
calculations, using explicit realpart(z) and imagpart(z) when necessary, but
nowadays it allows itself to use abs(z) as well.

Unfortunately, this principle has not been extended very far.  Though abs(z)
is certainly more compact than sqrt(R(z)^2+I(z)^2), using the abs form in
some cases and the sqrt form in others means that, for example
cabs(z*conjugate(z)) => sqrt(R(z)^2+I(z)^2)*abs(z) instead of either
abs(z)^2 or R(z)^2+I(z)^2, either of which would be better than the bastard

The difference between a mathematical (simplifying) function and a routine
is critical in Maxima.  In most cases, it is represented by the noun-form
(e.g. 'diff(x,y)) and the verb-form (diff(x,y)).  In the case of abs, by far
the more common usage is as a mathematical function, so requiring 'abs seems
too clumsy and unintuitive for most use cases.  LIke anything else, this
decision (from 1970 or so) can always be revisited, but I don't see a better

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20110526/1a30824f/attachment.html>

More information about the Maxima mailing list