Karim Belabas on Thu, 20 Nov 1997 18:52:11 +0100


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

patch3


* This addresses the bug reported by Gerhard in message 6 of this list.

(14:05) gp > 1. * quadgen(-163)  \\ supposedly a root of x^2 - x - 41
%1 = 0.0000000000000000000000000000 + 6.383572667401852330855476004*I

off by 0.5 ! This bug occurred in the conversion of quadratic numbers to
complex (floating point) numbers. It affected operations between quadratic
numbers (t_QUAD) of NEGATIVE disriminant and imprecise objects 
(t_REAL, etc.). It was introduced in version 1.928 (never officially
released).

=========================== patch3 (2.0.alpha) =============================

*** src/basemath/gen2.c.orig	Fri Nov 14 04:53:26 1997
--- src/basemath/gen2.c	Thu Nov 20 14:17:06 1997
***************
*** 1531,1537 ****
    else
    {
      p1 = gsub(gsqrt(p1,prec), (GEN)p[3]);
!     setexpo(p1[1], expo(p1[1])-1);
      setexpo(p1[2], expo(p1[2])-1);
    }/* p1 = (-b + sqrt(D)) / 2 */
    p1 = gmul((GEN)x[3],p1); tetpil=avma;
--- 1531,1537 ----
    else
    {
      p1 = gsub(gsqrt(p1,prec), (GEN)p[3]);
!     p1[1] = lmul2n((GEN)p1[1],-1);
      setexpo(p1[2], expo(p1[2])-1);
    }/* p1 = (-b + sqrt(D)) / 2 */
    p1 = gmul((GEN)x[3],p1); tetpil=avma;
--
Karim Belabas                          e-mail:
Max-Planck-Institut fuer Mathematik       karim@mpim-bonn.mpg.de
Gottfried-Claren-Str. 26               tel:
53225 Bonn (Germany)                      (00 49 228) 402-245