# Arithmetic Operations

Addition, subtraction, multiplication, division, power, rounding

Arithmetic functions include operators for simple operations like addition and multiplication, as well as functions for common calculations like summation, moving sums, modulo operations, and rounding.

## Functions

expand all

 `+` Add numbers, append strings `sum` Sum of array elements `cumsum` Cumulative sum `movsum` Moving sum

#### Subtraction

 `-` Subtraction `diff` Differences and approximate derivatives

#### Multiplication

 `.*` Multiplication `*` Matrix multiplication `prod` Product of array elements `cumprod` Cumulative product `pagemtimes` Page-wise matrix multiplication (Since R2020b) `tensorprod` Tensor products between two tensors (Since R2022a)

#### Division

 `./` Right array division `.\` Left array division `/` Solve systems of linear equations xA = B for x `\` Solve systems of linear equations Ax = B for x `pagemldivide` Page-wise left matrix divide (Since R2022a) `pagemrdivide` Page-wise right matrix divide (Since R2022a)

#### Powers

 `.^` Element-wise power `^` Matrix power

#### Transpose

 `.'` Transpose vector or matrix `'` Complex conjugate transpose `pagetranspose` Page-wise transpose (Since R2020b) `pagectranspose` Page-wise complex conjugate transpose (Since R2020b)

#### Array Sign

 `uminus` Unary minus `uplus` Unary plus
 `mod` Remainder after division (modulo operation) `rem` Remainder after division `idivide` Integer division with rounding option `ceil` Round toward positive infinity `fix` Round toward zero `floor` Round toward negative infinity `round` Round to nearest decimal or integer
 `bsxfun` Apply element-wise operation to two arrays with implicit expansion enabled

## Topics

• Array vs. Matrix Operations

Matrix operations follow the rules of linear algebra, and array operations execute element by element operations and support multidimensional arrays. The period character (`.`) distinguishes the array operations from the matrix operations.

• Compatible Array Sizes for Basic Operations

Most binary operators and functions in MATLAB® support numeric arrays that have compatible sizes. Two inputs have compatible sizes if, for every dimension, the dimension sizes of the inputs are either the same or one of them is 1.

• Operator Precedence

Precedence rules determine the order in which MATLAB evaluates an expression.

• Floating-Point Numbers

MATLAB represents floating-point numbers in either double-precision or single-precision format. The default is double precision.

• Integers

MATLAB supports 1-, 2-, 4-, and 8-byte storage for integer data. If you use the smallest integer type that accommodates your data, you can save memory and program execution time.