#
Arithmetic Array Operators

Arithmetic operators on arrays and certain combinations of arrays and scalars are available through the standard arithmetic operators, addition (+), subtraction (-), division (/), multiplication as well as through the exponentiation (^) operator.

##
1
Addition and Subtraction

Strangely enough, elementwise operations for the combination of an array and a scalar operand are defined for multiplication and division but not for addition and subtraction.

Try interactive:

###
1.1
Simulation of AddSub and AddSub2

When we try to simulate AddSub, it does not work since different array sizes are not allowed in Addition operand

Look at results:

##
2
Division

###
2.1
Simulation of Div and Div2

##
3
Multiplication

The array multiplication operator is only defined for vectors and matrices and has several different definitions depending on the type of its arguments. If both operands are vectors then array multiplication means scalar product, otherwise, if the operands are vectors or matrices then it means matrix multiplication. If one of the operands is a scalar, then the multiplication operation is defined as elementwise multiplication, which however is not available when both operands are arrays despite the fact that analogous elementwise operations are defined for addition and subtraction. The reason is that we have already used the multiplication notation (*) for the more common operation of matrix multiplication.

###
3.1
Simulation of Multiplication

##
4
Exponentiation

Array exponentiation is the same as repeated matrix multiplication and is therefore only defined when the first operand is a square matrix and the second operand is a non-negative integer.

###
4.1
Simulation of Exponentiation