Analytic operators

Codac provides a list of operators for calculating intervals, defining expressions and constructing contractors.

Operators currently available

The following table lists the mathematical operators currently available. The availability is indicated for four operations:
  1. Natural forward evaluation

  2. Centered-form forward evaluation

  3. Differentiation

  4. Backward (reverse) evaluation

When operators are available for operations 2–3, then an AnalyticFunction can be built upon them and the .eval(EvalMode.CENTERED, ...) and .diff(...) methods can be successfully called. When operators are available for operation 4, then analytic contractors such as CtcInverse will work.

Only the operators are supported at the moment. If you notice any mathematical operators missing from the list below, feel free to contribute to the library. You can submit your suggestions or pull requests on the GitHub repository of Codac.

The sources of the operators are available in the operators folder:
List of available operators in Codac

Operator

Syntax

Struct

Operands type

Fwd eval.

Bwd. eval.

Natur.

Centr.

Diff.

Unary operations

\(|x|\)

abs(x)

AbsOp

x: scalar

\(\arccos(x)\)

acos(x)

AcosOp

x: scalar

\(\arcsin(x)\)

asin(x)

AsinOp

x: scalar

\(\arctan(x)\)

atan(x)

AtanOp

x: scalar

\(\lceil x \rceil\)

ceil(x)

CeilOp

x: scalar

\(\cos(x)\)

cos(x)

CosOp

x: scalar

\(\cosh(x)\)

cosh(x)

CoshOp

x: scalar

\(\det(\mathbf{A})\)

det(A)

DetOp

A: matrix

\(\exp(x)\)

exp(x)

ExpOp

x: scalar

\(\lfloor x \rfloor\)

floor(x)

FloorOp

x: scalar

\(\log(x)\)

log(x)

LogOp

x: scalar

\(\mathrm{sgn}(x)\)

sign(x)

SignOp

x: scalar

\(\sin(x)\)

sin(x)

SinOp

x: scalar

\(\sinh(x)\)

sinh(x)

SinhOp

x: scalar

\(x^2\)

sqr(x)

SqrOp

x: scalar

\(\sqrt{x}\)

sqrt(x)

SqrtOp

x: scalar

\(\tan(x)\)

tan(x)

TanOp

x: scalar

\(\tanh(x)\)

tanh(x)

TanhOp

x: scalar

Binary operations

\(x_1+x_2\)

x1+x2

AddOp

x1, x2: scalar

\(\mathbf{x}_1+\mathbf{x}_2\)

x1+x2

x1, x2: vector

\(\mathbf{X}_1+\mathbf{X}_2\)

X1+X2

x1, x2: matrix

\(x_1-x_2\)

x1-x2

SubOp

x1, x2: scalar

\(\mathbf{x}_1-\mathbf{x}_2\)

x1-x2

x1, x2: vector

\(\mathbf{X}_1-\mathbf{X}_2\)

X1-X2

x1, x2: matrix

\(x_1\cdot x_2\)

x1*x2

MulOp

x1, x2: scalar

\(x_1\cdot\mathbf{x}_2\)

x1*x2

x1: scalar, x2: vector

\(\mathbf{x}_1\cdot x_2\)

x1*x2

x1: vector, x2: scalar

\(x_1\cdot\mathbf{X}_2\)

x1*X2

x1: scalar, X2: matrix

\(\mathbf{x}_1\cdot\mathbf{x}_2\)

x1*x2

x1: row, x2: vector

\(\mathbf{X}_1\cdot\mathbf{x}_2\)

X1*x2

X1: matrix, x2: vector

\(\mathbf{X}_1\cdot\mathbf{X}_2\)

X1*X2

X1: matrix, X2: matrix

\(x_1/x_2\)

x1/x2

DivOp

x1, x2: scalar

\(\mathbf{x}_1/x_2\)

x1/x2

X1: vector, x2: scalar

\(\mathbf{X}_1/x_2\)

X1/x2

X1: matrix, x2: scalar

\(\max(x_1,x_2)\)

max(x1,x2)

MaxOp

x1, x2: scalar

\(\min(x_1,x_2)\)

min(x1,x2)

MinOp

x1, x2: scalar

\(x_1\bmod x_2\)

mod(x1,x2)

ModOp

x1, x2: scalar

\((x_1)^{x_2}\)

pow(x1,x2)
x1^x2
x1**x2 (py)

PowOp

x1, x2: scalar

\(\mathrm{arctan2}(y,x)\)

atan2(y,x)

Atan2Op

y, x: scalar

Vectorial / matricial operations

\(x_i\) (vector coeff)

x[i]

ComponentOp

x: vector, i: scalar

\(X_{ij}\) (mat. coeff)

X(i,j)

X: matrix, i, j: scalar

\(\mathbf{x}_{i:j}\) (subvector)

x.subvector(i,j)

SubvectorOp

x: vector expression
i, j: scalar

\([x_1,x_2,\dots]^\intercal\)

vec(x1,x2,...)

VectorOp

x1, ...: scalar

\(\left(\mathbf{x}_1,\mathbf{x}_2,\dots\right)\)

mat(x1,x2,...)

MatrixOp

x1, ...: vector

Note that the operator \(\det\) is only available for \(1\times 1\) and \(2\times 2\) matrices.

Expression involving a non-supported centered-form operation

If an operator, for which the centered form is not defined, is involved in an expression, then this expression cannot be evaluated using the centered form (calculation is disabled for the entire operation). A simple natural evaluation will then be computed.

Direct use of operators

Operators can be used directly without building an AnalyticFunction. They are organized in structures named <OperatorCode>Op and each structure provides .fwd() and .bwd() methods. For example, the operator cos is proposed with:

class CosOp:

  @staticmethod
  def fwd(x1):
    # Default natural forward evaluation
    # ...

  @staticmethod
  def bwd(y, x1):
    # Backward evaluation
    # ...
For the names of available structures, please refer to Table List of available operators in Codac.
An example of use of CosOp is given below:
# Forward evaluation
y = CosOp.fwd([0,PI/2]) # y = [0,1]

# Backward evaluation
x = Interval(0,PI) # prior value of [x]
CosOp.bwd([0,0.5], x) # [x] is contracted to [PI/3,PI/2]