classpath
[Top][All Lists]
Advanced

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

Fwd: Quadratic and cubic equations


From: Sascha Brawer
Subject: Fwd: Quadratic and cubic equations
Date: Thu, 8 Jan 2004 16:26:46 +0100

---------------- Begin Forwarded Message ----------------
Subject: Re: Quadratic and cubic equations
Date Sent: Wednesday, January 7, 2004 3:17 PM
From: Sascha Brawer <address@hidden>
To: Brian Gough <address@hidden>
CC: Mark Wielaard <address@hidden>, Michael Koch <address@hidden>

Hi Brian

we have a problem with solving a specific quadratic equation in GNU
Classpath. For your convenience, I've re-written the problematic equation
as a patch to the GSL test suite (gsl/poly/test.c); see below.

I suspect that the problem is the test for (disc == 0) in gsl/poly/
solve_quadratic.c, line 61. With the Java version of your code, we get a
very small negative number in gcj (the Java front-end for the GCC) on IA-
32, and exactly 0.0 with some other Java Virtual Machines.

Could it be that the test for (disc == 0) should actually be replaced by
something like (fabs(disc - 0.0) < EPSILON)? If so, which value is
appropriate for EPSILON?

I have entered the problem into the bug database for GNU Classpath; see

 http://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=7123

Thanks a lot for your help,

-- Sascha

Sascha Brawer, address@hidden, http://www.dandelis.ch/people/brawer/ 


Index: poly/test.c
===================================================================
RCS file: /cvs/gsl/gsl/poly/test.c,v
retrieving revision 1.16
diff -u -r1.16 test.c
--- poly/test.c 26 Jul 2003 13:44:36 -0000      1.16
+++ poly/test.c 7 Jan 2004 13:32:21 -0000
@@ -102,6 +102,18 @@
     gsl_test_rel (x1, 2.0, 1e-9, "x1, 5 x^2 = 20");
   }
 
+  {
+    /* From the Mauve test suite, used by GNU Classpath. */
+    double x0, x1;
+
+    int n = gsl_poly_solve_quadratic (0.1, 20.0, 1000.0, &x0, &x1);
+
+    gsl_test (n != 1,
+              "gsl_poly_solve_quadratic, (x^2)/10 + 20x + 1000 = 0");
+    gsl_test_rel (x0, -100.0, 1e-9, "x0, (x^2)/10 + 20x + 1000 = 0");
+  }
+
+
   /* Cubic */
 
   {

----------------- End Forwarded Message -----------------






reply via email to

[Prev in Thread] Current Thread [Next in Thread]