Package math.equations
Class Quadratic
java.lang.Object
math.equations.Polynomial
math.equations.Quadratic
public class Quadratic extends Polynomial
This class represents a quadratic equation and provides functions to help
solve them.
-
Field Summary
Fields Modifier and Type Field Description doubleaThe coefficient of the quadratic term.doublebThe coefficient of the linear term.doublecThe constant.doublediscriminantThe discriminant of the quadratic equation.Fields inherited from class math.equations.Polynomial
EMPTY_ARRAY -
Constructor Summary
Constructors Constructor Description Quadratic(double a, double b, double c)Constructor of quadratic equations. -
Method Summary
Modifier and Type Method Description double[]solutions()Calculates the solutions of the equation.doublesubstitute(double x)Get the value of the quadratic for a given x value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
a
public final double aThe coefficient of the quadratic term. -
b
public final double bThe coefficient of the linear term. -
c
public final double cThe constant. -
discriminant
public final double discriminantThe discriminant of the quadratic equation.
-
-
Constructor Details
-
Quadratic
public Quadratic(double a, double b, double c)Constructor of quadratic equations.- Parameters:
a- The coefficient of the quadratic term. This may not be 0, else it would not be quadratic.b- The coefficient of the linear termc- The constant
-
-
Method Details
-
solutions
public double[] solutions()Description copied from class:PolynomialCalculates the solutions of the equation.- Specified by:
solutionsin classPolynomial- Returns:
- An array of doubles containing the solutions, if any.
-
substitute
public double substitute(double x)Get the value of the quadratic for a given x value.- Parameters:
x- The x value.- Returns:
- the value of the polynomial.
-