| Karim Belabas on Sat, 10 Mar 2007 19:23:39 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Desired behaviour ? |
* 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.
Since "automatic simplification" (\y) is on by default, things could
become even more confusing:
? a = I*I
%1 = -1 \\ t_INT
with a = -1 + 0*I. Nice.
K.B.
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.
The precise behaviour of a basic operation on the PARI types is not
explicitly documented. ("Anything that should make sense does, with the
expected result. Unless it does not".)
--
Karim Belabas Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1 Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation http://www.math.u-bordeaux.fr/~belabas/
F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP]