The following functions are included by default through the StandardFunctionTable unless otherwise noted. Functions can be included individually by calling jep.addFunction(String, PostfixMathCommandI). All standard function classes are located in the jep.functions package. The BigDecimal functions are kept separate in the jep.bigdecimal.functions package and the string manipulation functions are kept in jep.functions.strings.

Note that you can also add new custom functions.

Trigonometric Functions

All functions accept arguments of the Double and Complex type, except atan2 which only accepts Double arguments.

Description Function Name Class Name
Sine sin(x) Sine
Cosine cos(x) Cosine
Tangent tan(x) Tangent
Arc Sine2 asin(x) ArcSine
Arc Cosine2 acos(x) ArcCosine
Arc Tangent atan(x) ArcTangent
Arc Tan with 2 parameters atan2(y, x) ArcTangent2
Secant sec(x) Secant
Cosecant cosec(x) Cosecant
Co-tangent cot(x) Cotangent
Hyperbolic Sine sinh(x) SineH
Hyperbolic Cosine cosh(x) CosineH
Hyperbolic Tangent tanh(x) TanH
Inverse Hyperbolic Sine asinh(x) ArcSineH
Inverse Hyperbolic Cosine1 acosh(x) ArcCosineH
Inverse Hyperbolic Tangent1 atanh(x) ArcTanH

Log and Exponential Functions

All functions accept arguments of the Double and Complex types.

Description Function Name Class Name
Natural Logarithm1 ln(x) NaturalLogarithm
Logarithm base 101 log(x) Logarithm
Logarithm base 21 lg(x) LogBase2
Exponential (e^x) exp(x) Exp
Power1 pow(x) Power

Statistical Functions

All functions accept either a vector (e.g. min([1,2,3])) or a set of numbers (e.g. min(1,2,3)).

Description Function Name Class Name
Average avg(x1,x2,x3,...) Average
Minimum min(x1,x2,x3,...) MinMax(true)
Maximum max(x1,x2,x3,...) MinMax(false)
Vector Sum vsum(x1,x2,x3,...) VSum

Rounding Functions

Description Function Name Class Name
Round round(x), round(x, p) Round
Round to integer rint(x), rint(x, p) RInt
Floor floor(x) Floor
Ceiling ceil(x) Ceil

Miscellaneous Functions

Description Function Name Class Name
If if(cond, trueval, falseval) If
Str (convert number to string) str(x) Str
Absolute Value / Magnitude abs(x) Abs
Random number
(between 0 and 1)
rand() Random
Modulus mod(x,y)
= x % y
Square Root1 sqrt(x) SquareRoot
Sum sum(x,y,...) Sum
Binomial coefficients binom(n, i) Binomial
(-1,0,1 depending on sign of argument)
signum(x) Signum

Complex Functions

Description Function Name Class Name
Real Component re(c) Real
Imaginary Component im(c) Imaginary
Complex Modulus (Absolute Value) cmod(c) Abs
Argument (Angle of complex value, in radians) arg(c) Arg
Complex conjugate conj(c) Conjugate
Complex, constructs a complex number from real and imaginary parts complex(x, y) ComplexPFMC
Polar, constructs a complex number from modulus and argument polar(r, theta) Polar


1 By default functions like sqrt(-1) will return a complex result. These functions have constructors with a flag to control their behaviour for out of range values, if the flag is true, then the function will return Double.NaN for out of range real values. If the flag is false they will return the appropriate complex result.

2 By default functions like acos(2) will return Double.NaN. A constructor is available which sets a flag to make the function return the appropriate complex result for such cases.


String Functions

The following string functions are not included in the standard configuration. They can however be added by loading the StringFunctionSet component using jep.setComponent(new StringFunctionSet()) before parsing expressions. The individual functions can also be added using jep.addFunction().

Description Function Name Class Name
Left left(str, len) Left
Right right(str, len) Right
Middle mid(str, start, len) Mid
Substring substr(str, start, [end]) Substring
Lower Case lower(str) LowerCase
Upper Case upper(str) UpperCase
Length len(str) Length
Trim trim(str) Trim

Optional Functions

These functions are not included in the standard configuration, but can be added using jep.addFunction().

In com.singularsys.jep.misc.functions:

Class Description
LogTwoArg Two argument log function where second argument is the base.
Remainder Calculates the remainder and quotient the arguments. Constructors allow different conventions for remainder to be used.
RoundSF Rounds arguments to a specific number of significant figures.
ToBase Converts numbers to a string in a given base.
FromBase Converts a string in a given base to numbers.
Switch A switch statement. Returns the value of the argument based on the value of the first argument.
SwitchDefault A switch statement with a default value as final argument.
Case A case statement, first argument is test condition, following arguments are in pairs with a test value and corresponding result.
ElementOf Tests if the first argument is and element of a set given by subsequent arguments.
IsNull Tests if the argument is null.
IsNaN Tests if the argument is NaN.
IsInfinite Tests if the argument is infinite.
IsType Test is the argument is of the type specifies in the constructor. E.g. isDouble(x)
ConstantFunction Returns a constant specified in the constructor. E.g. pi()
Factorial A simple factorial implementation good upto 20!

In com.singularsys.jep.functions:

Class Description
Identity Returns its argument.

In com.singularsys.jep.misc.threadsafeeval:

Class Description
ThreadSafeEle Threadsafe version of the element of operator.
ThreadSafeAssign Threadsafe version of the assignment operator.
ThreadSafeRandom Version of the random function with better performance in a multi-threaded environment.

These functions and operators work better in a multi threaded environment. See Threads documentation for details.