Class CubicEquation


  • public class CubicEquation
    extends java.lang.Object
    This is a port of code written by Gerolamo Cardano under the Code Project Open Licence. A copy of the license if found at https://www.codeproject.com/info/cpol10.aspx. The equation is a1*x**3 + b*x**2 + c*x + d = 0 If result = 0, a1 = 0 If result = 1, x1 is real and x2 and x3 are complex with x3 = complex conjugate of x2 If result = 2, there are 3 real roots of which at least 2 are equal If result = 3, 3 real and unequal roots are found
    Author:
    ilb
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double a1  
      private double b  
      private double c  
      private double d  
      private int[] result  
      private double[] x1real  
      private double[] x2imag  
      private double[] x2real  
      private double[] x3imag  
      private double[] x3real  
    • Constructor Summary

      Constructors 
      Constructor Description
      CubicEquation()  
      CubicEquation​(double a1, double b, double c, double d, double[] x1real, double[] x2real, double[] x2imag, double[] x3real, double[] x3imag, int[] result)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void run()  
      void selfTest()  
      double Xroot​(double a, double x)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • a1

        private double a1
      • b

        private double b
      • c

        private double c
      • d

        private double d
      • x1real

        private double[] x1real
      • x2real

        private double[] x2real
      • x2imag

        private double[] x2imag
      • x3real

        private double[] x3real
      • x3imag

        private double[] x3imag
      • result

        private int[] result
    • Constructor Detail

      • CubicEquation

        public CubicEquation()
      • CubicEquation

        public CubicEquation​(double a1,
                             double b,
                             double c,
                             double d,
                             double[] x1real,
                             double[] x2real,
                             double[] x2imag,
                             double[] x3real,
                             double[] x3imag,
                             int[] result)
    • Method Detail

      • selfTest

        public void selfTest()
      • run

        public void run()
      • Xroot

        public double Xroot​(double a,
                            double x)