<html lang="en"> <head> <title>Complex Arithmetic - 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="prev" href="Exponents-and-Logarithms.html#Exponents-and-Logarithms" title="Exponents and Logarithms"> <link rel="next" href="Trigonometry.html#Trigonometry" title="Trigonometry"> <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="Complex-Arithmetic"></a> <p> Next: <a rel="next" accesskey="n" href="Trigonometry.html#Trigonometry">Trigonometry</a>, Previous: <a rel="previous" accesskey="p" href="Exponents-and-Logarithms.html#Exponents-and-Logarithms">Exponents and Logarithms</a>, Up: <a rel="up" accesskey="u" href="Arithmetic.html#Arithmetic">Arithmetic</a> <hr> </div> <h3 class="section">17.2 Complex Arithmetic</h3> <p>In the descriptions of the following functions, <var>z</var> is the complex number <var>x</var> + <var>i</var><var>y</var>, where <var>i</var> is defined as <code>sqrt (-1)</code>. <!-- mappers.cc --> <p><a name="doc_002dabs"></a> <div class="defun"> — Mapping Function: <b>abs</b> (<var>z</var>)<var><a name="index-abs-1376"></a></var><br> <blockquote><p>Compute the magnitude of <var>z</var>, defined as |<var>z</var>| = <code>sqrt (x^2 + y^2)</code>. <p>For example, <pre class="example"> abs (3 + 4i) ⇒ 5 </pre> </blockquote></div> <!-- mappers.cc --> <p><a name="doc_002darg"></a> <div class="defun"> — Mapping Function: <b>arg</b> (<var>z</var>)<var><a name="index-arg-1377"></a></var><br> — Mapping Function: <b>angle</b> (<var>z</var>)<var><a name="index-angle-1378"></a></var><br> <blockquote><p>Compute the argument of <var>z</var>, defined as, <var>theta</var> = <code>atan2 (</code><var>y</var><code>, </code><var>x</var><code>)</code>, in radians. <p>For example, <pre class="example"> arg (3 + 4i) ⇒ 0.92730 </pre> </blockquote></div> <!-- mappers.cc --> <p><a name="doc_002dconj"></a> <div class="defun"> — Mapping Function: <b>conj</b> (<var>z</var>)<var><a name="index-conj-1379"></a></var><br> <blockquote><p>Return the complex conjugate of <var>z</var>, defined as <code>conj (</code><var>z</var><code>)</code> = <var>x</var> - <var>i</var><var>y</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_002dreal.html#doc_002dreal">real</a>, <a href="doc_002dimag.html#doc_002dimag">imag</a>. </p></blockquote></div> <!-- ./general/cplxpair.m --> <p><a name="doc_002dcplxpair"></a> <div class="defun"> — Function File: <b>cplxpair</b> (<var>z</var>)<var><a name="index-cplxpair-1380"></a></var><br> — Function File: <b>cplxpair</b> (<var>z, tol</var>)<var><a name="index-cplxpair-1381"></a></var><br> — Function File: <b>cplxpair</b> (<var>z, tol, dim</var>)<var><a name="index-cplxpair-1382"></a></var><br> <blockquote><p>Sort the numbers <var>z</var> into complex conjugate pairs ordered by increasing real part. Place the negative imaginary complex number first within each pair. Place all the real numbers (those with <code>abs (imag (</code><var>z</var><code>) / </code><var>z</var><code>) < </code><var>tol</var><code>)</code>) after the complex pairs. <p>If <var>tol</var> is unspecified the default value is 100*<code>eps</code>. <p>By default the complex pairs are sorted along the first non-singleton dimension of <var>z</var>. If <var>dim</var> is specified, then the complex pairs are sorted along this dimension. <p>Signal an error if some complex numbers could not be paired. Signal an error if all complex numbers are not exact conjugates (to within <var>tol</var>). Note that there is no defined order for pairs with identical real parts but differing imaginary parts. <!-- Set example in small font to prevent overfull line --> <pre class="smallexample"> cplxpair (exp(2i*pi*[0:4]'/5)) == exp(2i*pi*[3; 2; 4; 1; 0]/5) </pre> </blockquote></div> <!-- mappers.cc --> <p><a name="doc_002dimag"></a> <div class="defun"> — Mapping Function: <b>imag</b> (<var>z</var>)<var><a name="index-imag-1383"></a></var><br> <blockquote><p>Return the imaginary part of <var>z</var> as a real number. <!-- 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_002dreal.html#doc_002dreal">real</a>, <a href="doc_002dconj.html#doc_002dconj">conj</a>. </p></blockquote></div> <!-- mappers.cc --> <p><a name="doc_002dreal"></a> <div class="defun"> — Mapping Function: <b>real</b> (<var>z</var>)<var><a name="index-real-1384"></a></var><br> <blockquote><p>Return the real part of <var>z</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_002dimag.html#doc_002dimag">imag</a>, <a href="doc_002dconj.html#doc_002dconj">conj</a>. </p></blockquote></div> </body></html>