1. Introduction2. Syntax of the OVi expressions
2.1. The general format of inputs3. The basic functions
2.2. The set of operators
2.3. Operator precedence
2.4. Variable names3.1. Trigonometric functions4. A note on symbolic differentation
3.2. Transcendental functions
3.3. Macros
This document describes only the most important features of AlgObj.
On SGI's the system handles all values as 64-bit IEEE "double" floating point numbers. The machine dependant constants are thus:
Smallest number above zero: 2.225 * 10-308It is not adviced to choose epsilon values smaller than 10-6 in the optimization algorithms.
Greatest number: 1.7977 * 10308
Average number of significant decimal digits: 15.6
As you can see the input looks pretty much like some higher level language like Basic or C. This is not a coincidence; we have tried to design the input syntax to follow the "common" rules so that most users (who are usually familiar with at least some programming language) would not even have to refer to help pages like this.
The above expression assigns the expression
to the default function symbol. You can also excplicitely enter the prefix fx = in the expressions if you want. In any case, whenever the value of x changes, the objective function will change correspondingly.
+ Addition: a + bThe differentation operator is discussed in the chapter "A note on symbolic differentation".
- Substraction (as in a - b) or negation (as in -a )
* Multiplication: a * b
/ Division: a / b
^ Power: a ^ b
= Assignment: a = b
? Conditional: ? ( a, b, c ) D Differentation operator: D(fx, x)
This set is pretty much the same as in the C programming language, apart from the adaptation of ^ sign to mean power. There are no exclusive-or or other bit-manipulation operators in OVi.
The other curiosity is the ? - operator. It has the same principial function as the ? - operator of "C", but the syntax is totally different. It can be used to construct complex conditional or discontinuous expressions. The operation of
is basically the same as of
in C. That is; either one of the last two parameters is chosen depending on the sign of the first parameter. You can recursively insert two or more ? -operators. The common discontinuous functions max, min, abs and sgn have been predefined as macros which internally use the ? - operator. See Functions.
1. R1 -> R1 predefined functions: abs(kissa), sin x ..
2. The power operator: 2^x
3. Multiplication and division: x*y, x/y
4. Addition and substraction: x+y, x-y
5. Negation operator: -x
6. Parenthesies: (x)
7. Differentiation operator: D(fx, x)
8. Conditional operators: max(x, y), min(x, y), ?(x, y, z)
9. The equation (assignment) sign: x=y
This means that the operators in group 3 have priority over the groups 4 to 9 but not over groups 1 and 2. The operators within the same group have equal priorities and are interpreted in the input (left to right) order.
Do not be afraid if this looks complicated; the operator precedence in OVi follows the common grammar school rules. Example:
Of course you are free to use an arbitary number of parenthesies to clear up or override the precedence whenever you want to.
- The fist character of a variable name must be one of a..z, A..Z or { _ @ $ # }.You do not have to explicitely declare a variable; variables are automatic.
- There can be no spaces within a variable name (this is not Fortran!)
- The characters after the first one can be alphabetic characters, numbers (0..9) or one of { _ @ $ # }.
sin ( x )All of the trigonometric functions operate in radians rather than degrees.
cos ( x )
tan ( x )
arcsin ( x )
arccos ( x )
arctan ( x )
exp ( x )These functions work in natural base (2.7183..). As OVi only operates with real numbers, an attempt of taking a logarithm from a negative number will cause a error message to be displayed.
ln ( x )
sqr ( x )All of these functions have been implemented as predefined macros.
abs ( x )
sgn ( x )
max ( x, y )
min ( x, y )
sqr x returns the square root of x.Note: max and min only accept exactly two parameters, but there is a way to generalize this: you can write something like max ( max(a, b), c ) to get the greatest of three numbers.
abs x returns the absolute value of x.
sgn x returns the sign of x. The sign is -1 for all negative x and +1 othervise.
max (x, y) returns the greater of x and y (parentheses are compulsory).
min (x, y) returns the smaller of x and y (parentheses are compulsory).
If the user wishes to enter a function's derivate as a parameters, he can use the D-operator for this. The syntax of the D-operator is:
This expression will result in a function which has the value of dy/dx. That is, the first parameter is the function to be differentiated and the second parameter is the name of the "reference" variable.