## Arithmetic and Mathematical Operations

This page lists the built-in methods and operators for applying arithmetic or other mathematical operations. For both static methods and operators, you can often pass in random variables as arguments e.g. Variable<double> instead of double. For compactness, this is not shown in the syntax below.

These methods provide a convenient short alternative to using Variable<T>.Factor and passing in the factor method, as described on this page

#### Arithmetic Operations

Arithmetic operations are supported via operator overloads or static methods.

 Operation Syntax Description Plus (double) a + b Creates a double random variable equal to the sum of a and b. Plus (int) a + b Creates an int random variable equal to the sum of a and b. Minus a - b Creates a double random variable equal to the difference of a and b. Times a * b Creates a double random variable equal to  the product of a and b. Divide a / b Creates a double random variable equal to  the ratio of a to b. Sum of elements Variable.Sum(double[] array)Variable.Sum(IList array) Creates a double random variable equal to  the sum of the elements of the array.

#### Mathematical Operations

Mathematical operations are supported via static methods.

 Operation Syntax Description Exp Variable.Exp(double exponent) Creates a double random variable which takes e to the power of exponent. Logistic Variable.Logistic(double x) Creates a double random variable equal to 1/(1+exp(-x)). Max Variable.Max(double a, double b) Creates a double random variable equal to the maximum of a and b. Softmax Variable.Softmax(double[] x) Creates a Vector random variable y where y[i] = exp(x[i])/(sum_j exp(x[j])).