closed form of modulus function

From: Alex Hunsley (lard_at_tardis.ed.ac.molar.uk)
Date: 02/10/05


Date: Thu, 10 Feb 2005 11:39:27 GMT

The modulus function, which gives the 'magnitude' of a number (in effect
removes a negative sign if one exists), can be expressed in closed form
as either sqrt(x^2) or (sqrt(x))^2. Is either of these forms preferable?
In practical terms, I think the former is the best, as it doesn't
involve the possibility of imaginary numbers coming up during the
calculation, which could cause an algorithm/computer program to object....

alex