Composing Algebraic Expressions in TSP

In general, TSP rules for formulas are similar to Fortran or other scientific programming languages.

A lag is indicated by putting an integer or a name in parentheses after a series name. The integer is negative for lags and positive for leads. A + sign is not necessary for leads. If the lag or lead is a name, it must have no more than four characters.

A series may have a single numeric or variable subscript (or lag/lead). A matrix may have a single or double subscript (numeric or variable). See the SET command for detailed rules and examples.

Arithmetic operators are:

+

add

-

subtract

*

multiply

/

divide

** or ^

raise to the power

See TSP Functions for a detailed list of functions and the MATRIX command for matrix functions.

Relational and logical operators are the following:

Operator

.OP.

Description

=

.EQ.

gives the value 1 when the variables on the left and on the right are equal; otherwise it is zero

~= or ^=

.NE.

gives the value 1 when the variables on the left and on the right are not equal; otherwise it is zero

<

.LT.

gives the value 1 when the variable on the left is less than the variable on the right; otherwise it is zero

>

.GT.

gives the value 1 when the variable on the left is greater than the variable on the right; otherwise it is zero

<=

.LE.

gives the value 1 when the variable on the left is less than or equal to the variable on the right; otherwise it is zero

>=

.GE.

gives the value 1 when the variable on the left is greater than or equal to the variable on the right; otherwise it is zero

&

.AND.

gives the value 1 when both the variable on the left and on the right are positive

|

.OR.

gives the value 1 when both the variable on the left and on the right are positive

~ or ^

.NOT.

gives the value 1 when the variable on the right is negative or zero

Note: the .OP. form of the relational and logical operators is the alternative to the symbolic notation (but it cannot be used in nested DOT loops).

As many parentheses as necessary may be used to indicate the order of evaluation of a formula. The special parentheses [] and {} are treated as (). In the absence of parentheses, evaluation proceeds from left to right in the following order:

1

Functions

2

Exponentiation (**)

3

Multiplication and division

4

Addition, subtraction, and negation (unary -)

5

Relational operators

6

.NOT. (~)

7

.AND. (&) and .OR. (|)