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:
Natural forward evaluation
Centered-form forward evaluation
Differentiation
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.
operators
folder:Operator |
Syntax |
Struct |
Operands type |
Fwd eval. |
Bwd. eval. |
||
---|---|---|---|---|---|---|---|
Natur. |
Centr. |
Diff. |
|||||
Unary operations |
|||||||
\(|x|\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\arccos(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\arcsin(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\arctan(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\lceil x \rceil\) |
|
|
✓ |
✗ |
✗ |
✓ |
|
\(\cos(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\cosh(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\det(\mathbf{A})\) |
|
|
✓ |
✗ |
✗ |
✓ |
|
\(\exp(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\lfloor x \rfloor\) |
|
|
✓ |
✗ |
✗ |
✓ |
|
\(\log(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\mathrm{sgn}(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\sin(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\sinh(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(x^2\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\sqrt{x}\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\tan(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\tanh(x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
Binary operations |
|||||||
\(x_1+x_2\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\mathbf{x}_1+\mathbf{x}_2\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\mathbf{X}_1+\mathbf{X}_2\) |
|
|
✓ |
✗ |
✗ |
✓ |
|
\(x_1-x_2\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\mathbf{x}_1-\mathbf{x}_2\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\mathbf{X}_1-\mathbf{X}_2\) |
|
|
✓ |
✗ |
✗ |
✓ |
|
\(x_1\cdot x_2\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(x_1\cdot\mathbf{x}_2\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\mathbf{x}_1\cdot x_2\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(x_1\cdot\mathbf{X}_2\) |
|
|
✓ |
✗ |
✗ |
✗ |
|
\(\mathbf{x}_1\cdot\mathbf{x}_2\) |
|
|
✓ |
✗ |
✗ |
✓ |
|
\(\mathbf{X}_1\cdot\mathbf{x}_2\) |
|
|
✓ |
✗ |
✗ |
✓ |
|
\(\mathbf{X}_1\cdot\mathbf{X}_2\) |
|
|
✓ |
✗ |
✗ |
✗ |
|
\(x_1/x_2\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\mathbf{x}_1/x_2\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\mathbf{X}_1/x_2\) |
|
|
✓ |
✗ |
✗ |
✗ |
|
\(\max(x_1,x_2)\) |
|
|
✓ |
✗ |
✗ |
✓ |
|
\(\min(x_1,x_2)\) |
|
|
✓ |
✗ |
✗ |
✓ |
|
\(x_1\bmod x_2\) |
|
|
✗ |
✗ |
✗ |
✓ |
|
\((x_1)^{x_2}\) |
pow(x1,x2) x1^x2 x1**x2 (py) |
|
✓ |
✓ |
✓ |
✓ |
|
\(\mathrm{arctan2}(y,x)\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
Vectorial / matricial operations |
|||||||
\(x_i\) (vector coeff) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(X_{ij}\) (mat. coeff) |
|
|
✓ |
✗ |
✗ |
✓ |
|
\(\mathbf{x}_{i:j}\) (subvector) |
|
x : vector expressioni , j : scalar |
✓ |
✓ |
✓ |
✓ |
|
\([x_1,x_2,\dots]^\intercal\) |
|
|
✓ |
✓ |
✓ |
✓ |
|
\(\left(\mathbf{x}_1,\mathbf{x}_2,\dots\right)\) |
|
|
✗ |
✗ |
✗ |
✗ |
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
# ...
struct CosOp
{
// Default natural forward evaluation
static Interval fwd(const Interval& x1);
// Backward evaluation
static void bwd(const Interval& y, Interval& x1);
};
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]
// Forward evaluation
Interval y = CosOp::fwd({0,PI/2}); // y = [0,1]
// Backward evaluation
Interval x(0,PI); // prior value of [x]
CosOp::bwd({0,0.5}, x); // [x] is contracted to [PI/3,PI/2]