Interface IFunction

public interface IFunction

Objects implementing the IFunction interface represent a mathematical function, say f(x). For example, if f(x) = cos(x) + sin(x), a suitable class could be defined this way:

     public class CosSin extends Object implements Function
     {  public CosSin()
        {  super();
        public double eval(double x)
        {  return Math.cos(x) + Math.sin(x);
and the following code would print a series of values of f(x):
     Function f = new CosSin();
     for(double x=-1; x<1; x+=0.5)
     {  System.out.println(f.eval(x));

By using instance variables and appropriate parameters on the constructor, entire families of functions can be defined using the same class.

The function can be graphed by passing an instance of IFunction to GrapherGUI. Please see the package description for a more in-depth discussion of using this class.

Byron Weber Becker
See Also:
GrapherGUI, IQuadraticFunction, IPolynomialFunction

Method Summary
 double eval(double x)
          Evaluate the function for a given value of x.

Method Detail


double eval(double x)
Evaluate the function for a given value of x.

x - The value for which the function should be evaluated.