Why does Abs return negative values?

Bug introduced in 5.2 or earlier and fixed in 12.2

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?

• Look what Abs[r] returns. Please make a report to support@wolfram.com Oct 17, 2020 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. Oct 17, 2020 at 21:53
• @Carl the Root expression was the output of Eigenvalues[mat]. Since there's no problem with the eigenvalues function I left that part out.
– Gert
Oct 18, 2020 at 7:13
• Workaround N[RealAbs[r]] (*15.5817*) Oct 18, 2020 at 8:55
• This has been internally reported as a bug, and bug tagging would be appropriate. Oct 28, 2020 at 19:44