JDK-4635008 : CubicCurve2D.solveCubic fails when there are repeated roots.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2002-02-07
  • Updated: 2002-03-08
  • Resolved: 2002-03-08
Related Reports
Duplicate :  
Description

Name: jk109818			Date: 02/07/2002


FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) 64-Bit Server VM (build 1.4.0-beta3-b84, mixed mode)

FULL OPERATING SYSTEM VERSION :SunOS unknown 5.8 Generic
sun4u sparc SUNW,Ultra-5_10





A DESCRIPTION OF THE PROBLEM :
The static method CubicCurve2D.solveCubic fails on cubics
that factor as  (x - r)^2 * (x - s)  where  r  and  s  are
real and distinct. It finds  s  but not  r.

I looked at the source code and here is a 2 line fix:

change the line

        if (R2 < Q3) {
to
        if (R2 <= Q3 && Q != 0.0) {

and add the line

          if (R2 == Q3) roots--;

just before the close of the above if.

 Ralph Freese              | E-Mail:
<mailto:###@###.###>
 Department of Mathematics | WWW:
<http://www.math.hawaii.edu/~ralph>
 University of Hawaii
 Honolulu, Hawaii 96822

 
     





This bug can be reproduced always.

CUSTOMER WORKAROUND :
See description for a solution
(Review ID: 138582) 
======================================================================

Comments
EVALUATION The solution is actually somewhat more complex than that due to roundoff error. Many "2 root" cases fall into a neighborhood of values for R2 and Q3 being near each other. This method probably needs to be revised to use the closed form results as a series of seeds for guessing at the real roots. Bug 4645692 proposes a simpler solution that involves fewer calculations and comparisons for the 2 root case so I will be closing this bug as a duplicate of that one. ###@###.### 2002-03-07
07-03-2002