# Logical and Mathematical Operators

Logical operations are supported and a specific order of precedence is followed.

PREFEKO allows the use of logical operations. It supports the function NOT() that returns TRUE if the argument is FALSE and FALSE when the argument is TRUE. PREFEKO also supports the delimiters >, <, >=, <=, =, <>, AND and OR. When boolean operations are applied to variables, a value of 0 is taken as FALSE and everything else is interpreted as TRUE. Similarly, in the result of a logical operation, FALSE is mapped to 0 and TRUE to 1.

The order of precedence is as follows:
1. single number, expressions in brackets
2. function calls
3. + and - (when used as a sign)
4. ^
5. * and /
6. + and -
7. >, <, >= and <=
8. = and <>
9. AND
10. OR
There are three other special variables #!x, #!y and #!z that are useful for the connection of complex wire structures. The three variables specify the Cartesian coordinates of the end point of the wire segment most recently defined. This enables the correct and easy connection of a straight wire to a curved length of wire, as the next extract from an input file demonstrates:
CL .....
DP   A                        #!x       #!y       #!z
#z = #!z + 0.5
DP   B                        #!x       #!y       #z
BL   A    B

The following example demonstrates the use of variables:
** A dielectric sphere in the field of an incident wave

** Define the variables
#r = 1         **   Radius of the sphere
#betrad = 1    **   Electrical size of the sphere
#epsr = 15     **   The relative dielectric constant
#maxlen = 0.7  **   The maximum edge length

** Define segmentation parameters
IP                                       #maxlen

** The corner points
DP     A                       0         0         0
DP     B                       0         0         #r
DP     C                       #r        0         0

** Select the medium
ME     1    0

** Generate an eighth of the sphere
KU     A    B    C             0         0         90        90        #maxlen

** Use symmetry in all three coordinate planes
**   yz-plane: ideal electrically conducting plane
**   xz-plane: ideal magnetically conducting plane
**   xy-plane: only geometrically symmetric
SY   1    2    3    1

** End of the geometry
EG   1    0    0    0    0

** Assigning the dielectric's properties
DI                             #epsr     1.0

** Incident plane wave excitation
EN