# Why does Abs return negative values?

According to the documentation Abs[z] gives the absolute value of the real or complex number z and is also known as the modulus. As far as I'm aware for any definition of the absolute value, norm or modulus the range of the function is supposed to be the positive real numbers but it seems that Mathematica's Abs function also returns negative numbers:

r = Root[ -1 - 9 # -15 #^2 + #^3&, 3, 1 ];

N[r]
(* 15.5817 *)

r > 0
(* True *)

N[Abs[r]]
(* -15.5817 *)

Abs[N[r]]
(* 15.5817 *)


I know that Simplify, Reduce and others show similar behaviour when working with powers of complex numbers, whose numerical value may change due multivaluedness of complex powers, but here I did not ask for a symbolic simplification and even if I did, there should be no change in numerical value since the Abs function is inherently single valued.

So I wondered whether this is a design choice or an actual bug and if it is a design choice, then how am I supposed to e.g. sort eigenvalues on magnitude and return a list positive magnitudes?

EDIT I have contacted the customer service but they get different results when running the same code. The full code I used is the following:

r = Abs @ Last @ SortBy[ Eigenvalues[{{0,1,0,0},{1,10,6,4},{0,6,4,3},{0,4,3,2}}], Abs @* N ];

N[r] < 0
(* True *)

r//InputForm
(* -Root[-1 - 9*#1 - 15*#1^2 + #1^3 & , 3, 1] *)

N[Abs[r]]
(* -15.5817 *)



The code that the person from the customer service ran is exactly the same but the output seems to be correct when he runs it.

The results I get have also been confirmed by someone using Mathematica 11.2.

Are there people who can confirm this behaviour?

• This is bug. Interesting is that N[Abs[ToRadicals[r]]] is correct. – Vaclav Kotesovec Oct 17 '20 at 16:53
• "how am I supposed to e.g. sort eigenvalues on magnitude". Use SortBy[list, Abs[N[#]] &] or SortBy[list, Abs[N[#, prec]] &] for arbitrary precision. – Bob Hanlon Oct 17 '20 at 17:17
• Look what Abs[r] returns. Please make a report to support@wolfram.com – Daniel Huber Oct 17 '20 at 17:18
• Why are you using 3 arguments for the Root object? The third argument shouldn't be used, it should be set by Mathematica when the 2 argument Root object is evaluated. – Carl Woll Oct 17 '20 at 21:53
• Workaround N[RealAbs[r]] (*15.5817*) – Ulrich Neumann Oct 18 '20 at 8:55