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.
@anchor{doc-ceil}
ceil (real (x)) + ceil (imag (x)) * I.
@anchor{doc-exp}
@anchor{doc-fix}
fix (real (x)) + fix (imag (x)) * I.
@anchor{doc-floor}
floor (real (x)) + floor (imag (x)) * I.
@anchor{doc-gcd}
...)
gcd (a1, ..., ak)
is the same as
gcd ([a1, ..., ak])
An optional second return value, v contains an integer vector such that
g = v(1) * a(k) + ... + v(k) * a(k)
@seealso{lcm, min, max, ceil, and floor}
@anchor{doc-lcm}
...)
lcm (a1, ..., ak)
is the same as
lcm ([a1, ..., ak]).
@seealso{gcd, min, max, ceil, and floor}
@anchor{doc-log}
@anchor{doc-log10}
@anchor{doc-log2}
@anchor{doc-max} 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.
If called with two output arguments, also returns the index of the maximum value(s). Thus,
[x, ix] = max([1, 3, 5, 2, 5])
returns x = 5 and ix = 3.
@anchor{doc-min} For a vector argument, return the minimum value. For a matrix argument, return the minimum value from each column, as a row vector. Thus,
min (min (x))
returns the smallest element of x.
For complex arguments, the magnitude of the elements are used for comparison.
If called with two output arguments, also returns the index of the minimum value(s). Thus,
[x, ix] = min ([1, 3, 0, 2, 5])
returns x = 0 and ix = 3.
@anchor{doc-nextpow2}
If x is a vector, return nextpow2 (length (x)).
@anchor{doc-pow2}
@anchor{doc-rem}
x / y, computed using the
expression
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.
@anchor{doc-round}
round (real (x)) + round (imag (x)) * I.
@anchor{doc-sign}
-1, x < 0;
sign (x) = 0, x = 0;
1, x > 0.
For complex arguments, sign returns x ./ abs (x).
@anchor{doc-sqrt}
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. In the descriptions of the following
functions,
z is the complex number x + iy, where i is
defined as sqrt (-1).
@anchor{doc-abs}
sqrt (x^2 + y^2).
For example,
abs (3 + 4i)
=> 5
@anchor{doc-arg}
atan (y/x).
in radians.
For example,
arg (3 + 4i)
=> 0.92730
@anchor{doc-conj}
conj (z) = x - iy.
@anchor{doc-imag}
@seealso{real and conj}
@anchor{doc-real}
Octave provides the following trigonometric functions. Angles are
specified in radians. To convert from degrees to radians multipy by
pi/180
(e.g. sin (30 * pi/180) returns the sine of 30 degrees).
@anchor{doc-sin}
@anchor{doc-cos}
@anchor{doc-tan}
@anchor{doc-sec}
@anchor{doc-csc}
@anchor{doc-cot}
@anchor{doc-asin}
@anchor{doc-acos}
@anchor{doc-atan}
@anchor{doc-asec}
@anchor{doc-acsc}
@anchor{doc-acot}
@anchor{doc-sinh}
@anchor{doc-cosh}
@anchor{doc-tanh}
@anchor{doc-sech}
@anchor{doc-csch}
@anchor{doc-coth}
@anchor{doc-asinh}
@anchor{doc-acosh}
@anchor{doc-atanh}
@anchor{doc-asech}
@anchor{doc-acsch}
@anchor{doc-acoth}
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
@anchor{doc-atan2}
@anchor{doc-sum}
@anchor{doc-prod}
@anchor{doc-cumsum}
@anchor{doc-cumprod}
@anchor{doc-sumsq}
This function is equivalent to computing
sum (X .* conj (X))
but it uses less memory and avoids calling conj if X is real.
@anchor{doc-besselj}
besselj
bessely
besseli
besselk
besselh
If the argument opt is supplied, the result is scaled by the
exp (-I*x) for k = 1 or exp (I*x) for
k = 2.
If alpha is a scalar, the result is the same size as x.
If x is a scalar, the result is the same size as alpha.
If alpha is a row vector and x is a column vector, the
result is a matrix with length (x) rows and
length (alpha) columns. Otherwise, alpha and
x must conform and the result will be the same size.
The value of alpha must be real. The value of x may be complex.
If requested, ierr contains the following status information and is the same size as the result.
NaN.
Inf.
NaN.
NaN.
@anchor{doc-airy}
K Function Scale factor (if a third argument is supplied) -- -------- ---------------------------------------------- 0 Ai (Z) exp ((2/3) * Z * sqrt (Z)) 1 dAi(Z)/dZ exp ((2/3) * Z * sqrt (Z)) 2 Bi (Z) exp (-abs (real ((2/3) * Z *sqrt (Z)))) 3 dBi(Z)/dZ exp (-abs (real ((2/3) * Z *sqrt (Z))))
The function call airy (z) is equivalent to
airy (0, z).
The result is the same size as z.
If requested, ierr contains the following status information and is the same size as the result.
NaN.
Inf.
NaN.
NaN
@anchor{doc-beta}
beta (a, b) = gamma (a) * gamma (b) / gamma (a + b).
@anchor{doc-betainc}
x
/
betai (a, b, x) = beta (a, b)^(-1) | t^(a-1) (1-t)^(b-1) dt.
/
t=0
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.
@anchor{doc-bincoeff}
/ \ | n | n (n-1) (n-2) ... (n-k+1) | | = ------------------------- | k | k! \ /
For example,
bincoeff (5, 2) => 10
@anchor{doc-erf}
z
/
erf (z) = (2/sqrt (pi)) | e^(-t^2) dt
/
t=0
@seealso{erfc and erfinv}
@anchor{doc-erfc}
1 - erf (z).
@seealso{erf and erfinv}
@anchor{doc-erfinv}
@anchor{doc-gamma}
infinity
/
gamma (z) = | t^(z-1) exp (-t) dt.
/
t=0
@seealso{gammai and lgamma}
@anchor{doc-gammainc}
x
1 /
gammainc (x, a) = --------- | exp (-t) t^(a-1) dt
gamma (a) /
t=0
If a is scalar, then gammainc (x, a) is returned
for each element of x and vice versa.
If neither x nor a is scalar, the sizes of x and a must agree, and gammainc is applied element-by-element.
@anchor{doc-lgamma}
@anchor{doc-cross}
A row vector is returned if x and y are both row vectors; otherwise, a column vector is returned.
cross ([1,1,0], [0,1,1]) => [ 1; -1; 1 ]
@anchor{doc-commutation_matrix}
If only one argument m is given, @math{K(m,m)} is returned.
See Magnus and Neudecker (1988), Matrix differential calculus with applications in statistics and econometrics.
@anchor{doc-duplication_matrix}
See Magnus and Neudecker (1988), Matrix differential calculus with applications in statistics and econometrics.
@anchor{doc-I}
sqrt (-1).
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 Status of Variables.
@anchor{doc-Inf}
@anchor{doc-NaN}
Note that NaN always compares not equal to NaN. This behavior is
specified by the IEEE standard for floating point arithmetic. To
find NaN values, you must use the isnan function.
@anchor{doc-pi}
pi is computed as `4.0 * atan (1.0)'.
@anchor{doc-e}
log (e) = 1.
@anchor{doc-eps}
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
2.2204e-16.
@anchor{doc-realmax}
realmax is approximately
1.7977e+308
@anchor{doc-realmin}
realmin is approximately
2.2251e-308
Go to the first, previous, next, last section, table of contents.