1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Octave: Exponents and Logarithms</title>
<meta name="description" content="GNU Octave: Exponents and Logarithms">
<meta name="keywords" content="GNU Octave: Exponents and Logarithms">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
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.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<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>Mapping Function: <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>. 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>Mapping Function: <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>Mapping Function: <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>. 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>Function File: <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>. Report
an error if any element results in a complex return value.
</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>Mapping Function: <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>Mapping Function: <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>Mapping Function: <em></em> <strong>log2</strong> <em>(<var>x</var>)</em></dt>
<dt><a name="index-log2-1"></a>Mapping Function: <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>
and <var>e</var> is an integer. If
<code>x = 0</code>, <code>f = e = 0</code>.
</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>Mapping Function: <em></em> <strong>pow2</strong> <em>(<var>x</var>)</em></dt>
<dt><a name="index-pow2-1"></a>Mapping Function: <em></em> <strong>pow2</strong> <em>(<var>f</var>, <var>e</var>)</em></dt>
<dd><p>With one argument, computes
2 .^ x
for each element of <var>x</var>.
</p>
<p>With two arguments, returns
f .* (2 .^ e).
</p>
<p><strong>See also:</strong> <a href="#XREFlog2">log2</a>, <a href="#XREFnextpow2">nextpow2</a>.
</p></dd></dl>
<a name="XREFnextpow2"></a><dl>
<dt><a name="index-nextpow2"></a>Function File: <em></em> <strong>nextpow2</strong> <em>(<var>x</var>)</em></dt>
<dd><p>If <var>x</var> is a scalar, return the first integer <var>n</var> such that
2^n ≥ abs (x).
</p>
<p>If <var>x</var> is a vector, return <code>nextpow2 (length (<var>x</var>))</code>.
</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>Function File: <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. 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="#XREFreallog">reallog</a>, <a href="#XREFrealsqrt">realsqrt</a>.
</p></dd></dl>
<a name="XREFsqrt"></a><dl>
<dt><a name="index-sqrt"></a>Mapping Function: <em></em> <strong>sqrt</strong> <em>(<var>x</var>)</em></dt>
<dd><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>.
</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>Function File: <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>. Report an
error if any element results in a complex return value.
</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>Mapping Function: <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>.
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>Function File: <em></em> <strong>nthroot</strong> <em>(<var>x</var>, <var>n</var>)</em></dt>
<dd>
<p>Compute the n-th root of <var>x</var>, returning real results for real
components of <var>x</var>. For example:
</p>
<div class="example">
<pre class="example">nthroot (-1, 3)
⇒ -1
(-1) ^ (1 / 3)
⇒ 0.50000 - 0.86603i
</pre></div>
<p><var>x</var> must have all real entries. <var>n</var> must be a scalar.
If <var>n</var> is an even integer and <var>X</var> has negative entries, an
error is produced.
</p>
<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>
|