Class QuadraticSolver

java.lang.Object
com.github.gbenroscience.math.quadratic.QuadraticSolver

public class QuadraticSolver extends Object
Solves quadratic equations of the form ax² + bx + c = 0. Includes numerical stability for real roots and correct complex conjugate pairs. * @author GBEMIRO
  • Field Details

    • solutions

      public final double[] solutions
      solutions[0], solutions[1]: Real/Imag parts of root 1 solutions[2], solutions[3]: Real/Imag parts of root 2 solutions[4]: 0 for Real, 1 for Complex
    • complexCoords1

      public final double[] complexCoords1
    • complexCoords2

      public final double[] complexCoords2
  • Constructor Details

    • QuadraticSolver

      public QuadraticSolver(double a, double b, double c)
  • Method Details

    • setA

      public void setA(double a)
    • getA

      public double getA()
    • setB

      public void setB(double b)
    • getB

      public double getB()
    • setC

      public void setC(double c)
    • getC

      public double getC()
    • isComplex

      public final boolean isComplex()
    • solve

      public String solve()
      Returns the solutions as a formatted string.
    • soln

      public String[] soln()
      Returns the solutions as an array of strings.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • main

      public static void main(String[] args)