/usr/share/doc/octave/octave.html/Arithmetic-Ops.html is in octave-doc 4.2.2-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | <!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>Arithmetic Ops (GNU Octave)</title>
<meta name="description" content="Arithmetic Ops (GNU Octave)">
<meta name="keywords" content="Arithmetic Ops (GNU Octave)">
<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="Expressions.html#Expressions" rel="up" title="Expressions">
<link href="Comparison-Ops.html#Comparison-Ops" rel="next" title="Comparison Ops">
<link href="Recursion.html#Recursion" rel="prev" title="Recursion">
<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="Arithmetic-Ops"></a>
<div class="header">
<p>
Next: <a href="Comparison-Ops.html#Comparison-Ops" accesskey="n" rel="next">Comparison Ops</a>, Previous: <a href="Calling-Functions.html#Calling-Functions" accesskey="p" rel="prev">Calling Functions</a>, Up: <a href="Expressions.html#Expressions" accesskey="u" rel="up">Expressions</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="Arithmetic-Operators"></a>
<h3 class="section">8.3 Arithmetic Operators</h3>
<a name="index-arithmetic-operators"></a>
<a name="index-operators_002c-arithmetic"></a>
<a name="index-addition"></a>
<a name="index-subtraction"></a>
<a name="index-multiplication"></a>
<a name="index-matrix-multiplication"></a>
<a name="index-division"></a>
<a name="index-quotient"></a>
<a name="index-negation"></a>
<a name="index-unary-minus"></a>
<a name="index-exponentiation"></a>
<a name="index-transpose"></a>
<a name="index-Hermitian-operator"></a>
<a name="index-transpose_002c-complex_002dconjugate"></a>
<a name="index-complex_002dconjugate-transpose"></a>
<p>The following arithmetic operators are available, and work on scalars
and matrices. The element-by-element operators and functions broadcast
(see <a href="Broadcasting.html#Broadcasting">Broadcasting</a>).
</p>
<dl compact="compact">
<dt><var>x</var> + <var>y</var></dt>
<dd><a name="index-_002b"></a>
<p>Addition. If both operands are matrices, the number of rows and columns
must both agree, or they must be broadcastable to the same shape.
</p>
</dd>
<dt><var>x</var> .+ <var>y</var></dt>
<dd><a name="index-_002e_002b"></a>
<p>Element-by-element addition. This operator is equivalent to <code>+</code>.
</p>
</dd>
<dt><var>x</var> - <var>y</var></dt>
<dd><a name="index-_002d"></a>
<p>Subtraction. If both operands are matrices, the number of rows and
columns of both must agree, or they must be broadcastable to the same
shape.
</p>
</dd>
<dt><var>x</var> .- <var>y</var></dt>
<dd><p>Element-by-element subtraction. This operator is equivalent to <code>-</code>.
</p>
</dd>
<dt><var>x</var> * <var>y</var></dt>
<dd><a name="index-_002a"></a>
<p>Matrix multiplication. The number of columns of <var>x</var> must agree with
the number of rows of <var>y</var>.
</p>
</dd>
<dt><var>x</var> .* <var>y</var></dt>
<dd><a name="index-_002e_002a"></a>
<p>Element-by-element multiplication. If both operands are matrices, the
number of rows and columns must both agree, or they must be
broadcastable to the same shape.
</p>
</dd>
<dt><var>x</var> / <var>y</var></dt>
<dd><a name="index-_002f"></a>
<p>Right division. This is conceptually equivalent to the expression
</p>
<div class="example">
<pre class="example">(inverse (y') * x')'
</pre></div>
<p>but it is computed without forming the inverse of <var>y’</var>.
</p>
<p>If the system is not square, or if the coefficient matrix is singular,
a minimum norm solution is computed.
</p>
</dd>
<dt><var>x</var> ./ <var>y</var></dt>
<dd><a name="index-_002e_002f"></a>
<p>Element-by-element right division.
</p>
</dd>
<dt><var>x</var> \ <var>y</var></dt>
<dd><a name="index-_005c"></a>
<p>Left division. This is conceptually equivalent to the expression
</p>
<div class="example">
<pre class="example">inverse (x) * y
</pre></div>
<p>but it is computed without forming the inverse of <var>x</var>.
</p>
<p>If the system is not square, or if the coefficient matrix is singular,
a minimum norm solution is computed.
</p>
</dd>
<dt><var>x</var> .\ <var>y</var></dt>
<dd><a name="index-_002e_005c"></a>
<p>Element-by-element left division. Each element of <var>y</var> is divided
by each corresponding element of <var>x</var>.
</p>
</dd>
<dt><var>x</var> ^ <var>y</var></dt>
<dt><var>x</var> ** <var>y</var></dt>
<dd><a name="index-_002a_002a"></a>
<a name="index-_005e"></a>
<p>Power operator. If <var>x</var> and <var>y</var> are both scalars, this operator
returns <var>x</var> raised to the power <var>y</var>. If <var>x</var> is a scalar and
<var>y</var> is a square matrix, the result is computed using an eigenvalue
expansion. If <var>x</var> is a square matrix, the result is computed by
repeated multiplication if <var>y</var> is an integer, and by an eigenvalue
expansion if <var>y</var> is not an integer. An error results if both
<var>x</var> and <var>y</var> are matrices.
</p>
<p>The implementation of this operator needs to be improved.
</p>
</dd>
<dt><var>x</var> .^ <var>y</var></dt>
<dt><var>x</var> .** <var>y</var></dt>
<dd><a name="index-_002e_002a_002a"></a>
<a name="index-_002e_005e"></a>
<p>Element-by-element power operator. If both operands are matrices, the
number of rows and columns must both agree, or they must be
broadcastable to the same shape. If several complex results are
possible, the one with smallest non-negative argument (angle) is taken.
This rule may return a complex root even when a real root is also possible.
Use <code>realpow</code>, <code>realsqrt</code>, <code>cbrt</code>, or <code>nthroot</code> if a
real result is preferred.
</p>
</dd>
<dt>-<var>x</var></dt>
<dd><a name="index-_002d-1"></a>
<p>Negation.
</p>
</dd>
<dt>+<var>x</var></dt>
<dd><a name="index-_002b-1"></a>
<p>Unary plus. This operator has no effect on the operand.
</p>
</dd>
<dt><var>x</var>’</dt>
<dd><a name="index-_0027-2"></a>
<p>Complex conjugate transpose. For real arguments, this operator is the
same as the transpose operator. For complex arguments, this operator is
equivalent to the expression
</p>
<div class="example">
<pre class="example">conj (x.')
</pre></div>
</dd>
<dt><var>x</var>.’</dt>
<dd><a name="index-_002e_0027"></a>
<p>Transpose.
</p></dd>
</dl>
<p>Note that because Octave’s element-by-element operators begin with a
‘<samp>.</samp>’, there is a possible ambiguity for statements like
</p>
<div class="example">
<pre class="example">1./m
</pre></div>
<p>because the period could be interpreted either as part of the constant
or as part of the operator. To resolve this conflict, Octave treats the
expression as if you had typed
</p>
<div class="example">
<pre class="example">(1) ./ m
</pre></div>
<p>and not
</p>
<div class="example">
<pre class="example">(1.) / m
</pre></div>
<p>Although this is inconsistent with the normal behavior of Octave’s
lexer, which usually prefers to break the input into tokens by
preferring the longest possible match at any given point, it is more
useful in this case.
</p>
<a name="index-_0027-3"></a>
<a name="XREFctranspose"></a><dl>
<dt><a name="index-ctranspose"></a>: <em></em> <strong>ctranspose</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Return the complex conjugate transpose of <var>x</var>.
</p>
<p>This function and <code><var>x</var>'</code> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFtranspose">transpose</a>.
</p></dd></dl>
<a name="index-_002e_005c-1"></a>
<a name="XREFldivide"></a><dl>
<dt><a name="index-ldivide"></a>: <em></em> <strong>ldivide</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the element-by-element left division of <var>x</var> and <var>y</var>.
</p>
<p>This function and <code><var>x</var> .\ <var>y</var></code><!-- /@w --> are
equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFrdivide">rdivide</a>, <a href="#XREFmldivide">mldivide</a>, <a href="#XREFtimes">times</a>, <a href="#XREFplus">plus</a>.
</p></dd></dl>
<a name="index-_002d-2"></a>
<a name="XREFminus"></a><dl>
<dt><a name="index-minus"></a>: <em></em> <strong>minus</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>This function and <code><var>x</var> <span class="nolinebreak">-</span> <var>y</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFplus">plus</a>, <a href="#XREFuminus">uminus</a>.
</p></dd></dl>
<a name="index-_005c-1"></a>
<a name="XREFmldivide"></a><dl>
<dt><a name="index-mldivide"></a>: <em></em> <strong>mldivide</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the matrix left division of <var>x</var> and <var>y</var>.
</p>
<p>This function and <code><var>x</var> \ <var>y</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFmrdivide">mrdivide</a>, <a href="#XREFldivide">ldivide</a>, <a href="#XREFrdivide">rdivide</a>.
</p></dd></dl>
<a name="index-_002a_002a-1"></a>
<a name="index-_005e-1"></a>
<a name="XREFmpower"></a><dl>
<dt><a name="index-mpower"></a>: <em></em> <strong>mpower</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the matrix power operation of <var>x</var> raised to the <var>y</var> power.
</p>
<p>This function and <code><var>x</var> ^ <var>y</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFpower">power</a>, <a href="#XREFmtimes">mtimes</a>, <a href="#XREFplus">plus</a>, <a href="#XREFminus">minus</a>.
</p></dd></dl>
<a name="index-_002f-1"></a>
<a name="XREFmrdivide"></a><dl>
<dt><a name="index-mrdivide"></a>: <em></em> <strong>mrdivide</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the matrix right division of <var>x</var> and <var>y</var>.
</p>
<p>This function and <code><var>x</var> / <var>y</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFmldivide">mldivide</a>, <a href="#XREFrdivide">rdivide</a>, <a href="#XREFplus">plus</a>, <a href="#XREFminus">minus</a>.
</p></dd></dl>
<a name="index-_002a-1"></a>
<a name="XREFmtimes"></a><dl>
<dt><a name="index-mtimes"></a>: <em></em> <strong>mtimes</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dt><a name="index-mtimes-1"></a>: <em></em> <strong>mtimes</strong> <em>(<var>x1</var>, <var>x2</var>, …)</em></dt>
<dd><p>Return the matrix multiplication product of inputs.
</p>
<p>This function and <code><var>x</var> * <var>y</var></code><!-- /@w --> are equivalent.
If more arguments are given, the multiplication is applied
cumulatively from left to right:
</p>
<div class="example">
<pre class="example">(…((<var>x1</var> * <var>x2</var>) * <var>x3</var>) * …)
</pre></div>
<p>At least one argument is required.
</p>
<p><strong>See also:</strong> <a href="#XREFtimes">times</a>, <a href="#XREFplus">plus</a>, <a href="#XREFminus">minus</a>, <a href="#XREFrdivide">rdivide</a>, <a href="#XREFmrdivide">mrdivide</a>, <a href="#XREFmldivide">mldivide</a>, <a href="#XREFmpower">mpower</a>.
</p></dd></dl>
<a name="index-_002b-2"></a>
<a name="XREFplus"></a><dl>
<dt><a name="index-plus"></a>: <em></em> <strong>plus</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dt><a name="index-plus-1"></a>: <em></em> <strong>plus</strong> <em>(<var>x1</var>, <var>x2</var>, …)</em></dt>
<dd><p>This function and <code><var>x</var> + <var>y</var></code><!-- /@w --> are equivalent.
</p>
<p>If more arguments are given, the summation is applied
cumulatively from left to right:
</p>
<div class="example">
<pre class="example">(…((<var>x1</var> + <var>x2</var>) + <var>x3</var>) + …)
</pre></div>
<p>At least one argument is required.
</p>
<p><strong>See also:</strong> <a href="#XREFminus">minus</a>, <a href="#XREFuplus">uplus</a>.
</p></dd></dl>
<a name="index-_002e_002a_002a-1"></a>
<a name="index-_002e_005e-1"></a>
<a name="XREFpower"></a><dl>
<dt><a name="index-power"></a>: <em></em> <strong>power</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the element-by-element operation of <var>x</var> raised to the
<var>y</var> power.
</p>
<p>This function and <code><var>x</var> .^ <var>y</var></code><!-- /@w --> are equivalent.
</p>
<p>If several complex results are possible, returns the one with smallest
non-negative argument (angle). Use <code>realpow</code>, <code>realsqrt</code>,
<code>cbrt</code>, or <code>nthroot</code> if a real result is preferred.
</p>
<p><strong>See also:</strong> <a href="#XREFmpower">mpower</a>, <a href="Exponents-and-Logarithms.html#XREFrealpow">realpow</a>, <a href="Exponents-and-Logarithms.html#XREFrealsqrt">realsqrt</a>, <a href="Exponents-and-Logarithms.html#XREFcbrt">cbrt</a>, <a href="Exponents-and-Logarithms.html#XREFnthroot">nthroot</a>.
</p></dd></dl>
<a name="index-_002e_002f-1"></a>
<a name="XREFrdivide"></a><dl>
<dt><a name="index-rdivide"></a>: <em></em> <strong>rdivide</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the element-by-element right division of <var>x</var> and <var>y</var>.
</p>
<p>This function and <code><var>x</var> ./ <var>y</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFldivide">ldivide</a>, <a href="#XREFmrdivide">mrdivide</a>, <a href="#XREFtimes">times</a>, <a href="#XREFplus">plus</a>.
</p></dd></dl>
<a name="index-_002e_002a-1"></a>
<a name="XREFtimes"></a><dl>
<dt><a name="index-times"></a>: <em></em> <strong>times</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dt><a name="index-times-1"></a>: <em></em> <strong>times</strong> <em>(<var>x1</var>, <var>x2</var>, …)</em></dt>
<dd><p>Return the element-by-element multiplication product of inputs.
</p>
<p>This function and <code><var>x</var> .* <var>y</var></code><!-- /@w --> are equivalent.
If more arguments are given, the multiplication is applied
cumulatively from left to right:
</p>
<div class="example">
<pre class="example">(…((<var>x1</var> .* <var>x2</var>) .* <var>x3</var>) .* …)
</pre></div>
<p>At least one argument is required.
</p>
<p><strong>See also:</strong> <a href="#XREFmtimes">mtimes</a>, <a href="#XREFrdivide">rdivide</a>.
</p></dd></dl>
<a name="index-_002e_0027-1"></a>
<a name="XREFtranspose"></a><dl>
<dt><a name="index-transpose-2"></a>: <em></em> <strong>transpose</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Return the transpose of <var>x</var>.
</p>
<p>This function and <code><var>x</var>.'</code> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFctranspose">ctranspose</a>.
</p></dd></dl>
<a name="index-_002d-3"></a>
<a name="XREFuminus"></a><dl>
<dt><a name="index-uminus"></a>: <em></em> <strong>uminus</strong> <em>(<var>x</var>)</em></dt>
<dd><p>This function and <code><span class="nolinebreak">-</span> <var>x</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFuplus">uplus</a>, <a href="#XREFminus">minus</a>.
</p></dd></dl>
<a name="index-_002b-3"></a>
<a name="XREFuplus"></a><dl>
<dt><a name="index-uplus"></a>: <em></em> <strong>uplus</strong> <em>(<var>x</var>)</em></dt>
<dd><p>This function and <code>+ <var>x</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFuminus">uminus</a>, <a href="#XREFplus">plus</a>, <a href="#XREFminus">minus</a>.
</p></dd></dl>
<hr>
<div class="header">
<p>
Next: <a href="Comparison-Ops.html#Comparison-Ops" accesskey="n" rel="next">Comparison Ops</a>, Previous: <a href="Calling-Functions.html#Calling-Functions" accesskey="p" rel="prev">Calling Functions</a>, Up: <a href="Expressions.html#Expressions" accesskey="u" rel="up">Expressions</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>
|