math#

gamspy.math.cos(x: int | float | Symbol) Expression[source]#

Cosine of x.

Returns:
Expression
gamspy.math.cosh(x: int | float | Symbol) Expression[source]#

Hyperbolic cosine of x.

Returns:
Expression
gamspy.math.sin(x: float | Symbol) Expression[source]#

Sine of x.

Returns:
Expression
gamspy.math.sinh(x: float | Symbol) Expression[source]#

Hyperbolic sine of x.

Returns:
Expression
gamspy.math.acos(x: float | Symbol) Expression[source]#

Inverse cosine of x.

Returns:
Expresion | float
gamspy.math.asin(x: float | Symbol) Expression[source]#

Inver sinus of x.

Returns:
Expression
gamspy.math.tan(x: float | Symbol) Expression[source]#

Tangent of x.

Returns:
Expression
gamspy.math.tanh(x: float | Symbol) Expression[source]#

Hyperbolic tangent of x.

Returns:
Expression
gamspy.math.atan(x: float | Symbol) Expression[source]#

Inverse tangent of x.

Returns:
Expression
gamspy.math.atan2(y: int | float | Symbol, x: int | float | Symbol) Expression[source]#

Four-quadrant arctan function

Returns:
Expression
gamspy.math.exp(x: float | Symbol) Expression[source]#

Exponential of x (i.e. e^x)

Returns:
Expression
gamspy.math.power(base: float | Symbol, exponent: float | Symbol) Expression[source]#

Base to the exponent power (i.e. base ^ exponent)

Parameters:
basefloat | Symbol
exponentfloat | Symbol
Returns:
Expression
gamspy.math.sqr(x: float | Symbol) Expression[source]#

Square of x

Parameters:
xfloat | Symbol
Returns:
Expression
gamspy.math.sqrt(x: int | float | Symbol) Expression[source]#

Square root of x

Returns:
Expression
gamspy.math.log(x: int | float | Symbol) Expression[source]#

Natural logarithm of x (i.e. logarithm base e of x)

Returns:
Expression
gamspy.math.log2(x: float | Symbol) Expression[source]#

Binary logarithm (i.e. logarithm base 2 of x)

Returns:
Expression
gamspy.math.log10(x: float | Symbol) Expression[source]#

Common logarithm (i.e. logarithm base 10 of x)

Returns:
Expression
gamspy.math.log_beta(x: int | float | Symbol, y: int | float | Symbol) Expression[source]#

Log beta function

Returns:
Expression
gamspy.math.log_gamma(x: int | float | Symbol, y: int | float | Symbol) Expression[source]#

Log gamma function

Returns:
Expression
gamspy.math.logit(x: int | float | Symbol) Expression[source]#

Natural logarithm of x (i.e. logarithm base e of x)

Returns:
Expression
gamspy.math.abs(x: int | float | Symbol) Expression[source]#

Absolute value of x (i.e. |x|)

Returns:
Expression
gamspy.math.ceil(x: int | float | Symbol) Expression[source]#

The smallest integer greater than or equal to x

Returns:
Expression
gamspy.math.dist(x1: tuple[int, float] | Symbol, x2: tuple[int, float] | Symbol) Expression[source]#

L2 norm

Returns:
Expression
Raises:
Exception

In case both x1 and x2 are not a tuple or none.

gamspy.math.div(dividend: int | float | Symbol, divisor: int | float | Symbol) Expression[source]#

Dividing operation

Parameters:
dividendint | float | Symbol
divisorint | float | Symbol
Returns:
Expression
gamspy.math.div0(dividend: int | float | Symbol, divisor: int | float | Symbol) Expression[source]#

Dividing operation

Parameters:
dividendint | float | Symbol
divisorint | float | Symbol
Returns:
Expression
gamspy.math.factorial(x: int | Symbol) Expression[source]#

Factorial of x

Returns:
Expression
gamspy.math.floor(x: int | float | Symbol) Expression[source]#

The greatest integer less than or equal to x

Returns:
Expression
gamspy.math.fractional(x: int | float | Symbol) Expression[source]#

Returns the fractional part of x

Returns:
Expression
gamspy.math.Min(*values) Expression[source]#

Minimum value of the values, where the number of values may vary.

Returns:
Expression
gamspy.math.Max(*values) Expression[source]#

Maximum value of the values, where the number of values may vary.

Returns:
Expression
gamspy.math.mod(x: float | Symbol, y: float | Symbol) Expression[source]#

Remainder of x divided by y.

Returns:
Expression
gamspy.math.Round(x: float | Symbol, num_decimals: int = 0) Expression[source]#

Round x to num_decimals decimal places.

Parameters:
xfloat | Symbol
decimalint, optional
Returns:
Expression
gamspy.math.sign(x: Symbol) Expression[source]#

Sign of x returns 1 if x > 0, -1 if x < 0, and 0 if x = 0

Parameters:
xSymbol
Returns:
Expression
gamspy.math.binomial(n: int | float | Symbol, k: int | float | Symbol) Expression[source]#

(Generalized) Binomial coefficient for n > -1, -1 < k < n + 1

Parameters:
nint | float | Symbol
kint | float | Symbol
Returns:
Expression
gamspy.math.centropy(x: int | float | Symbol, y: int | float | Symbol, z: float = 1e-20) Expression[source]#

Cross-entropy. x . ln((x + z) / (y + z)

Parameters:
xfloat | Symbol
yfloat | Symbol
zfloat, optional
Returns:
Expression
Raises:
ValueError

if z is smaller than 0

gamspy.math.normal(mean: int | float, dev: int | float) Expression[source]#

Generate a random number from the normal distribution with mean mean and standard deviation dev.

Parameters:
meanint | float
devint | float
Returns:
Expression
gamspy.math.uniform(lower_bound: float | Expression, upper_bound: float | Expression) Expression[source]#

Generates a random number from the uniform distribution between lower_bound and higher_bound

Parameters:
lower_boundfloat
upper_boundfloat
Returns:
Expression
gamspy.math.uniformInt(lower_bound: int | float, upper_bound: int | float) Expression[source]#

Generates an integer random number from the discrete uniform distribution whose outcomes are the integers between lower_bound and higher_bound.

Parameters:
lower_boundint | float
upper_boundint | float
Returns
——-
Expression
gamspy.math.cv_power(base: float | Symbol, exponent: float | Symbol) Expression[source]#

Real power (i.e. base ^ exponent where X >= 0)

Parameters:
basefloat | Symbol
exponentfloat | Symbol
Returns:
Expression
gamspy.math.rpower(base: float | Symbol, exponent: float | Symbol)[source]#

Returns x^y for x > 0 and also for x = 0 and restricted values of y

Parameters:
basefloat | Symbol
exponentfloat | Symbol
Returns:
Expression
gamspy.math.sign_power(base: float | Symbol, exponent: float | Symbol)[source]#

Signed power for y > 0.

Parameters:
basefloat | Symbol
exponentfloat | Symbol
Returns:
Expression
gamspy.math.sllog10(x: int | float | Symbol, S: int | float = 1e-150) Expression[source]#

Smooth (linear) logarithm base 10

Parameters:
xint | float | Symbol
Sint | float, by default 1.0e-150
Returns:
Expression
gamspy.math.sqlog10(x: int | float | Symbol, S: int | float = 1e-150) Expression[source]#

Smooth (quadratic) logarithm base 10

Parameters:
xint | float | Symbol
Sint | float, by default 1.0e-150
Returns:
Expression
gamspy.math.vc_power(base: float | Symbol, exponent: float | Symbol)[source]#

Returns x^y for x >= 0

Parameters:
basefloat | Symbol
exponentfloat | Symbol
Returns:
Expression
gamspy.math.slexp(x: int | float | Symbol, S: int | float = 150) Expression[source]#

Smooth (linear) exponential

Parameters:
xint | float | Symbol
Sint | float, by default 150
Returns:
Expression
gamspy.math.sqexp(x: int | float | Symbol, S: int | float = 150) Expression[source]#

Smooth (quadratic) exponential

Parameters:
xint | float | Symbol
Sint | float, by default 150
Returns:
Expression
gamspy.math.truncate(x: int | float | Symbol) Expression[source]#

Returns the integer part of x

Returns:
Expression
gamspy.math.ifthen(condition: Expression, yes_return: float | Expression, no_return: float | Expression) Expression[source]#

If the logical condition is true, the function returns iftrue, else it returns else

Parameters:
conditionExpression
yes_returnfloat | Expression
no_returnfloat | Expression
Returns:
Expression

Examples

>>> from gamspy.math import ifthen
>>> import gamspy as gp
>>> m = gp.Container()
>>> tt = gp.Parameter(m, "tt", records=2)
>>> y = gp.Parameter(m, "y", records=2)
>>> x = ifthen(tt == 2, 3, 4 + y)
gamspy.math.beta(x: int | float | Symbol, y: int | float | Symbol) Expression[source]#

Beta function

Parameters:
xint | float | Symbol
yint | float | Symbol
Returns:
Expression
gamspy.math.regularized_beta(x: int | float, y: int | float, z: int | float) Expression[source]#

Beta function

Parameters:
xint | float
yint | float
zint | float
Returns:
Expression
gamspy.math.gamma(x: int | float | Symbol) Expression[source]#

Gamma function

Parameters:
xint | float
Returns:
Expression
gamspy.math.regularized_gamma(x: int | float, a: int | float) Expression[source]#

Gamma function

Parameters:
xint | float
aint | float
Returns:
Expression
gamspy.math.entropy(x: int | float | Symbol) Expression[source]#

L2 Norm of x

Parameters:
xint | float | Symbol
Returns:
Expression
gamspy.math.lse_max(*xs) Expression[source]#

Smoothed Max via the Logarithm of the Sum of Exponentials

Returns:
Expression
gamspy.math.lse_max_sc(t, *xs) Expression[source]#

Scaled smoothed Max via the Logarithm of the Sum of Exponentials

Returns:
Expression
gamspy.math.lse_min(*xs) Expression[source]#

Smoothed Min via the Logarithm of the Sum of Exponentials

Returns:
Expression
gamspy.math.lse_min_sc(t, *xs) Expression[source]#

Scaled smoothed Min via the Logarithm of the Sum of Exponentials

Returns:
Expression
gamspy.math.ncp_cm(x: Symbol, y: Symbol, z: float | int) Expression[source]#

Chen-Mangasarian smoothing

Parameters:
xSymbol
ySymbol
zint | float
Returns:
Expression
gamspy.math.ncp_f(x: Symbol, y: Symbol, z: int | float = 0) Expression[source]#

Fisher-Burmeister smoothing

Parameters:
xSymbol
ySymbol
zint | float, optional
Returns:
Expression
gamspy.math.ncpVUpow(r: Symbol, s: Symbol, mu: int | float = 0) Expression[source]#

NCP Veelken-Ulbrich: smoothed min(r,s)

Parameters:
rSymbol
sSymbol
muint | float, optional
Returns:
Expression
gamspy.math.ncpVUsin(r: Symbol, s: Symbol, mu: int | float = 0) Expression[source]#

NCP Veelken-Ulbrich: smoothed min(r,s)

Parameters:
rSymbol
sSymbol
muint | float, optional
Returns:
Expression
gamspy.math.poly(x, *args) Expression[source]#

Polynomial function

Returns:
Expression
gamspy.math.rand_binomial(n: int | float, p: int | float) Expression[source]#

Generate a random number from the binomial distribution, where n is the number of trials and p the probability of success for each trial

Parameters:
nint | float
pint | float
Returns:
Expression
gamspy.math.rand_linear(low: int | float, slope: int | float, high: int | float) Expression[source]#

Generate a random number between low and high with linear distribution. slope must be greater than 2 / (high - low)

Parameters:
lowint | float
slopeint | float
highint | float
Returns:
Expression
gamspy.math.rand_triangle(low: int | float, mid: int | float, high: int | float) Expression[source]#

Generate a random number between low and high with triangular distribution. mid is the most probable number.

Parameters:
lowint | float
midint | float
highint | float
Returns:
Expression
gamspy.math.slrec(x: int | float | Symbol, S: int | float = 1e-10) Expression[source]#

Smooth (linear) reciprocal

Parameters:
xint | float | Symbol
Sint | float, by default 1e-10
Returns:
Expression
gamspy.math.sqrec(x: int | float | Symbol, S: int | float = 1e-10) Expression[source]#

Smooth (quadratic) reciprocal

Parameters:
xint | float | Symbol
Sint | float, by default 1e-10
Returns:
Expression
gamspy.math.errorf(x: int | float | Symbol) Expression[source]#

Integral of the standard normal distribution

Parameters:
xint, float, Symbol
Returns:
Expression
gamspy.math.same_as(self: Set | Alias, other: Set | Alias | str) Expression[source]#

Evaluates to true if this set is identical to the given set or alias, false otherwise.

Parameters:
otherSet | Alias
Returns:
Expression
gamspy.math.sigmoid(x: int | float | Symbol) Expression[source]#

Sigmoid of x

Parameters:
xint | float | Symbol
Returns:
Expression
gamspy.math.bool_and(x: int | Symbol, y: int | Symbol) Expression[source]#
gamspy.math.bool_eqv(x: int | Symbol, y: int | Symbol) Expression[source]#
gamspy.math.bool_imp(x: int | Symbol, y: int | Symbol) Expression[source]#
gamspy.math.bool_not(x: int | Symbol) Expression[source]#
gamspy.math.bool_or(x: int | Symbol, y: int | Symbol) Expression[source]#
gamspy.math.bool_xor(x: int | Symbol, y: int | Symbol) Expression[source]#
gamspy.math.rel_eq(x: int | Symbol, y: int | Symbol) Expression[source]#
gamspy.math.rel_ge(x: int | Symbol, y: int | Symbol) Expression[source]#
gamspy.math.rel_gt(x: int | Symbol, y: int | Symbol) Expression[source]#
gamspy.math.rel_le(x: int | Symbol, y: int | Symbol) Expression[source]#
gamspy.math.rel_lt(x: int | Symbol, y: int | Symbol) Expression[source]#
gamspy.math.rel_ne(x: int | Symbol, y: int | Symbol) Expression[source]#