Bill Allombert on Mon, 26 Jul 2010 15:12:46 +0200


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

Re: Real zero in libpari


On Mon, Jul 26, 2010 at 02:35:04PM +0200, Jeroen Demeyer wrote:
> Hello pari-users,
> 
> I have a technical question about the t_REAL type.  The documentation
> says that real zero is characterized by having the sign equal to zero.
> My question is: does a real zero NEED to have lg == 2 in order to be a
> valid GEN?

Currently, yes. This is necessary because z[2] must be normalized, and so
cannot be 0. Thus the only possibility is that z[2] does not exist i.e. lg=2.

> I am asking because the following program gives an error:
> #include <pari/pari.h>
> int main()
> {
>     pari_init(1000000, 500000);
> 
>     GEN x = cgetr(3);  /* Normally, lg would be 2 */
>     setsigne(x, 0);
>     setexpo(x, -63);
>     dbgGEN(x, -1);
> 
>     /* The following line gives:
>   ***   overflow in expo().
>   ***   Error in the PARI system. End of program. */
>     gexp(x, 100);
> }

It seems that mpexp explicitly make the assumption that lg(x)=2 iff signe(x)=0.
This assumption is correct at this point.

Another frequent similar assumption is done for polynomials with t_INT coefficients:
lg(x)=2 iff signe(x)=0. Note that this is not true for general polynomials (with
inexact 0 as coefficients).

Cheers,
Bill.