Unless otherwise noted, all of the functions described in this chapter will work for real and complex scalar or matrix arguments.

The following functions are available for working with complex numbers.
Each expects a single argument. They are called **mapping functions**
because when given a matrix argument, they apply the given function to
each element of the matrix.

__Mapping Function:__**ceil***(*`x`)-
Return the smallest integer not less than
`x`. If`x`is complex, return`ceil (real (`

.`x`)) + ceil (imag (`x`)) * I

__Mapping Function:__**floor***(*`x`)-
Return the largest integer not greater than
`x`. If`x`is complex, return`floor (real (`

.`x`)) + floor (imag (`x`)) * I

__Mapping Function:__**fix***(*`x`)-
Truncate
`x`toward zero. If`x`is complex, return`fix (real (`

.`x`)) + fix (imag (`x`)) * I

__Mapping Function:__**round***(*`x`)-
Return the integer nearest to
`x`. If`x`is complex, return`round (real (`

.`x`)) + round (imag (`x`)) * I

__Mapping Function:__**sign***(*`x`)-
Compute the
**signum**function, which is defined asFor complex arguments,

`sign`

returns`x ./ abs (`

.`x`)

__Mapping Function:__**exp***(*`x`)-
Compute the exponential of
`x`. To compute the matrix exponential, see section Linear Algebra.

__Mapping Function:__**gcd***(*`x`,`...`

)-
Compute the greatest common divisor of the elements of
`x`, or the list of all the arguments. For example,gcd (a1, ..., ak)

is the same as

gcd ([a1, ..., ak])

An optional second return value,

`v`contains an integer vector such thatg = v(1) * a(k) + ... + v(k) * a(k)

__Mapping Function:__**lcm***(*`x`,`...`

)-
Compute the least common multiple of the elements elements of
`x`, or the list of all the arguments. For example,lcm (a1, ..., ak)

is the same as

lcm ([a1, ..., ak]).

__Mapping Function:__**log***(*`x`)-
Compute the natural logarithm of
`x`. To compute the matrix logarithm, see section Linear Algebra.

__Mapping Function:__`y`=**log2***(*`x`)__Mapping Function:__[`f`,`e`]**log2***(*`x`)-
Compute the base-2 logarithm of
`x`. With two outputs, returns`f`and`e`such that

__Mapping Function:__**log10***(*`x`)-
Compute the base-10 logarithm of
`x`.

__Mapping Function:__**pow2***(*`x`)__Mapping Function:__**pow2***(*`f`,`e`)-
With one argument, computes
for each element of
`x`. With two arguments, returns

__Function File:__**nextpow2***(*`x`)-
If
`x`is a scalar, returns the first integer`n`such thatIf

`x`is a vector, return`nextpow2 (length (`

.`x`))

__Mapping Function:__**sqrt***(*`x`)-
Compute the square root of
`x`. To compute the matrix square root, see section Linear Algebra.

__Loadable Function:__**max***(*`x`)-
For a vector argument, return the maximum value. For a matrix argument,
return the maximum value from each column, as a row vector. Thus,
max (max (

`x`))returns the largest element of

`x`.For complex arguments, the magnitude of the elements are used for comparison.

__Loadable Function:__**min***(*`x`)-
Like
`max`

, but return the minimum value.

__Mapping Function:__**rem***(*`x`,`y`)-
Return the remainder of

, computed using the expression`x`/`y`x - y .* fix (x ./ y)

An error message is printed if the dimensions of the arguments do not agree, or if either of the arguments is complex.

__Mapping Function:__**xor***(*`x`,`y`)-
Return the `exclusive or' of the entries of
`x`and`y`. For boolean expressions`x`and`y`,`xor (`

is true if and only if either`x`,`y`)`x`or`y`is true.

The following functions are available for working with complex numbers. Each expects a single argument. Given a matrix they work on an element by element basis.

__Mapping Function:__**abs***(*`z`)-
Compute the magnitude of
`z`.

__Mapping Function:__**arg***(*`z`)__Mapping Function:__**angle***(*`z`)-
Compute the argument of
`z`.

__Mapping Function:__**conj***(*`z`)-
Return the complex conjugate of
`z`.

__Mapping Function:__**imag***(*`z`)-
Return the imaginary part of
`z`.

__Mapping Function:__**real***(*`z`)-
Return the real part of
`z`.

Octave provides the following trigonometric functions:

__Mapping Function:__**sin***(*`z`)__Mapping Function:__**cos***(*`z`)__Mapping Function:__**tan***(*`z`)__Mapping Function:__**sec***(*`z`)__Mapping Function:__**csc***(*`z`)__Mapping Function:__**cot***(*`z`)- The ordinary trigonometric functions.

__Mapping Function:__**asin***(*`z`)__Mapping Function:__**acos***(*`z`)__Mapping Function:__**atan***(*`z`)__Mapping Function:__**asec***(*`z`)__Mapping Function:__**acsc***(*`z`)__Mapping Function:__**acot***(*`z`)- The ordinary inverse trigonometric functions.

__Mapping Function:__**sinh***(*`z`)__Mapping Function:__**cosh***(*`z`)__Mapping Function:__**tanh***(*`z`)__Mapping Function:__**sech***(*`z`)__Mapping Function:__**csch***(*`z`)__Mapping Function:__**coth***(*`z`)- Hyperbolic trigonometric functions.

__Mapping Function:__**asinh***(*`z`)__Mapping Function:__**acosh***(*`z`)__Mapping Function:__**atanh***(*`z`)__Mapping Function:__**asech***(*`z`)__Mapping Function:__**acsch***(*`z`)__Mapping Function:__**acoth***(*`z`)- Inverse hyperbolic trigonometric functions.

Each of these functions expect a single argument. For matrix arguments, they work on an element by element basis. For example,

sin ([1, 2; 3, 4]) => 0.84147 0.90930 0.14112 -0.75680

__Mapping Function:__**atan2***(*`y`,`x`)-
Return the arctangent of
`y`/`x`. The signs of the arguments are used to determine the quadrant of the result, which is in the range

__Built-in Function:__**sum***(*`x`)- For a vector argument, return the sum of all the elements. For a matrix argument, return the sum of the elements in each column, as a row vector. The sum of an empty matrix is 0 if it has no columns, or a vector of zeros if it has no rows (see section Empty Matrices).

__Built-in Function:__**prod***(*`x`)- For a vector argument, return the product of all the elements. For a matrix argument, return the product of the elements in each column, as a row vector. The product of an empty matrix is 1 if it has no columns, or a vector of ones if it has no rows (see section Empty Matrices).

__Built-in Function:__**cumsum***(*`x`)-
Return the cumulative sum of each column of
`x`. For example,cumsum ([1, 2; 3, 4]) => 1 2 4 6

__Built-in Function:__**cumprod***(*`x`)-
Return the cumulative product of each column of
`x`. For example,cumprod ([1, 2; 3, 4]) => 1 2 3 8

__Built-in Function:__**sumsq***(*`x`)- For a vector argument, return the sum of the squares of all the elements. For a matrix argument, return the sum of the squares of the elements in each column, as a row vector.

__Mapping Function:__**beta***(*`a`,`b`)- Returns the Beta function,

__Mapping Function:__**betai***(*`a`,`b`,`x`)-
Returns the incomplete Beta function,
If x has more than one component, both

`a`and`b`must be scalars. If`x`is a scalar,`a`and`b`must be of compatible dimensions.

__Mapping Function:__**bincoeff***(*`n`,`k`)-
Returns the binomial coefficient of
`n`and`k`.

__Mapping Function:__**erf***(*`z`)- Computes the error function,

__Mapping Function:__**erfc***(*`z`)-
Computes the complementary error function,
`1 - erf (`

.`z`)

__Mapping Function:__**erfinv***(*`z`)- Computes the inverse of the error function.

__Mapping Function:__**gamma***(*`z`)- Computes the Gamma function,

__Mapping Function:__**gammai***(*`a`,`x`)-
Computes the incomplete gamma function,
If

`a`is scalar, then`gammai (`

is returned for each element of`a`,`x`)`x`and vice versa.If neither

`a`nor`x`is scalar, the sizes of`a`and`x`must agree, and`gammai`is applied element-by-element.

__Mapping Function:__**lgamma***(*`a`,`x`)__Mapping Function:__**gammaln***(*`a`,`x`)- Returns the natural logarithm of the gamma function.

__Function File:__**cross***(*`x`,`y`)-
Computes the vector cross product of the two 3-dimensional vectors
`x`and`y`.

__Function File:__**commutation_matrix***(*`m`,`n`)-
Returns the commutation matrix
$K_{m,n}$
which is the unique
matrix such that
for all
matrices
If only one argument

`m`is given, is returned.See Magnus and Neudecker (1988), Matrix differential calculus with applications in statistics and econometrics.

__Function File:__**duplication_matrix***(*`n`)-
Returns the duplication matrix
which is the unique
matrix such that
for all symmetric
$n \times n$
matrices
See Magnus and Neudecker (1988), Matrix differential calculus with applications in statistics and econometrics.

__Built-in Variable:__**I**__Built-in Variable:__**J**__Built-in Variable:__**i**__Built-in Variable:__**j**-
A pure imaginary number, defined as
The
`I`

and`J`

forms are true constants, and cannot be modified. The`i`

and`j`

forms are like ordinary variables, and may be used for other purposes. However, unlike other variables, they once again assume their special predefined values if they are cleared See section Miscellaneous Utilities.

__Built-in Variable:__**Inf**__Built-in Variable:__**inf**- Infinity. This is the result of an operation like 1/0, or an operation that results in a floating point overflow.

__Built-in Variable:__**NaN**__Built-in Variable:__**nan**-
Not a number. This is the result of an operation like
``0/0'`, or``Inf - Inf'`, or any operation with a NaN.

__Built-in Variable:__**eps**-
The machine precision. More precisely,
`eps`

is the largest relative spacing between any two adjacent numbers in the machine's floating point system. This number is obviously system-dependent. On machines that support 64 bit IEEE floating point arithmetic,`eps`

is approximately

__Built-in Variable:__**pi**-
The ratio of the circumference of a circle to its diameter.
Internally,
`pi`

is computed as``4.0 * atan (1.0)'`.

__Built-in Variable:__**e**- The base of natural logarithms. The constant satisfies the equation

__Built-in Variable:__**realmax**-
The largest floating point number that is representable. The actual
value is system-dependent. On machines that support 64 bit IEEE
floating point arithmetic,
`realmax`

is approximately

__Built-in Variable:__**realmin**-
The smallest floating point number that is representable. The actual
value is system-dependent. On machines that support 64 bit IEEE
floating point arithmetic,
`realmin`

is approximately

Go to the first, previous, next, last section, table of contents.