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 Summary

    Fields
    Modifier and Type
    Field
    Description
    final double[]
    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
  • Constructor Summary

    Constructors
    Constructor
    Description
    QuadraticSolver(double a, double b, double c)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
     
    double
     
    double
     
    final boolean
     
    static void
    main(String[] args)
     
    void
    setA(double a)
     
    void
    setB(double b)
     
    void
    setC(double c)
     
    Returns the solutions as an array of strings.
    Returns the solutions as a formatted string.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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
  • 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)