MVT API

math.objects
Class Variable

java.lang.Object
  |
  +--math.objects.Expression
        |
        +--math.objects.Variable
All Implemented Interfaces:
java.lang.Comparable

public class Variable
extends Expression
implements java.lang.Comparable

The class Variable is used to create mathematical Variable objects. It extends the Expr class.

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
Variable(java.lang.String identity)
          Creates an Variable object given one String argument.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Overrides the compareTo method of the Comparable object This is used for the VariableSet.
 Expression differentiate(Variable var)
          A method that returns the derivative of the Variable object using the summation rule of differentiation
 boolean equals(Variable var)
          Overrides the equal() method of the Object class.
 double evaluate(VariableSet vars, double[] values)
          A method used to evaluate a Variable object given an ordered variable vector and a corresponding array of constant double values
 Expression evaluateVariables(VariableSet variables, double[] values)
          A method used to evaluate a Variable object containing multiple variables given only one variable name and one value
 java.lang.String getIdentity()
          Returns the Variable object's identity as a String object
 void setIdentity(java.lang.String ident)
          Alternate method to set the Variable object's identity to a String object
 Expression simplify()
          A method that returns a Expression representation of the Variable object with its onlyChild in a simplified form with redundant terms combined and terms multiplied by zero eliminated.
 java.lang.String toString()
          Overrides the toString() method of the Object class.
 
Methods inherited from class math.objects.Expression
evaluate, evaluate, evaluate, evaluate, evaluate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Variable

public Variable(java.lang.String identity)
         throws UnacceptableVariableException
Creates an Variable object given one String argument.

Throws:
UnacceptableVariableException - if variable is of an unacceptable form.
Method Detail

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 Variable Object

getIdentity

public java.lang.String getIdentity()
Returns the Variable object's identity as a String object

Returns:
the Variable object's identity as a String object

setIdentity

public void setIdentity(java.lang.String ident)
Alternate method to set the Variable object's identity to a String object


equals

public boolean equals(Variable var)
Overrides the equal() method of the Object class. This determines whether two Variable objects have the same identity

Returns:
a boolean equal to true if identities are equal a boolean equal to false if identities are not equal

evaluate

public double evaluate(VariableSet vars,
                       double[] values)
                throws java.lang.ArithmeticException,
                       IllegalEvaluationException,
                       VariableUndefinedException
A method used to evaluate a Variable object given an ordered variable vector and a corresponding array of constant double values

Specified by:
evaluate in class Expression
Parameters:
vars - the name of the VariableVector of Variables associated with the function.
Returns:
a double representing the value of the Expression for the entered value.
Throws:
VariableUndefinedException - for Variables not defined
java.lang.ArithmeticException - for NaN and Divide by Zero
IllegalEvaluationException - if an error occurs
Since:
JDK1.1

evaluateVariables

public Expression evaluateVariables(VariableSet variables,
                                    double[] values)
                             throws java.lang.ArithmeticException,
                                    IllegalEvaluationException
A method used to evaluate a Variable object containing multiple variables given only one variable name and one value

Specified by:
evaluateVariables in class Expression
Parameters:
variables - a VariableSet value
values - a double[] value
Returns:
a Expression object representing the given Expression with one of it's variables evaluated for the given value.
Throws:
IllegalEvaluationException - if the number of variables do not equal the number of values.
java.lang.ArithmeticException - for NaN and Divide by Zero
Since:
JDK1.1

differentiate

public Expression differentiate(Variable var)
A method that returns the derivative of the Variable object using the summation rule of differentiation

Specified by:
differentiate in class Expression
Parameters:
var - the variable of differentiation
Returns:
an Expression object containing value of one representing the derivative of the Variable object if the derivative is with respect to this Variable object.

simplify

public Expression simplify()
A method that returns a Expression representation of the Variable object with its onlyChild in a simplified form with redundant terms combined and terms multiplied by zero eliminated.

Specified by:
simplify in class Expression
Returns:
an Expression object in a simplified form

compareTo

public int compareTo(java.lang.Object obj)
Overrides the compareTo method of the Comparable object This is used for the VariableSet.

Specified by:
compareTo in interface java.lang.Comparable

MVT API

mvt.icons