Exponents and Logarithms (GNU Octave (version 11.1.0))

### 17.1 Exponents and Logarithms ¶

`y =` exp `(x)` ¶

  Compute `e^x` for each element of x.

  To compute the matrix exponential, see Linear Algebra.

  See also: log.

`y =` expm1 `(x)` ¶

  Compute `exp (x) - 1` accurately in the neighborhood of zero.

  See also: exp.

`y =` log `(x)` ¶

  Compute the natural logarithm, `ln (x)`, for each element of x.

  To compute the matrix logarithm, see Linear Algebra.

  See also: exp, log1p, log2, log10, logspace.

`y =` 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.

  See also: log, realpow, realsqrt.

`y =` log1p `(x)` ¶

  Compute `log (1 + x)` accurately in the neighborhood of zero.

  See also: log, exp, expm1.

`y =` log10 `(x)` ¶

  Compute the base-10 logarithm of each element of x.

  See also: log, log2, logspace, exp.

`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` where `1/2 <= abs (f) < 1` and e is an integer. If `x = 0`, `f = e = 0`.

  See also: pow2, log, log10, exp.

`y =` pow2 `(x)` ¶
`y =` pow2 `(f, e)` ¶

  With one input argument, compute y = 2 .^ x for each element of x.

  With two input arguments, return y = f .* (2 .^ e). where for complex inputs only the real part of both inputs is regarded and from e only the real integer part. This calling form corresponds to C/C++ standard function `ldexp()`.

  See also: log2, nextpow2, power.

`n =` nextpow2 `(x)` ¶

  Compute the exponent of the next power of two not smaller than the input.

  For each element in the input array x, return the smallest integer n such that `2^n ≥ abs (x)`. For input elements equal to zero, return zero.

  See also: pow2, log2.

`z =` realpow `(x, y)` ¶

  Compute the real-valued, element-by-element power operator.

  This is equivalent to `x .^ y`, except that `realpow` reports an error if any return value is complex.

  See also: power, reallog, realsqrt.

`y =` 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.

  See also: realsqrt, nthroot.

`y =` 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.

  See also: sqrt, realpow, reallog.

`y =` cbrt `(x)` ¶

  Compute the real-valued cube root of each element of x.

  Unlike `x^(1/3)`, the result will be negative if x is negative.

  If any element of x is complex, `cbrt` aborts with an error.

  See also: nthroot.

`y =` 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

  See also: realsqrt, sqrt, cbrt.