de.jstacs.algorithms.optimization

• All Implemented Interfaces:
Function

```public class QuadraticFunction
extends OneDimensionalFunction```
This class implements a quadratic function.
Author:
Jens Keilwagen
• ### Constructor Summary

Constructors
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))`.
• ### Method Summary

All Methods
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()`
• ### Methods inherited from class de.jstacs.algorithms.optimization.OneDimensionalFunction

`evaluateFunction, findMin, getDimensionOfScope`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Constructor Detail

```public QuadraticFunction(double a,
double b,
double c)```
This constructor creates a quadratic function with: `a*x2 + b*x + c`.
Parameters:
`a` - the coefficient for `x2`
`b` - the coefficient for `x`
`c` - the constant

```public QuadraticFunction(double x1,
double fx1,
double x2,
double fx2,
double x3,
double fx3)
throws IOException```
This constructor creates an instance from 3 points `(x,f(x))`.
Parameters:
`x1` - the first `x`-coordinate
`fx1` - `f(x1)`
`x2` - the second `x`-coordinate
`fx2` - `f(x2)`
`x3` - the third `x`-coordinate
`fx3` - `f(x3)`
Throws:
`IOException` - if the quadratic function could not be determined
• ### Method Detail

• #### evaluateFunction

`public double evaluateFunction(double x)`
Description copied from class: `OneDimensionalFunction`
Evaluates the function at position `x`.
Specified by:
`evaluateFunction` in class `OneDimensionalFunction`
Parameters:
`x` - the current position
Returns:
`f(x)`
• #### findMax

```public double findMax()
throws IOException```
This method returns the maximum of the `QuadraticFunction`.
Returns:
the maximum
Throws:
`IOException` - if no maximum exists
• #### findMin

```public double findMin()
throws IOException```
This method returns the minimum of the `QuadraticFunction`.
Returns:
the minimum
Throws:
`IOException` - if no minimum exists
• #### getExtremum

```public double getExtremum()
throws IOException```
This method returns the extremum of the `QuadraticFunction`.
Returns:
the extremum
Throws:
`IOException` - if no extremum exists
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`