Bill Allombert on Sat, 10 Mar 2007 21:52:26 +0100

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Desired behaviour ?

On Sat, Mar 10, 2007 at 07:21:27PM +0100, Karim Belabas wrote:
> * Bill Allombert [2007-03-10 18:53]:
> > On Sat, Mar 10, 2007 at 05:34:22PM +0100, Loic Grenie wrote:
> > > 
> > >     I'm just wondering if there is a strong reason why 1.*I*I has an
> > >   imaginary part (equal to 0., but it's there). For instance neither I*I*1.
> > >   nor 1.*(I*I) have any imaginary part.
> > 
> > My understanding is that I*I should return -1+0*I but wrongly return
> > -1. So 1.*I*I should have an imaginary part (along with I*I*1. and
> > 1.*(I*I) of course).
> > 
> > The rationale is that arithmetic operation should preserve the
> > definition domain so that domain detection work:
> More precisely, I*I might return -1+0*I for the reason you indicate, but
> simplify(-1+0*I) should definitely return -1.

Of course.

> P.S: I have no strong feelings either way. This is among the things that
> just "always worked that way" for no particular reason except immediate
> simplicity.  

It is crucial that the PARI type of objects is predictable in order to 
write robust code because the semantic of a lot of functions depend on
the PARI type. It is even more important in library mode, because you
need/want low-level access to objects which is only possible if the
exact type is known (e.g. using x[1] instead of greal).

(Historically I took the trouble to write the Fp* functions mainly to
avoid dealing with inconsistency in the return types of generic operations).