# abs(pi*i) Bug

39 views

### Clemens Heuberger

Feb 7, 2011, 7:05:01 AM2/7/11
to sage-support
I encountered the following bug:

sage: abs(pi*I)
I*pi

The correct answer would have been pi.

Several other examples show a different behaviour, e.g.

sage: abs(log(2)*I)
abs(I*log(2))

would have been better).

I do not know whether this is related to
http://trac.sagemath.org/sage_trac/ticket/7557

System information: I am using
ftp://ftp.sun.ac.za/pub/mirrors/www.sagemath.org/linux/64bit/sage-4.6.1-linux-64bit-ubuntu_8.04.4_lts-x86_64-Linux.tar.gz
on debian lenny.

regards,

Clemens Heuberger

### Laurent

Feb 7, 2011, 7:27:30 AM2/7/11
Le 07/02/2011 13:05, Clemens Heuberger a �crit :

> I encountered the following bug:
>
> sage: abs(pi*I)
> I*pi

I do not know how we define absolute value in Sage. Even in math in
general, I'm not sure of what means the absolute value of a complex
number. Depends on the data of a convex cone ?

I suppose that some Sage gurus will explain why abs(pi*I)=pi*I.

However as far as my knowledge in math is concerned, the "good"
generalization of abs to the complex plane is the norm.
sage: (pi*I).norm()

pi^2

Hope it helps ...

Have a good afternoon
Laurent

### Mike Hansen

Feb 7, 2011, 7:48:51 AM2/7/11
On Mon, Feb 7, 2011 at 1:27 PM, Laurent <moky...@gmail.com> wrote:

> Le 07/02/2011 13:05, Clemens Heuberger a écrit :
>>
>> I encountered the following bug:
>>
>> sage: abs(pi*I)
>> I*pi
>
> I do not know how we define absolute value in Sage. Even in math in general,
> I'm not sure of what means the absolute value of a complex number. Depends
> on the data of a convex cone ?

Sage's uses the following:

sage: abs(3 + 4*I)
5

> I suppose that some Sage gurus will explain why abs(pi*I)=pi*I.

I believe the underlying cause is due to #10064, #10583, #7160, and
#6132 all of which are the same issue.

--Mike

### Robert Dodier

Feb 8, 2011, 12:04:13 AM2/8/11
to sage-support
On Feb 7, 5:05 am, Clemens Heuberger <clemens.heuber...@gmail.com>
wrote:

> I encountered the following bug:
>
> sage: abs(pi*I)
> I*pi
>
> The correct answer would have been pi.
>
> Several other examples show a different behaviour, e.g.
>
> sage: abs(log(2)*I)
> abs(I*log(2))
>
> would have been better).
>
> I do not know whether this is related to
>    http://trac.sagemath.org/sage_trac/ticket/7557

For the record, various bugs fixes and improvements have
been made in Maxima's abs function recently.
It might be worth the trouble to review ticket 7557
of Maxima (5.23).

HTH

Robert Dodier

### Loïc

Feb 8, 2011, 9:52:39 AM2/8/11
to sage-support
I've just compiled on my laptotp the last maxima version,

(%i13) abs(%pi*%i);
(%o13) %pi

Seems it works

On which Maxima version is based Sage 4.6.1?

### Loïc

Feb 8, 2011, 10:00:12 AM2/8/11
to sage-support
Sage implements...

maxima.version()
5.22.1

### Daniel Krenn

Feb 26, 2012, 7:31:46 AM2/26/12
Am Montag, 7. Februar 2011 13:48:51 UTC+1 schrieb Mike Hansen:
On Mon, Feb 7, 2011 at 1:27 PM, Laurent wrote:
> Le 07/02/2011 13:05, Clemens Heuberger a écrit :
>> sage: abs(pi*I)
>> I*pi
> I believe the underlying cause is due to #10064, #10583, #7160, and #6132 all of which are the same issue.

I think, there should be a doctest for ``abs(pi*I)`` somewhere, so that we do not forget about it. Should this be in one of the tickets mentioned above, e.g. # 7160, or a new ticket depending on the above? (the mentioned tickets do not deal with the absolute value function directly...)

Daniel