+ - * / ^ % (Arithmetic Operators)

Purpose:

Add/subtract/multiply/divide/exponentiate two expressions.

Syntax:

val1 op val2

val1

-

A scalar, series, or table.

val2

-

A scalar, series, or table.

Returns:

If one or both of the expressions is a series, then a series results. The following is a list of type conversion rules:

 

Integer

op

Integer

yields Integer

Integer

op

Real

yields Real

Integer

op

Series

yields Series

Real

op

Complex

yields Complex

Real

op

Series

yields Series

Complex

op

Real Series

yields Complex Series

 

 

The following arithmetic operators and functions are supported:

 

Operator

Function

Description

+

PLUS

add

-

MINUS

subract

*

TIMES

multiply

/

DIVIDE

bit complement

^

POW

raise to powerr

%

MOD

modulo

Example:

128 + 13.29

 

displays the real result 141.29.

Example:

W1: {1,2,0,4,5)

4 * (W1)

 

multiplies each element of the series by a factor of four and produces the new series {4, 8, 0, 16, 20}.

Example:

-3 ^ 1.8

 

displays -7.224674.

Example:

(-3) ^ 1.8

 

displays the complex result 5.844884 - 4.246557i.

 

Note that the ^ (power) operator has higher precedence than the – (unitary minus) operator.

Example:

12 % 5 returns 2, the remainder when 12 is divided by 5.

Example:

The right divide operator performs division such that

 

a b == b * (1 / a) == b / a

 

For example 10 5 == 5 * (1 / 10) == 5 / 10 == 0.5

Example:

The .* and ./ operators perform standard scalar multiply and divide. For example:

 

a = {3, 6, 9};

b = a .* 3;

c = a ./ 3;

 

b == {9, 18, 27}

c == {1, 2, 3}

Remarks:

The DEFAULT_MATH_VALUE and USE_DEFAULT_MATH_VALUE configuration parameters determine the result of exceptions for operations such as 1/0 and log(0).

 

If USE_DEFAULT_MATH_VALUE is 1, the value specified by DEFAULT_MATH_VALUE is returned.

 

If USE_DEFAULT_MATH_VALUE is 0, the internal exception value determined by the math processor is returned.

 

For example:

 

setconf("DEFAULT_MATH_VALUE", "0.0");

setconf("USE_DEFAULT_MATH_VALUE", "1");

 

a = 1 / 0;

 

setconf("USE_DEFAULT_MATH_VALUE", "0");

 

b = 1 / 0;

 

a == 0.0;

b == inf;

 

 

The ^ operator can return a complex result if the first expression is negative and the second expression has a non-zero fractional part.

 

See *^ (Matrix Multiply) to perform matrix multiplication.

 

See ^^ (Matrix Power) to raise a matrix to a power.

 

See \^ (Matrix Solve) to solve a system of equations.

 

See /^ (Matrix Right Division) to perform matrix right division.

 

See ' (Matrix Transpose) to transpose a matrix.

 

See DADiSP/VectorXL to optimize arithmetic operations on series.

See Also:

Assignment Operators

Conditional Operators

DADiSP/VectorXL

Logical Operators