sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.34k stars 452 forks source link

multiplicative order inconsistency #341

Closed williamstein closed 17 years ago

williamstein commented 17 years ago
On 3/31/07, Pablo De Napoli <> wrote:
> In the process of investigating how rings are defined in sage I've found
> some 
> inconsistencies: the function multiplicative_order is not consistently
> defined
> for all rings.
> 
> Applying this function to a rational 
> integer which is not a unit raises an exception:
> 
> sage: a=ZZ(3)
> sage: a.multiplicative_order()
> ---------------------------------------------------------------------------
> <type 'exceptions.ArithmeticError '>       Traceback (most recent call last)
> 
> /hdc1/pablo.hdc1/sage/sage/<ipython console> in <module>()
> 
> /hdc1/pablo.hdc1/sage/sage/integer.pyx in
> integer.Integer.multiplicative_order()
> 
>  <type 'exceptions.ArithmeticError'>: no power of 3 is a unit
> 
> (and so does for example the ring ComplexDouble)
> 
> However, for complex numbers, things are different: (gives +infinity)
> 
>  b= 2+3*I 
> sage: type(b)
> <type 'sage.rings.complex_number.ComplexNumber'>
> sage: b.multiplicative_order()
> +Infinity
> 
> Which should be the correct behaviour? (I like more the one that answers
> +infinity) 

The correct behavior is +infinity, which is more useful and than an error,
and is technically correct.  

Component: basic arithmetic

Issue created by migration from https://trac.sagemath.org/ticket/341

85eec1a4-3d04-4b4d-b711-d4db03337c41 commented 17 years ago
comment:1

I would consider this "worksforme":

----------------------------------------------------------------------
| SAGE Version 2.8.2, Release Date: 2007-08-22                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------

sage: a=ZZ(3)
sage: a.multiplicative_order()
+Infinity