Classes

  Class Description
Abs
Absolute value function
Add
Add function
ArcCosine
Acos function
ArcCosineH
Implements the arcCosH function.
ArcSine
Implementation of Asin function
ArcSineH
Implements the arcSinH function.
ArcTangent
Implementation of the Atan function
ArcTangent2
Implementation of the Atan function with two parameters
ArcTanH
Implements the arcTanH function.
Arg
Argument of a complex number
Assign
An assignment operator so we can do x=3+4.

This function implements the ICallbackEvaluation interface so that it handles setting the value of a variable.

Any Variable or function which implements the ILValue can appear on the left hand side of the equation.
Average
Average function class.

This class is very similar to MinMax, so when making changes, also consider changing MinMax.

Binomial
Binomial coefficients: binom(n,i).

Requires n,i integers >=0. Often written as nCi or column vector (n,i).

The following rules apply:

(n,0) = 1, (n,1) = n, (n,n-1) = n, (n,n) = 1

(n,i) = n! / ( i! (n-i)! )

Pascals triangle rule: (n,i) = (n-1,i-1) + (n-1,i)

Binomial theorem: (a+b)^n = sum (n,i) a^i b^(n-i), i=0..n.

For efficiency the binomial coefficients are stored in a static array.
Ceil
A PostfixMathCommandI which find the smallest integer above the number.

ceil(pi) gives 4

ceil(-i) gives -3

Comparative
Implements the comparative operations <, >, <=, >=, != and ==. The <, >, <=, >=, operators only work on Double type, while the != and == operators also work on String and Vector arguments. For other types, care might be needed.

Complex numbers are compared using a tolerance which can be set using setTolerance().

ComplexPFMC
Converts a pair of real numbers to a complex number Complex(x,y)=x+i y.
Conjugate
The complex conjugate of a number conj(c)
Cosine
Cos function
CosineH
Implementation of CosH function
Cross
Vector cross product for 2 or 3 dimensional vectors
Divide
Division function
Dot
Vector dot product.
Ele
Function which allows array access using the a[3] notation on left and right hand side. The first element is indexed with 1.
CopyC#
a=[4,3,2,1];
a[2];   // Returns 2
a[2]=5; // Sets the 2nd element of a to 5. So a is now [4,5,2,1]
b=[[1,2,3],[4,5,6]];
b[2][3]; // returns 6
b[2][3]=7; // sets 3rd element of 2nd row to 7 (only works with the configurable parser)
Exp
The exp function. Defines a method exp(Object param)
Floor
A PostfixMathCommandI which find the largest integer above the number

floor(pi) give 3

floor(-i) give -4

If
The if(condExpr, posExpr, negExpr) function.

The value of trueExpr will be returned if condExpr is >0 or true and value of negExpr will be returned if condExpr is <= 0 or true. If condExpr is NaN then NaN is returned.

This function performs lazy evaluation so that only posExpr or negExpr will be evaluated. For Complex numbers only the real part is used.

An alternate form if(condExpr, posExpr, negExpr, zeroExpr) is also available. Note most computations are carried out over floating point doubles so testing for zero can be dangerous.

This function implements the SpecialEvaluationI interface so that it handles setting the value of a variable.

Imaginary
Returns the imaginary portion of a complex number or 0 for a double.
LazyLogical
A version of the logical operators which use lazy evaluation. The first argument is always evaluated but the second argument is only evaluated if needed. Hence
  • 0 || arg2 arg2 is evaluated
  • 1 || arg2 arg2 is not evaluated and true is returned
  • 0 && arg2 arg2 is not evaluated and false is returned
  • 1 && arg2 arg2 is evaluated
List
The list function.

Returns an array comprising all the children.

Logarithm
Log base 10.
LogBase2
Logarithm base 2
Logical
Logical operators AND and OR. No longer used by default after having added
MinMax
Minimum and Maximum functions. Initialize with true for minimum and false for maximum.

This class is very similar to Average, so when making changes, also consider changing Average.

Modulus
Modulus Function
Multiply
Multiply Function
NaturalLogarithm
Natural logarithm.
  • For positive Double arguments returns a Double: Math.Log(value).
  • For negative Double arguments convert to Complex and return the Complex log: Complex(Math.Log(Math.Abs(value)),Math.PI)
  • For Complex find the complex logarithm: Complex(Math.Log(Math.Abs(value)),Arg(value))
Not
Polar
Converts an [r,theta] pair to a complex number r * e^(i theta).
PostfixMathCommand
Function classes extend this class. It is an implementation of the PostfixMathCommandI interface.

It includes a numberOfParameters member, that is checked when parsing the expression. This member should be initialized to an appropriate value for all classes extending this class. If an arbitrary number of parameters should be allowed, initialize this member to -1.

Power
pow function
Rand
Encapsulates the Random class (simply uses Random.NextDouble() method to generate random doubles beween 0-1)
Real
Returns the Real portion of a complex number, or the number itself for doubles.
Round
A PostfixMathCommandI which rounds a number.
  • round(pi) finds the closest integer to the argument
  • round(p1,3) rounds the argument to 3 decimal places
Sine
Sin function.
SineH
SinH function.
SquareRoot
Square root function.
Str
Converts an object into its string representation. Calls the toString method of the object.
StrictNaturalLogarithm
A strict version of Natural logarithm.

For negative Double arguments the standard NaturalLogarithm class will convert treat the argument and compute the complex logarithm. This class will return Double.NaN for negative Double arguments.

Subtract
Subtract function.
Sum
This class serves mainly as an example of a function that accepts any number of parameters. Note that the numberOfParameters is initialized to -1.
Tangent
Tan function.
TanH
TanH function.
UMinus
Unary minus function

Interfaces

  Interface Description
ICallbackEvaluation
Functions which require greater control over their evaluation should implement this interface.
ILValue