17.1 Exponents and Logarithms
- : exp (x)
-
Compute
e^x
for each element of x.To compute the matrix exponential, see Linear Algebra.
See also: log.
- : expm1 (x)
-
Compute
exp (x) - 1
accurately in the neighborhood of zero.See also: exp.
- : log (x)
-
Compute the natural logarithm,
ln (x)
, for each element of x.To compute the matrix logarithm, see Linear Algebra.
- : reallog (x)
-
Return the real-valued natural logarithm of each element of x.
If any element results in a complex return value
reallog
aborts and issues an error.
- : y = log2 (x)
- : [f, e] = log2 (x)
-
Compute the base-2 logarithm of each element of x.
If called with one output, compute the base-2 logarithm such that
2^y = x
.If called with two output arguments, split x into binary mantissa (f) and exponent (e) such that
x = f * 2^e
where1/2 <= abs (f) < 1
and e is an integer. Ifx = 0
,f = e = 0
.
- : pow2 (x)
- : pow2 (f, e)
-
With one input argument, compute 2 .^ x for each element of x.
With two input arguments, return f .* (2 .^ e).
- : n = nextpow2 (x)
-
Compute the exponent for the smallest power of two larger than the input.
For each element in the input array x, return the first integer n such that 2^n ≥ abs (x).
- : realpow (x, y)
-
Compute the real-valued, element-by-element power operator.
This is equivalent to
x .^ y
, except thatrealpow
reports an error if any return value is complex.
- : sqrt (x)
-
Compute the square root of each element of x.
If x is negative, a complex result is returned.
To compute the matrix square root, see Linear Algebra.
- : realsqrt (x)
-
Return the real-valued square root of each element of x.
If any element results in a complex return value
realsqrt
aborts and issues an error.
- : cbrt (x)
-
Compute the real cube root of each element of x.
Unlike
x^(1/3)
, the result will be negative if x is negative.See also: nthroot.
- : nthroot (x, n)
-
Compute the real (non-complex) n-th root of x.
x must have all real entries and n must be a scalar. If n is an even integer and x has negative entries then
nthroot
aborts and issues an error.Example:
nthroot (-1, 3) ⇒ -1 (-1) ^ (1 / 3) ⇒ 0.50000 - 0.86603i
© 1996–2020 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/v6.3.0/Exponents-and-Logarithms.html