Karim Belabas on Sat, 15 Sep 2001 10:37:21 +0000 (GMT)


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

Re: truncation


On Wed, 1 Aug 2001, Mark Chimley wrote:
> I have been using simplify (ground (x)) to convert x (a polynomial with
> complex coefficients) into one with integer coefficients. The polynomial
> is an approximation to a class equation of an imaginary quadratic field,
> so is known to reside in Z[X]. The problem is, when the coefficients
> become suitably large, I get the error, "precision loss in truncation".
> I have tried using precision (x, n) to increase the number of decimal
> places in x prior to rounding, and although this seemed to overcome the
> error, simplify (x) did not give a polynomial with integer coefficients.
> 
> I think an example might be appropriate to explain the problem better,
> so I shall log some output. In the meantime, I shall post this message
> to see if there is anything obvious that I am doing wrong, and to ask
> exactly what "precision loss in truncation" means.

You are trying to take the integral part (as a subroutine of round()) of a
real number whose number of significant digits is too low for the operation
to make sense, e.g round(1e30) at \p28 : 1e30 represents any real number x
such that |x - 10^30| < 2^(99 - 3*32) = 8 [assuming 32bit machine;
internally, we have significant bits, not digits: 1e30 has exponent 99 and
\p28 translates to 3 significant words].  There is no unique integer with
that property, hence the error message.

What you need to do is to increase the precision of your data _before_
starting the computation, e.g. increase 'realprecision' before computing your
transcendental functions. Using 'precision' to increase the internal
precision of an object is a hack that inserts essentially random significant
digits.

Hope this helps,

  Karim.

-- 
Karim Belabas                    email: Karim.Belabas@math.u-psud.fr
Dep. de Mathematiques, Bat. 425
Universite Paris-Sud             Tel: (00 33) 1 69 15 57 48
F-91405 Orsay (France)           Fax: (00 33) 1 69 15 60 19
--
PARI/GP Home Page: http://www.parigp-home.de/