# 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:

Operator | Description | Example | Priority |
---|---|---|---|

`=` | Assignment | `x = 5` sets the value of `x` to 5 | 0 |

`<=` | Less or equal | `x <= y` means that `x` is less than or equal to `y` | 1 |

`>=` | Greater or equal | `x >= y` means that `x` is greater than or equal to `y` | 1 |

`+` | Addition | `2 + 3` evaluates to `5` | 2 |

`-` | Subtraction | `5 - 2` evaluates to `3` | 2 |

`*` | Multiplication | `2 * 3` evaluates to `6` | 3 |

`/` | Division | `6 / 3` evaluates to `2` | 3 |

`^` | Raise x to the power of y | `7 ^ 2` evaluates to `49` | 4 |

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.

NoteThe 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:

Function | Arguments | Description | Example |
---|---|---|---|

`exp(x)` | 1 | Exponential function, e^x | `exp(1)` evaluates to `2.71828` |

`log(x)` | 1 | Natural logarithm of x | `log(10)` evaluates to `1` |

`log2(x)` | 1 | Base 2 logarithm of x | `log2(100)` evaluates to `6.64386` |

`log10(x)` | 1 | Base 10 logarithm of x | `log10(100)` evaluates to `2` |

`ln(x)` | 1 | Base e logarithm of x | `ln(10)` evaluates to `2.30258` |

`sqrt(x)` | 1 | Square root of `x` | `sqrt(16)` evaluates to `4` |

`sign` | 1 | sign function -1 if `x<0` ; 1 if `x>0` | `sign(-3)` evaluates to `-1` |

`rint` | 1 | round to nearest integer | `rint(3.4)` evaluates to `3` |

`abs` | 1 | absolute value | `abs(-4)` evaluates to `4` |

`min` | var. | min of all arguments | `min(2, 3, 1)` evaluates to `1` |

`max` | var. | max of all arguments | `max(2, 3, 1)` evaluates to `3` |

`sum` | var. | sum of all arguments | `sum(2, 3, 1)` evaluates to `6` |

`avg` | var. | mean value of all arguments | `avg(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):

Constant | Description | Remarks |
---|---|---|

`_pi` | The one and only pi | 3.141592653589793238462643 |

`_e` | Euler's number | 2.718281828459045235360287 |

## Trigonometric Functions

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

Function | Arguments | Description | Example |
---|---|---|---|

`sin(x)` | 1 | Sine of x, where x is in radians | `sin(_pi/2)` evaluates to `1` |

`cos(x)` | 1 | Cosine of x, where x is in radians | `cos(0)` evaluates to `1` |

`tan(x)` | 1 | Tangent of x, where x is in radians | `tan(_pi/4)` evaluates to `1` |

`asin(x)` | 1 | Arcsine of x, where x is in radians | `asin(1)` evaluates to `_pi/2` |

`acos(x)` | 1 | Arccosine of x, where x is in radians | `acos(0)` evaluates to `_pi/2` |

`atan(x)` | 1 | Arctangent of x, where x is in radians | `atan(1)` evaluates to `_pi/4` |

`sinh(x)` | 1 | Hyperbolic sine of x, where x is in radians | `sinh(2) = (_e^2 - _e^(-2))/2` evaluates to `~3.62686` |

`cosh(x)` | 1 | Hyperbolic cosine of x, where x is in radians | `cosh(3) = (_e^3 + _e^(-3))/2` evaluates to `~10.0677` |

`tanh(x)` | 1 | Hyperbolic tangent of x, where x is in radians | `tanh(1) = (_e^1 - _e^(-1)) / (_e^1 + _e^(-1))` evaluates to `~0.761594` |

`asinh(x)` | 1 | Hyperbolic arcsine of x, where x is in radians | `arcsinh(2) = ln(2 + sqrt(2^2 + 1))` evaluates to `~1.44364` |

`acosh(x)` | 1 | Hyperbolic arccosine of x, where x is in radians | `arccosh(3) = ln(3 + sqrt(3^2 - 1))` evaluates to `~1.76275` |

`atanh(x)` | 1 | Hyperbolic arctangent of x, where x is in radians | `arctanh(0.5) = (1/2) * ln((1 + 0.5) / (1 - 0.5))` evaluates to `~0.549306` |