# Mathematical Expressions in SYMB

The following mathematical operations are available in SYMB:

• COS
• SIN
• TAN
• EXP
• ALOG
• ALOG10
• ACOS
• ASIN
• ATAN
• ATAN2
• SQRT
• ABS
• SIGN
• INT
• NINT
• MAX
• MIN
• **
• *
• /
• +
• -

Parentheses may be used to control the sequence in which the expression is evaluated (innermost parentheses evaluated first). Within parentheses, the evaluation is done from left to right for each operator listed above in the order listed.

The real number equivalence of all arguments to COS, SIN, TAN, EXP, ALOG, ALOG10, ACOS, ASIN, ATAN, ATAN2, SQRT, ABS, INT, and NINT are used.

Note that Symbol does not allow a real expression in which a negative number is taken to an exponential power (even the power of 2), as the real number representation of the exponent is used in the expression and math libraries do not allow this operation. Multiple arguments may be provided to the MAX,  MIN, ATAN2, and SIGN functions.

These arguments must be separated by commas (which are themselves blank delimited) and be bounded by parentheses.

Examples of all these operations are provided in this sample file:

Basic Operations:

```c ********** basic operations **********
symb x = 1 + 2    /* x = 3
c subtraction
symb x = 5 - 3    /* x = 3
c multiplication
symb x = 2 * 3    /* x = 6
c division
symb x = 10 / 2   /* x = 5
c power
symb x = 2 ** 2   /* x = 4```

Multiplication & Division:

```c multiplications and divisions are performed before additions and subtractions
symb x = 2 + 1 * 3       /* x = 5
symb x = 9 / 3 - 1 * 2   /* x = 1
c real numbers are defined with the use of a decimal point after the value
symb x = 4               /* x = 4 (integer)
symb x = 4.              /* x = 4 (real)
c if all arguments are integer then integer arithmetic is performed
symb x = 10 / 50         /* x = 0
symb x = 20 / 3          /* x = 6
c if arguments are real or a mix between real and integer, the result is real
symb x = 10. / 50        /* x = 0.2
symb x = 10 / 50.        /* x = 0.2
symb x = 10. / 50.       /* x = 0.2
symb x = 20. / 3         /* x = 6.666667
symb x = 20 / 3.         /* x = 6.666667
symb x = 20. / 3.        /* x = 6.666667```

```c ********** cos **********symb x = cos ( 0 )       /* x = 1
symb x = cos ( 3.14 )    /* x = -0.9999987```

```c ********** sin **********symb x = sin ( 0 )        /* x = 0
symb x = sin ( 3.14 / 2 ) /* x = 0.9999997```

```c ********** tan **********symb x = tan ( 0 )        /* x = 0
symb x = tan ( 3.14 )     /* x = -0.1592550e-02```

Exponential:

```c ********** exp **********symb x = exp ( 1 )        /* x = 2.718282
symb x = exp ( -2 )       /* x = 0.1353353```

Natural Logarithm:

```c ********** alog **********symb x = alog ( 10 ) /* x = 2.302585
symb x = alog ( 0.1 ) /* x = -2.302585</em```

Logarithm Base 10:

```c ********** alog10 **********symb x = alog10 ( 10 ) /* x = 1
symb x = alog10 ( 0.1 ) /* x = -1```

```c ********** asin **********symb x = asin ( 0.1 ) /* x = 0.1001674
symb x = asin ( 1 ) /* x = 1.570796```

```c ********** atan **********symb x = atan ( 0.1 ) /* x = 0.9966865e-01
symb x = atan ( 1 ) /* x = 0.7853982
c atan can be used to calculate value of pi
symb pi = 4 * atan ( 1 ) /* pi = 3.141593```

```c ********** atan2 **********symb x = atan2 ( 0.1 , 10 ) /* x = 0.9999667e-02
symb x = atan2 ( -1 , 4 ) /* x = -0.2449787```

Square Root:

```c ********** sqrt **********symb x = sqrt ( 9 ) /* x = 3
symb x = sqrt ( 20 ) /* x = 4.472136```

Absolute Value:

```c ********** abs **********symb x = abs ( 5 ) /* x = 5
symb x = abs ( -2 ) /* x = 2```

Sign of a Real or Complex Number:

```c ********** sign **********symb x = sign ( 1 , 1 ) /* x = 1
symb x = sign ( 1 , -1 ) /* x = -1
symb x = sign ( -1 , -1 ) /* x = -1
symb x = sign ( -1 , 1 ) /* x = 1```

Rounding Down to the Next Integer:

```c ********** int **********symb x = int ( 1.2 ) /* x = 1
symb x = int ( 1.5 ) /* x = 1
symb x = int ( 1.8 ) /* x = 1```

Rounding to the Nearest Integer:

```c ********** nint **********symb x = nint ( 1.2 ) /* x = 1
symb x = nint ( 1.5 ) /* x = 2
symb x = nint ( 1.8 ) /* x = 2```

Maximun of Numbers:

```c ********** max **********symb x = max ( 1 , 4 , 10 ) /* x = 10
symb x = max ( -5 , 0.2 ) /* x = 0.2```

Minimum of Numbers:

```c ********** min **********symb x = min ( 1 , 4 , 10 ) /* x = 1
symb x = min ( -5 , 0.2 ) /* x = -5```
0 out of 0 found this helpful