public class QuadraticFunction extends OneDimensionalFunction
| Constructor and Description |
|---|
QuadraticFunction(double a,
double b,
double c)
This constructor creates a quadratic function with:
a*x2 + b*x + c. |
QuadraticFunction(double x1,
double fx1,
double x2,
double fx2,
double x3,
double fx3)
This constructor creates an instance from 3 points
(x,f(x)). |
| Modifier and Type | Method and Description |
|---|---|
double |
evaluateFunction(double x)
Evaluates the function at position
x. |
double |
findMax()
This method returns the maximum of the
QuadraticFunction. |
double |
findMin()
This method returns the minimum of the
QuadraticFunction. |
double |
getExtremum()
This method returns the extremum of the
QuadraticFunction. |
String |
toString() |
evaluateFunction, findMin, getDimensionOfScopepublic QuadraticFunction(double a,
double b,
double c)
a*x2 + b*x + c.a - the coefficient for x2b - the coefficient for xc - the constantpublic QuadraticFunction(double x1,
double fx1,
double x2,
double fx2,
double x3,
double fx3)
throws IOException
(x,f(x)).x1 - the first x-coordinatefx1 - f(x1)x2 - the second x-coordinatefx2 - f(x2)x3 - the third x-coordinatefx3 - f(x3)IOException - if the quadratic function could not be determinedpublic double evaluateFunction(double x)
OneDimensionalFunctionx.evaluateFunction in class OneDimensionalFunctionx - the current positionf(x)public double findMax()
throws IOException
QuadraticFunction.IOException - if no maximum existspublic double findMin()
throws IOException
QuadraticFunction.IOException - if no minimum existspublic double getExtremum()
throws IOException
QuadraticFunction.IOException - if no extremum exists