|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface IQuadraticFunction
A quadratic function, f(x), has the form ax2 + bx1 + cx0, or more simply, ax2 + bx + c where the coefficients a, b, and c are real numbers.
For example, if a=2.0, b=4.0, and c=1.0 then f(x) = 2.0*x2 + 4.0*x + 1.0. The function may be evaluated for a particular value of x by substituting the value for x in the above equation. For example, f(2) = 2.0*22 + 4.0*2 + 1.0 = 2.0*4 + 8.0 + 1.0 = 17.0.
A class implementing the IQuadraticFunction interface
will be able to evaluate a function at a particular value of x
using the eval method. The current values
of a, b and c can be obtained with
getA,
getB, and
getC.
Finally, the coefficients can be reset to represent a new function with
setCoefficients.
The function can be graphed by passing an instance of IQuadraticFunction
to GrapherGUI. Please see the package description
for a more in-depth discussion of using this class.
IFunction,
IPolynomialFunction,
GrapherGUI| Method Summary | |
|---|---|
void |
addView(IView aView)
Add a view (graphical user interface) to the function. |
double |
eval(double x)
Evaluate the function for a given value of x. |
double |
getA()
Get the current value of coefficient a |
double |
getB()
Get the current value of coefficient b |
double |
getC()
Get the current value of coefficient c |
void |
setCoefficients(double a,
double b,
double c)
Set the coefficients of the quadratic function, a, b, and c to new values. |
| Method Detail |
|---|
double getA()
double getB()
double getC()
void setCoefficients(double a,
double b,
double c)
a - The new coeffient for the x2 term.b - The new coeffient for the x1 term.c - The new coeffient for the x0 term.double eval(double x)
x - The value for which the function should be evaluated.void addView(IView aView)
updateView
method must be called each time the function's state changes.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||