<html lang="en"> <head> <title>Exponents and Logarithms - Untitled</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Untitled"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Arithmetic.html#Arithmetic" title="Arithmetic"> <link rel="next" href="Complex-Arithmetic.html#Complex-Arithmetic" title="Complex Arithmetic"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Exponents-and-Logarithms"></a> <p> Next: <a rel="next" accesskey="n" href="Complex-Arithmetic.html#Complex-Arithmetic">Complex Arithmetic</a>, Up: <a rel="up" accesskey="u" href="Arithmetic.html#Arithmetic">Arithmetic</a> <hr> </div> <h3 class="section">17.1 Exponents and Logarithms</h3> <!-- mappers.cc --> <p><a name="doc_002dexp"></a> <div class="defun"> — Mapping Function: <b>exp</b> (<var>x</var>)<var><a name="index-exp-1361"></a></var><br> <blockquote><p>Compute <code>e^x</code> for each element of <var>x</var>. To compute the matrix exponential, see <a href="Linear-Algebra.html#Linear-Algebra">Linear Algebra</a>. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dlog.html#doc_002dlog">log</a>. </p></blockquote></div> <!-- mappers.cc --> <p><a name="doc_002dexpm1"></a> <div class="defun"> — Mapping Function: <b>expm1</b> (<var>x</var>)<var><a name="index-expm1-1362"></a></var><br> <blockquote><p>Compute <code>exp (</code><var>x</var><code>) - 1</code> accurately in the neighborhood of zero. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dexp.html#doc_002dexp">exp</a>. </p></blockquote></div> <!-- mappers.cc --> <p><a name="doc_002dlog"></a> <div class="defun"> — Mapping Function: <b>log</b> (<var>x</var>)<var><a name="index-log-1363"></a></var><br> <blockquote><p>Compute the natural logarithm, <code>ln (</code><var>x</var><code>)</code>, for each element of <var>x</var>. To compute the matrix logarithm, see <a href="Linear-Algebra.html#Linear-Algebra">Linear Algebra</a>. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dexp.html#doc_002dexp">exp</a>, <a href="doc_002dlog1p.html#doc_002dlog1p">log1p</a>, <a href="doc_002dlog2.html#doc_002dlog2">log2</a>, <a href="doc_002dlog10.html#doc_002dlog10">log10</a>, <a href="doc_002dlogspace.html#doc_002dlogspace">logspace</a>. </p></blockquote></div> <!-- mappers.cc --> <p><a name="doc_002dlog1p"></a> <div class="defun"> — Mapping Function: <b>log1p</b> (<var>x</var>)<var><a name="index-log1p-1364"></a></var><br> <blockquote><p>Compute <code>log (1 + </code><var>x</var><code>)</code> accurately in the neighborhood of zero. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dlog.html#doc_002dlog">log</a>, <a href="doc_002dexp.html#doc_002dexp">exp</a>, <a href="doc_002dexpm1.html#doc_002dexpm1">expm1</a>. </p></blockquote></div> <!-- mappers.cc --> <p><a name="doc_002dlog10"></a> <div class="defun"> — Mapping Function: <b>log10</b> (<var>x</var>)<var><a name="index-log10-1365"></a></var><br> <blockquote><p>Compute the base-10 logarithm of each element of <var>x</var>. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dlog.html#doc_002dlog">log</a>, <a href="doc_002dlog2.html#doc_002dlog2">log2</a>, <a href="doc_002dlogspace.html#doc_002dlogspace">logspace</a>, <a href="doc_002dexp.html#doc_002dexp">exp</a>. </p></blockquote></div> <!-- data.cc --> <p><a name="doc_002dlog2"></a> <div class="defun"> — Mapping Function: <b>log2</b> (<var>x</var>)<var><a name="index-log2-1366"></a></var><br> — Mapping Function: [<var>f</var>, <var>e</var>] = <b>log2</b> (<var>x</var>)<var><a name="index-log2-1367"></a></var><br> <blockquote><p>Compute the base-2 logarithm of each element of <var>x</var>. <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> and <var>e</var> is an integer. If <code>x = 0</code>, <code>f = e = 0</code>. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dpow2.html#doc_002dpow2">pow2</a>, <a href="doc_002dlog.html#doc_002dlog">log</a>, <a href="doc_002dlog10.html#doc_002dlog10">log10</a>, <a href="doc_002dexp.html#doc_002dexp">exp</a>. </p></blockquote></div> <!-- ./general/nextpow2.m --> <p><a name="doc_002dnextpow2"></a> <div class="defun"> — Function File: <b>nextpow2</b> (<var>x</var>)<var><a name="index-nextpow2-1368"></a></var><br> <blockquote><p>If <var>x</var> is a scalar, return the first integer <var>n</var> such that 2^n >= abs (x). <p>If <var>x</var> is a vector, return <code>nextpow2 (length (</code><var>x</var><code>))</code>. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dpow2.html#doc_002dpow2">pow2</a>, <a href="doc_002dlog2.html#doc_002dlog2">log2</a>. </p></blockquote></div> <!-- ./general/nthroot.m --> <p><a name="doc_002dnthroot"></a> <div class="defun"> — Function File: <b>nthroot</b> (<var>x, n</var>)<var><a name="index-nthroot-1369"></a></var><br> <blockquote> <p>Compute the n-th root of <var>x</var>, returning real results for real components of <var>x</var>. For example <pre class="example"> nthroot (-1, 3) ⇒ -1 (-1) ^ (1 / 3) ⇒ 0.50000 - 0.86603i </pre> </blockquote></div> <!-- ./specfun/pow2.m --> <p><a name="doc_002dpow2"></a> <div class="defun"> — Mapping Function: <b>pow2</b> (<var>x</var>)<var><a name="index-pow2-1370"></a></var><br> — Mapping Function: <b>pow2</b> (<var>f, e</var>)<var><a name="index-pow2-1371"></a></var><br> <blockquote><p>With one argument, computes 2 .^ x for each element of <var>x</var>. <p>With two arguments, returns f .* (2 .^ e). <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dlog2.html#doc_002dlog2">log2</a>, <a href="doc_002dnextpow2.html#doc_002dnextpow2">nextpow2</a>. </p></blockquote></div> <!-- ./specfun/reallog.m --> <p><a name="doc_002dreallog"></a> <div class="defun"> — Function File: <b>reallog</b> (<var>x</var>)<var><a name="index-reallog-1372"></a></var><br> <blockquote><p>Return the real-valued natural logarithm of each element of <var>x</var>. Report an error if any element results in a complex return value. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dlog.html#doc_002dlog">log</a>, <a href="doc_002drealpow.html#doc_002drealpow">realpow</a>, <a href="doc_002drealsqrt.html#doc_002drealsqrt">realsqrt</a>. </p></blockquote></div> <!-- ./specfun/realpow.m --> <p><a name="doc_002drealpow"></a> <div class="defun"> — Function File: <b>realpow</b> (<var>x, y</var>)<var><a name="index-realpow-1373"></a></var><br> <blockquote><p>Compute the real-valued, element-by-element power operator. This is equivalent to <var>x</var><code> .^ </code><var>y</var><!-- /@w -->, except that <code>realpow</code> reports an error if any return value is complex. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dreallog.html#doc_002dreallog">reallog</a>, <a href="doc_002drealsqrt.html#doc_002drealsqrt">realsqrt</a>. </p></blockquote></div> <!-- ./specfun/realsqrt.m --> <p><a name="doc_002drealsqrt"></a> <div class="defun"> — Function File: <b>realsqrt</b> (<var>x</var>)<var><a name="index-realsqrt-1374"></a></var><br> <blockquote><p>Return the real-valued square root of each element of <var>x</var>. Report an error if any element results in a complex return value. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dsqrt.html#doc_002dsqrt">sqrt</a>, <a href="doc_002drealpow.html#doc_002drealpow">realpow</a>, <a href="doc_002dreallog.html#doc_002dreallog">reallog</a>. </p></blockquote></div> <!-- mappers.cc --> <p><a name="doc_002dsqrt"></a> <div class="defun"> — Mapping Function: <b>sqrt</b> (<var>x</var>)<var><a name="index-sqrt-1375"></a></var><br> <blockquote><p>Compute the square root of each element of <var>x</var>. If <var>x</var> is negative, a complex result is returned. To compute the matrix square root, see <a href="Linear-Algebra.html#Linear-Algebra">Linear Algebra</a>. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002drealsqrt.html#doc_002drealsqrt">realsqrt</a>. </p></blockquote></div> </body></html>