Class QuadraticSolver

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

public class QuadraticSolver extends Object
Author:
GBEMIRO
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final double[]
    Store the real root of the equation in the first index of the array Store the complex root of the equation in the second index of the array
    final double[]
    Store the real root of the equation in the first index of the array Store the complex root of the equation in the second index of the array
    final double[]
    Stores the roots of the equation.
  • 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)
     
     
     
     

    Methods inherited from class java.lang.Object

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

    • solutions

      public final double[] solutions
      Stores the roots of the equation. If the solutions are not complex, then the 2 solutions are real numbers stored in index 0 and index 1 of this array. If the solutions are complex(check field complex), then index 0 contains the real part of the first complex solution and index 1 contains the complex part of the first complex solution. Index 2 contains the real part of the second complex solution and index 3 contains the complex part of the second complex solution. If the content of the 4th index(solutions[4]) is 0, then the equation has real roots. If the content of the 4th index(solutions[4]) is 1,then it has complex roots.
    • complexCoords1

      public final double[] complexCoords1
      Store the real root of the equation in the first index of the array Store the complex root of the equation in the second index of the array
    • complexCoords2

      public final double[] complexCoords2
      Store the real root of the equation in the first index of the array Store the complex root of the equation in the second index of the array
  • Constructor Details

    • QuadraticSolver

      public QuadraticSolver(double a, double b, double c)
      Parameters:
      a - the co-efficient of the squared variable
      b - the co-efficient of the variable
      c - the constant term
  • Method Details

    • setA

      public void setA(double a)
      Parameters:
      a - the co-efficient of the squared variable
    • getA

      public double getA()
      Returns:
      the co-efficient of the squared variable
    • setB

      public void setB(double b)
      Parameters:
      b - the co-efficient of the variable
    • getB

      public double getB()
      Returns:
      the co-efficient of the squared variable
    • setC

      public void setC(double c)
      Parameters:
      c - the constant term
    • getC

      public double getC()
      Returns:
      the constant term
    • isComplex

      public final boolean isComplex()
    • solve

      public String solve()
      Returns:
      the solutions as a string of values.
    • soln

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

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

      public static void main(String[] args)