[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Unless otherwise noted, all of the functions described in this chapter will work for real and complex scalar or matrix arguments.
1.1 Utility Functions | ||
1.2 Complex Arithmetic | ||
1.3 Trigonometry | ||
1.4 Sums and Products | ||
1.5 Special Functions |
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The following functions are available for working with complex numbers. Each expects a single argument, and given a matrix, they work on an element by element basis.
ceil (x)
Return the smallest integer not less than x. If x is
complex, return ceil (real (x)) + ceil (imag (x)) * I
.
floor (x)
Return the largest integer not greater than x. If x is
complex, return floor (real (x)) + floor (imag (x)) * I
.
fix (x)
Truncate x toward zero. If x is complex, return
fix (real (x)) + fix (imag (x)) * I
.
round (x)
Return the integer nearest to x. If x is complex, return
round (real (x)) + round (imag (x)) * I
.
sign (x)
Compute the signum function, which is defined as
For complex arguments, sign
returns x ./ abs (x)
.
exp (x)
Compute the exponential of x. To compute the matrix exponential, see @ref{Linear Algebra}.
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 that
g = v(1) * a(k) + ... + v(k) * a(k)
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]).
log (x)
Compute the natural logarithm of x. To compute the matrix logarithm, see @ref{Linear Algebra}.
log2 (x)
Compute the base-2 logarithm of x.
log10 (x)
Compute the base-10 logarithm of x.
sqrt (x)
Compute the square root of x. To compute the matrix square root, see @ref{Linear Algebra}.
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.
min (x)
Like max
, but return the minimum value.
rem (x, y)
Return the remainder of 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.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
abs (x)
Compute the magnitude of x.
angle (x)
arg (x)
Compute the argument of x.
conj (x)
Return the complex conjugate of x.
imag (x)
Return the imaginary part of x.
real (x)
Return the real part of x.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Octave provides the following trigonometric functions:
sin asin sinh asinh cos acos cosh acosh tan atan tanh atanh sec asec sech asech csc acsc csch acsch cot acot coth acoth
Each of these functions expect a single argument. For matrix arguments, they work on an element by element basis. For example, the expression
sin ([1, 2; 3, 4])
produces
ans = 0.84147 0.90930 0.14112 -0.75680
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 (@pxref{Empty Matrices}).
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 (@pxref{Empty Matrices}).
cumsum (x)
Return the cumulative sum of each column of x. For example,
cumsum ([1, 2; 3, 4])
produces
ans = 1 2 4 6
cumprod (x)
Return the cumulative product of each column of x. For example,
cumprod ([1, 2; 3, 4])
produces
ans = 1 2 3 8
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.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
beta
Returns the beta 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.
erf
Computes the error function,
erfc (z)
Computes the complementary error function, 1 - erf (z)
.
erfinv
Computes the inverse of the error function.
gamma (z)
Computes the gamma function,
gammai (a, x)
Computes the incomplete gamma function,
If a is scalar, then gammai (a, x)
is returned
for each element of 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.
lgamma
Returns the natural logarithm of the gamma function.
[Top] | [Contents] | [Index] | [ ? ] |
This document was generated on January 15, 2023 using texi2html 5.0.
The buttons in the navigation panels have the following meaning:
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ << ] | FastBack | Beginning of this chapter or previous chapter | 1 |
[ < ] | Back | Previous section in reading order | 1.2.2 |
[ Up ] | Up | Up section | 1.2 |
[ > ] | Forward | Next section in reading order | 1.2.4 |
[ >> ] | FastForward | Next chapter | 2 |
[Top] | Top | Cover (top) of document | |
[Contents] | Contents | Table of contents | |
[Index] | Index | Index | |
[ ? ] | About | About (help) |
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:
This document was generated on January 15, 2023 using texi2html 5.0.