Bill Allombert on Mon, 29 Jul 2019 23:52:04 +0200


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

Re: real/imag for t_QUAD


On Mon, Jul 29, 2019 at 11:29:50PM +0200, Vincent Delecroix wrote:
> Bonjour,
> 
> I am confused by the behavior of the GP functions real and imag called
> on quadratic numbers
> 
> ? w1 = quadgen(-23);
> ? real(w1)
> %10 = 0
> ? imag(w1)
> %11 = 1
> 
> According to the (ambiguous?) documentation of these functions, the
> return values are supposed to be the real and imaginary parts. I would
> have expected an answer closer to 0.5 and and 2.3979. But perhaps my
> notion of real and imaginary part is not up to date.

See ??t_QUAD:
Quadratic numbers (t_QUAD):
....
   Since  the  order is Z + wZ,  any other element can be input as z =
x+y*w for some integers x and y. In fact, you may work in its fraction
field Q(sqrt{d}) and use t_FRAC values for x and y.

   The member function z.disc retrieves the discriminant d; x and y are
obtained via real(z) and imag(z) respectively.

Cheers,
Bill.