Skip to main content

Supported Operators and Functions

The Toxeus Cloud Slover (TCS) is a Javascript library that allows you to quickly solve optimization problems or find solutions to systems of nonlinear equations and inequalities. It supports many operators and functions that can be used in your expressions. Here are the supported operators and functions:

Arithmetic Operators

TCS supports the following arithmetic operators:

OperatorDescriptionExamplePriority
=Assignmentx = 5 sets the value of x to 50
<=Less or equalx <= y means that x is less than or equal to y1
>=Greater or equalx >= y means that x is greater than or equal to y1
+Addition2 + 3 evaluates to 52
-Subtraction5 - 2 evaluates to 32
*Multiplication2 * 3 evaluates to 63
/Division6 / 3 evaluates to 23
^Raise x to the power of y7 ^ 2 evaluates to 494

Note 'Priority' here refers to operator precedence, which determines how operators are parsed concerning each other. Operators with higher precedence are evaluated before operators with lower precedence.

Note The assignment operator is special since it changes one of its arguements and can only be applied to variables.

Exponential and Logarithmic Functions

TCS supports the following exponential and logarithmic functions:

FunctionArgumentsDescriptionExample
exp(x)1Exponential function, e^xexp(1) evaluates to 2.71828
log(x)1Natural logarithm of xlog(10) evaluates to 1
log2(x)1Base 2 logarithm of xlog2(100) evaluates to 6.64386
log10(x)1Base 10 logarithm of xlog10(100) evaluates to 2
ln(x)1Base e logarithm of xln(10) evaluates to 2.30258
sqrt(x)1Square root of xsqrt(16) evaluates to 4
sign1sign function -1 if x<0; 1 if x>0sign(-3) evaluates to -1
rint1round to nearest integerrint(3.4) evaluates to 3
abs1absolute valueabs(-4) evaluates to 4
minvar.min of all argumentsmin(2, 3, 1) evaluates to 1
maxvar.max of all argumentsmax(2, 3, 1) evaluates to 3
sumvar.sum of all argumentssum(2, 3, 1) evaluates to 6
avgvar.mean value of all argumentsavg(2, 3, 1) evaluates to 2

Constants

The names of predefined constant names are prefixed with an underscore. TCS has two predefined constants: Pi and Euler's number. The accuracy of the constant definition ultimately depends on the size of the selected value type (float, double, long double):

ConstantDescriptionRemarks
_piThe one and only pi3.141592653589793238462643
_eEuler's number2.718281828459045235360287

Trigonometric Functions

TCS supports the following trigonometric functions. It lists the function names, the number of arguments, a brief description, and an example.

FunctionArgumentsDescriptionExample
sin(x)1Sine of x, where x is in radianssin(_pi/2) evaluates to 1
cos(x)1Cosine of x, where x is in radianscos(0) evaluates to 1
tan(x)1Tangent of x, where x is in radianstan(_pi/4) evaluates to 1
asin(x)1Arcsine of x, where x is in radiansasin(1) evaluates to _pi/2
acos(x)1Arccosine of x, where x is in radiansacos(0) evaluates to _pi/2
atan(x)1Arctangent of x, where x is in radiansatan(1) evaluates to _pi/4
sinh(x)1Hyperbolic sine of x, where x is in radianssinh(2) = (_e^2 - _e^(-2))/2 evaluates to ~3.62686
cosh(x)1Hyperbolic cosine of x, where x is in radianscosh(3) = (_e^3 + _e^(-3))/2 evaluates to ~10.0677
tanh(x)1Hyperbolic tangent of x, where x is in radianstanh(1) = (_e^1 - _e^(-1)) / (_e^1 + _e^(-1)) evaluates to ~0.761594
asinh(x)1Hyperbolic arcsine of x, where x is in radiansarcsinh(2) = ln(2 + sqrt(2^2 + 1)) evaluates to ~1.44364
acosh(x)1Hyperbolic arccosine of x, where x is in radiansarccosh(3) = ln(3 + sqrt(3^2 - 1)) evaluates to ~1.76275
atanh(x)1Hyperbolic arctangent of x, where x is in radiansarctanh(0.5) = (1/2) * ln((1 + 0.5) / (1 - 0.5)) evaluates to ~0.549306