MVT API

math.objects
Class Function

java.lang.Object
  |
  +--math.objects.Function

public class Function
extends java.lang.Object

The Function class is a container class for the Expr class. It holds an Expr object, a VariableSet object containing the defined variables for the Expr object and the String that generated the Expr object.

Since:
JDK1.1
Author:
Peter Staab
, Pete Fox , both for the Mathematical Visualization Project for the Department of Applied Mathematics, University of Colorado at Boulder

Constructor Summary
Function(Expression expr, VariableSet vars)
          Creates an Function object given one Expr argument.
Function(java.lang.String str)
          Creates an Function object given one String argument.
 
Method Summary
 void addVariable(Variable var)
          A method that adds a Variable object to a VariableSet that contains all of the defined individual Variables for the current Expression.
 Function differentiate(Variable var)
          A method that returns a Function representation of the derivative of the current Expr differentiated with respect to String var.
 boolean equals(Function f)
          Overrides the equal() method of the Object class.
 boolean equals(java.lang.String input)
          Overrides the equal() method of the Object class.
 double evaluate()
          A method used to evaluate a symbolic object given nothing.
 double evaluate(Variable var, double value)
          A method used to evaluate a symbolic object given a one variable name and one value
 double evaluate(Variable var1, double value1, Variable var2, double value2)
          A method used to evaulate a symbolic object given two variable names and two values
 double evaluate(Variable var1, double value1, Variable var2, double value2, Variable var3, double value3)
          A method used to evaulate the Expr object of this Function given three variable names and three values
 double evaluate(Variable var1, double value1, Variable var2, double value2, Variable var3, double value3, Variable var4, double value4)
          A method used to evaulate the Expr object of this Function given 4 variable names and 4 values
 double evaluate(VariableSet vars, double[] values)
          A method used to evaluate a symbolic object given any number of doubles contained in an array.
 Function evaluateOneVar(Variable var, double value)
          An method used to evaluate a Function object containing multiple variables given only one variable name and one value
 Function evaluateTwoVar(Variable var1, double value1, Variable var2, double value2)
          An method used to evaluate a Function object containing multiple variables given two variable names and two values
 Expression getExpression()
          A method that returns an Expression object, expr, that contains the current Expression for the Function object.
 int getNumVariables()
          Returns number of Variable objects defined in variables vector as a integer value
 Variable getVar(java.lang.String str)
          Returns a Variable object identical to string str from the the variables VariableSet object
 VariableSet getVariables()
          A method that returns the VariableSet that contains all of the defined individual Variables for the current Expression.
 void setExpression(Expression expr)
          A method that initializes a Expression object, expr, that contains the current Expression for the Function object.
 void setVariables(VariableSet variables)
          A method that initializes a VariableSet variables that contains all of the defined individual Variables for the current Expr.
 Function simplify()
           
 java.lang.String toString()
          Overrides the toString() method of the Object class.
 boolean variableDefined(Variable var)
          A method that tests a Variable object against a VariableSet that contains all of the defined individual Variables to determine if there is a new instance of a Variable object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Function

public Function(java.lang.String str)
         throws SyntaxException
Creates an Function object given one String argument.

Parameters:
str - the String object representing a mathematical expression
Throws:
SyntaxException - for incomplete or unparsable mathematical expressions

Function

public Function(Expression expr,
                VariableSet vars)
Creates an Function object given one Expr argument.

Parameters:
expr - the Expr object representing a mathematical expression.
Method Detail

equals

public boolean equals(Function f)
Overrides the equal() method of the Object class. This determines whether two Funtion objects have the same stringExpr.

Returns:
a boolean equal to true if stringExpr are equal or a boolean equal to false if stringExpr are not equal

equals

public boolean equals(java.lang.String input)
Overrides the equal() method of the Object class. This determines whether two Funtion objects have the same stringExpr.

Returns:
a boolean equal to true if stringExpr are equal or a boolean equal to false if stringExpr are not equal

setVariables

public void setVariables(VariableSet variables)
A method that initializes a VariableSet variables that contains all of the defined individual Variables for the current Expr.


getVariables

public VariableSet getVariables()
A method that returns the VariableSet that contains all of the defined individual Variables for the current Expression.

Returns:
VariableSet variables that contains the defined Variable object for the Expression expr

getNumVariables

public int getNumVariables()
Returns number of Variable objects defined in variables vector as a integer value

Returns:
number of defined Variables as a integer value

addVariable

public void addVariable(Variable var)
A method that adds a Variable object to a VariableSet that contains all of the defined individual Variables for the current Expression.

Parameters:
var - the variable newly defined.

variableDefined

public boolean variableDefined(Variable var)
A method that tests a Variable object against a VariableSet that contains all of the defined individual Variables to determine if there is a new instance of a Variable object.

Parameters:
var - the new Variable object
Returns:
boolean indicating whether object present in VariableSet variables.

getVar

public Variable getVar(java.lang.String str)
                throws VariableUndefinedException,
                       UnacceptableVariableException
Returns a Variable object identical to string str from the the variables VariableSet object

Returns:
Var as a Variable object
Throws:
VariableUndefinedException - for Variables not defined
UnacceptableVariableException - for unacceptable variable string inputs

setExpression

public void setExpression(Expression expr)
A method that initializes a Expression object, expr, that contains the current Expression for the Function object.

Parameters:
expr - the Expression to be attributed to this Function object.

getExpression

public Expression getExpression()
A method that returns an Expression object, expr, that contains the current Expression for the Function object.

Returns:
expr--the Expressionession to be attributed to this Function object.

evaluate

public double evaluate(VariableSet vars,
                       double[] values)
                throws java.lang.ArithmeticException,
                       VariableUndefinedException,
                       IllegalEvaluationException
A method used to evaluate a symbolic object given any number of doubles contained in an array. The orderVariables() method MUST be called before this method to set the variables in the order that you plan to send the doubles contained in the array values.

Parameters:
values - an array of doubles containing the values that correspond to the Variables contained in the VariableSet orderedVariables
Returns:
a double representing the value of the Expr for the entered values.
Throws:
VariableUndefinedException - for Variables not defined
java.lang.ArithmeticException - for NaN and Divide by Zero
IllegalEvaluationException - if the number of variables does not equal the number of values.
Since:
JDK1.1

evaluate

public double evaluate()
                throws java.lang.ArithmeticException,
                       VariableUndefinedException
A method used to evaluate a symbolic object given nothing.

Returns:
a double representing the value of the Expr for the entered value.
Throws:
VariableUndefinedException - if a variable is called in the evaluation list but not not exist in the Function's variable list.
java.lang.ArithmeticException - for NaN and Divide by Zero
Since:
JDK1.1

evaluate

public double evaluate(Variable var,
                       double value)
                throws java.lang.ArithmeticException,
                       VariableUndefinedException,
                       UnacceptableVariableException
A method used to evaluate a symbolic object given a one variable name and one value

Parameters:
var - the name of the Variable associated with the function
value - the value of the Variable
Returns:
a double representing the value of the Expr for the entered value.
Throws:
VariableUndefinedException - for Variables not defined
java.lang.ArithmeticException - for NaN and Divide by Zero
UnacceptableVariableException - for unacceptable variable string inputs
Since:
JDK1.1

evaluate

public double evaluate(Variable var1,
                       double value1,
                       Variable var2,
                       double value2)
                throws java.lang.ArithmeticException,
                       VariableUndefinedException,
                       UnacceptableVariableException
A method used to evaulate a symbolic object given two variable names and two values

Parameters:
var1 - the name of the first Variable associated with the function
value1 - the value of the first Variable
var2 - the name of the second Variable associated with the function
value2 - the value of the second Variable
Returns:
a double representing the value of the Expr for the entered value.
Throws:
VariableUndefinedException - for Variables not defined
java.lang.ArithmeticException - for NaN and Divide by Zero
UnacceptableVariableException - for unacceptable variable string inputs
Since:
JDK1.1

evaluate

public double evaluate(Variable var1,
                       double value1,
                       Variable var2,
                       double value2,
                       Variable var3,
                       double value3)
                throws java.lang.ArithmeticException,
                       VariableUndefinedException,
                       UnacceptableVariableException
A method used to evaulate the Expr object of this Function given three variable names and three values

Parameters:
var1 - the name of the first Variable associated with the function
value1 - the value of the first Variable
var2 - the name of the second Variable associated with the function
value2 - the value of the second Variable
var3 - the name of the second Variable associated with the function
value3 - the value of the second Variable
Returns:
a double representing the value of the Expr for the entered value.
Throws:
VariableUndefinedException - for Variables not defined
java.lang.ArithmeticException - for NaN and Divide by Zero
UnacceptableVariableException - for unacceptable variable string inputs
Since:
JDK1.1

evaluate

public double evaluate(Variable var1,
                       double value1,
                       Variable var2,
                       double value2,
                       Variable var3,
                       double value3,
                       Variable var4,
                       double value4)
                throws java.lang.ArithmeticException,
                       VariableUndefinedException,
                       UnacceptableVariableException
A method used to evaulate the Expr object of this Function given 4 variable names and 4 values

Parameters:
var1 - the name of the first Variable associated with the function
value1 - the value of the first Variable
var2 - the name of the second Variable associated with the function
value2 - the value of the second Variable
var3 - the name of the second Variable associated with the function
value3 - the value of the second Variable
var4 - the name of the second Variable associated with the function
value4 - the value of the second Variable
Returns:
a double representing the value of the Expr for the entered value.
Throws:
VariableUndefinedException - for Variables not defined
java.lang.ArithmeticException - for NaN and Divide by Zero
UnacceptableVariableException - for unacceptable variable string inputs

evaluateOneVar

public Function evaluateOneVar(Variable var,
                               double value)
                        throws java.lang.ArithmeticException,
                               VariableUndefinedException,
                               UnacceptableVariableException
An method used to evaluate a Function object containing multiple variables given only one variable name and one value

Parameters:
value - the value of the Variable
Returns:
a Function object representing the given Function with one of it's variables evaluated for the given value.
Throws:
VariableUndefinedException - for Variables not defined
java.lang.ArithmeticException - for NaN and Divide by Zero
UnacceptableVariableException - for unacceptable variable string inputs
Since:
JDK1.1

evaluateTwoVar

public Function evaluateTwoVar(Variable var1,
                               double value1,
                               Variable var2,
                               double value2)
                        throws java.lang.ArithmeticException,
                               VariableUndefinedException,
                               UnacceptableVariableException
An method used to evaluate a Function object containing multiple variables given two variable names and two values

Parameters:
value1 - the value of the Variable
value2 - the value of the Variable
Returns:
a Expr object representing the given Expr with two of it's variables evaluated for the given value.
Throws:
VariableUndefinedException - for Variables not defined
java.lang.ArithmeticException - for NaN and Divide by Zero
UnacceptableVariableException - for unacceptable variable string inputs
Since:
JDK1.1

differentiate

public Function differentiate(Variable var)
                       throws VariableUndefinedException,
                              UnacceptableVariableException
A method that returns a Function representation of the derivative of the current Expr differentiated with respect to String var.

Parameters:
var - the variable of differentiation
Returns:
a Function object representing the derivative of the current Function object's Expr expr
Throws:
VariableUndefinedException - for Variables not defined
UnacceptableVariableException - for unacceptable variable string inputs

simplify

public Function simplify()

toString

public java.lang.String toString()
Overrides the toString() method of the Object class. This gives a string represenation of the Symbolic Object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the Function Object

MVT API

mvt.icons