Class CubicEquation

java.lang.Object
fr.rodofire.ewc.maths.equation.CubicEquation

public class CubicEquation extends Object
Class based on the cubic equation solver provided by WattZap.

License: GNU General Public License

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    The number of real roots.
    double
    The first real root.
    double
    The second real root.
    double
    The third real root.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a new Cubic object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    solve(double a, double b, double c, double d)
    Solve the cubic equation with the given coefficients.

    Methods inherited from class java.lang.Object

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

    • nRoots

      public int nRoots
      The number of real roots.
    • x1

      public double x1
      The first real root.
    • x2

      public double x2
      The second real root.
    • x3

      public double x3
      The third real root.
  • Constructor Details

    • CubicEquation

      public CubicEquation()
      Construct a new Cubic object.
  • Method Details

    • solve

      public void solve(double a, double b, double c, double d)
      Solve the cubic equation with the given coefficients. The results are stored in this Cubic object's fields.
      Parameters:
      a - Coefficient of x3.
      b - Coefficient of x2.
      c - Coefficient of x.
      d - Constant coefficient.