Mathfunctions Package

The functions available from the mathfunctions package are symbolic mathematical functions or mathematical objects (in the Object-Oriented sense). This allows any functions that is created to be manipulated as a mathematical object as those found in many CAS (Computer Algebra Systems) like Mathematica or Maple.

Currently, those functions (classes) available are:

Object-Oriented Aspects of Mathematical Functions

Currently, the two major object-oriented aspects of the mathfunctions are the ability to differentiate and then the simplify procedure. The differentiate method is simple to implement, due to the nature of differentiation in that it is algorithmic. Simplification is much more difficult, often because style is important in simplication. Most of the simplication arises in the four basic mathematical operations (+,-,*,/) when the identity element (either 1 or 0) is involved in the operation.

Coding Design of the mathfunctions

The basic mathematical object is the Function object. This has two important member variables:

  • Expression: A series of nested objects used the store the individual mathematical expression.
  • VariableSet: A set (extension of TreeSet) that stores Variable objects.

Also, the Function object has the following methods:

  • evaluate: which takes a VariableSet object and an array of double primitives (of the same length) and evaluates the function, returning a double.
  • evaluateOneVar which takes a Variable and a double and returns a Function evaluated at the given variable/value pair.
  • evaluateTwoVar which takes two Variables and two doubles and returns a Function evaluated at the given variable/value pairs.
  • differentiate which returns a Function object which is the derivative of the original function.
  • simplify which returns a Function object which is a simplified version of the original function.

The Expression class

The Expression class is the superclass of all mathematical functions. It is an abstract class, and has three subclasses (Constant, UnaryExpression, and BinaryExpression).