<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Exponents and Logarithms (GNU Octave (version 5.1.0))</title> <meta name="description" content="Exponents and Logarithms (GNU Octave (version 5.1.0))"> <meta name="keywords" content="Exponents and Logarithms (GNU Octave (version 5.1.0))"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <link href="index.html#Top" rel="start" title="Top"> <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="Arithmetic.html#Arithmetic" rel="up" title="Arithmetic"> <link href="Complex-Arithmetic.html#Complex-Arithmetic" rel="next" title="Complex Arithmetic"> <link href="Arithmetic.html#Arithmetic" rel="prev" title="Arithmetic"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.lisp {margin-left: 3.2em} div.smalldisplay {margin-left: 3.2em} div.smallexample {margin-left: 3.2em} div.smalllisp {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: inherit; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: inherit; font-size: smaller} pre.smalllisp {font-size: smaller} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} ul.no-bullet {list-style: none} --> </style> <link rel="stylesheet" type="text/css" href="octave.css"> </head> <body lang="en"> <a name="Exponents-and-Logarithms"></a> <div class="header"> <p> Next: <a href="Complex-Arithmetic.html#Complex-Arithmetic" accesskey="n" rel="next">Complex Arithmetic</a>, Up: <a href="Arithmetic.html#Arithmetic" accesskey="u" rel="up">Arithmetic</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> <hr> <a name="Exponents-and-Logarithms-1"></a> <h3 class="section">17.1 Exponents and Logarithms</h3> <a name="XREFexp"></a><dl> <dt><a name="index-exp"></a><em></em> <strong>exp</strong> <em>(<var>x</var>)</em></dt> <dd><p>Compute <code>e^x</code> for each element of <var>x</var>. </p> <p>To compute the matrix exponential, see <a href="Linear-Algebra.html#Linear-Algebra">Linear Algebra</a>. </p> <p><strong>See also:</strong> <a href="#XREFlog">log</a>. </p></dd></dl> <a name="XREFexpm1"></a><dl> <dt><a name="index-expm1"></a><em></em> <strong>expm1</strong> <em>(<var>x</var>)</em></dt> <dd><p>Compute <code>exp (<var>x</var>) - 1</code> accurately in the neighborhood of zero. </p> <p><strong>See also:</strong> <a href="#XREFexp">exp</a>. </p></dd></dl> <a name="XREFlog"></a><dl> <dt><a name="index-log"></a><em></em> <strong>log</strong> <em>(<var>x</var>)</em></dt> <dd><p>Compute the natural logarithm, <code>ln (<var>x</var>)</code>, for each element of <var>x</var>. </p> <p>To compute the matrix logarithm, see <a href="Linear-Algebra.html#Linear-Algebra">Linear Algebra</a>. </p> <p><strong>See also:</strong> <a href="#XREFexp">exp</a>, <a href="#XREFlog1p">log1p</a>, <a href="#XREFlog2">log2</a>, <a href="#XREFlog10">log10</a>, <a href="Special-Utility-Matrices.html#XREFlogspace">logspace</a>. </p></dd></dl> <a name="XREFreallog"></a><dl> <dt><a name="index-reallog"></a><em></em> <strong>reallog</strong> <em>(<var>x</var>)</em></dt> <dd><p>Return the real-valued natural logarithm of each element of <var>x</var>. </p> <p>If any element results in a complex return value <code>reallog</code> aborts and issues an error. </p> <p><strong>See also:</strong> <a href="#XREFlog">log</a>, <a href="#XREFrealpow">realpow</a>, <a href="#XREFrealsqrt">realsqrt</a>. </p></dd></dl> <a name="XREFlog1p"></a><dl> <dt><a name="index-log1p"></a><em></em> <strong>log1p</strong> <em>(<var>x</var>)</em></dt> <dd><p>Compute <code>log (1 + <var>x</var>)</code> accurately in the neighborhood of zero. </p> <p><strong>See also:</strong> <a href="#XREFlog">log</a>, <a href="#XREFexp">exp</a>, <a href="#XREFexpm1">expm1</a>. </p></dd></dl> <a name="XREFlog10"></a><dl> <dt><a name="index-log10"></a><em></em> <strong>log10</strong> <em>(<var>x</var>)</em></dt> <dd><p>Compute the base-10 logarithm of each element of <var>x</var>. </p> <p><strong>See also:</strong> <a href="#XREFlog">log</a>, <a href="#XREFlog2">log2</a>, <a href="Special-Utility-Matrices.html#XREFlogspace">logspace</a>, <a href="#XREFexp">exp</a>. </p></dd></dl> <a name="XREFlog2"></a><dl> <dt><a name="index-log2"></a><em></em> <strong>log2</strong> <em>(<var>x</var>)</em></dt> <dt><a name="index-log2-1"></a><em>[<var>f</var>, <var>e</var>] =</em> <strong>log2</strong> <em>(<var>x</var>)</em></dt> <dd><p>Compute the base-2 logarithm of each element of <var>x</var>. </p> <p>If called with two output arguments, split <var>x</var> into binary mantissa and exponent so that <code>1/2 <= abs(f) < 1</code><!-- /@w --> and <var>e</var> is an integer. If <code>x = 0</code><!-- /@w -->, <code>f = e = 0</code><!-- /@w -->. </p> <p><strong>See also:</strong> <a href="#XREFpow2">pow2</a>, <a href="#XREFlog">log</a>, <a href="#XREFlog10">log10</a>, <a href="#XREFexp">exp</a>. </p></dd></dl> <a name="XREFpow2"></a><dl> <dt><a name="index-pow2"></a><em></em> <strong>pow2</strong> <em>(<var>x</var>)</em></dt> <dt><a name="index-pow2-1"></a><em></em> <strong>pow2</strong> <em>(<var>f</var>, <var>e</var>)</em></dt> <dd><p>With one input argument, compute 2 .^ x for each element of <var>x</var>. </p> <p>With two input arguments, return f .* (2 .^ e). </p> <p><strong>See also:</strong> <a href="#XREFlog2">log2</a>, <a href="#XREFnextpow2">nextpow2</a>, <a href="Arithmetic-Ops.html#XREFpower">power</a>. </p></dd></dl> <a name="XREFnextpow2"></a><dl> <dt><a name="index-nextpow2"></a><em><var>n</var> =</em> <strong>nextpow2</strong> <em>(<var>x</var>)</em></dt> <dd><p>Compute the exponent for the smallest power of two larger than the input. </p> <p>For each element in the input array <var>x</var>, return the first integer <var>n</var> such that 2^n ≥ abs (x). </p> <p><strong>See also:</strong> <a href="#XREFpow2">pow2</a>, <a href="#XREFlog2">log2</a>. </p></dd></dl> <a name="XREFrealpow"></a><dl> <dt><a name="index-realpow"></a><em></em> <strong>realpow</strong> <em>(<var>x</var>, <var>y</var>)</em></dt> <dd><p>Compute the real-valued, element-by-element power operator. </p> <p>This is equivalent to <code><var>x</var> .^ <var>y</var></code><!-- /@w -->, except that <code>realpow</code> reports an error if any return value is complex. </p> <p><strong>See also:</strong> <a href="Arithmetic-Ops.html#XREFpower">power</a>, <a href="#XREFreallog">reallog</a>, <a href="#XREFrealsqrt">realsqrt</a>. </p></dd></dl> <a name="XREFsqrt"></a><dl> <dt><a name="index-sqrt"></a><em></em> <strong>sqrt</strong> <em>(<var>x</var>)</em></dt> <dd><p>Compute the square root of each element of <var>x</var>. </p> <p>If <var>x</var> is negative, a complex result is returned. </p> <p>To compute the matrix square root, see <a href="Linear-Algebra.html#Linear-Algebra">Linear Algebra</a>. </p> <p><strong>See also:</strong> <a href="#XREFrealsqrt">realsqrt</a>, <a href="#XREFnthroot">nthroot</a>. </p></dd></dl> <a name="XREFrealsqrt"></a><dl> <dt><a name="index-realsqrt"></a><em></em> <strong>realsqrt</strong> <em>(<var>x</var>)</em></dt> <dd><p>Return the real-valued square root of each element of <var>x</var>. </p> <p>If any element results in a complex return value <code>realsqrt</code> aborts and issues an error. </p> <p><strong>See also:</strong> <a href="#XREFsqrt">sqrt</a>, <a href="#XREFrealpow">realpow</a>, <a href="#XREFreallog">reallog</a>. </p></dd></dl> <a name="XREFcbrt"></a><dl> <dt><a name="index-cbrt"></a><em></em> <strong>cbrt</strong> <em>(<var>x</var>)</em></dt> <dd><p>Compute the real cube root of each element of <var>x</var>. </p> <p>Unlike <code><var>x</var>^(1/3)</code>, the result will be negative if <var>x</var> is negative. </p> <p><strong>See also:</strong> <a href="#XREFnthroot">nthroot</a>. </p></dd></dl> <a name="XREFnthroot"></a><dl> <dt><a name="index-nthroot"></a><em></em> <strong>nthroot</strong> <em>(<var>x</var>, <var>n</var>)</em></dt> <dd> <p>Compute the real (non-complex) <var>n</var>-th root of <var>x</var>. </p> <p><var>x</var> must have all real entries and <var>n</var> must be a scalar. If <var>n</var> is an even integer and <var>x</var> has negative entries then <code>nthroot</code> aborts and issues an error. </p> <p>Example: </p> <div class="example"> <pre class="example">nthroot (-1, 3) ⇒ -1 (-1) ^ (1 / 3) ⇒ 0.50000 - 0.86603i </pre></div> <p><strong>See also:</strong> <a href="#XREFrealsqrt">realsqrt</a>, <a href="#XREFsqrt">sqrt</a>, <a href="#XREFcbrt">cbrt</a>. </p></dd></dl> <hr> <div class="header"> <p> Next: <a href="Complex-Arithmetic.html#Complex-Arithmetic" accesskey="n" rel="next">Complex Arithmetic</a>, Up: <a href="Arithmetic.html#Arithmetic" accesskey="u" rel="up">Arithmetic</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> </body> </html>