man-pages/man7/complex.7.html
2021-03-31 01:06:50 +01:00

160 lines
4.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of COMPLEX</TITLE>
</HEAD><BODY>
<H1>COMPLEX</H1>
Section: Linux Programmer's Manual (7)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
complex - basics of complex mathematics
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>#include &lt;<A HREF="file:///usr/include/complex.h">complex.h</A>&gt;</B>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
Complex numbers are numbers of the form z = a+b*i, where a and b are
real numbers and i = sqrt(-1), so that i*i = -1.
<P>
There are other ways to represent that number.
The pair (a,b) of real
numbers may be viewed as a point in the plane, given by X- and
Y-coordinates.
This same point may also be described by giving
the pair of real numbers (r,phi), where r is the distance to the origin O,
and phi the angle between the X-axis and the line Oz.
Now
z = r*exp(i*phi) = r*(cos(phi)+i*sin(phi)).
<P>
The basic operations are defined on z = a+b*i and w = c+d*i as:
<DL COMPACT>
<DT id="1"><B>addition: z+w = (a+c) + (b+d)*i</B>
<DD>
<DT id="2"><B>multiplication: z*w = (a*c - b*d) + (a*d + b*c)*i</B>
<DD>
<DT id="3"><B>division: z/w = ((a*c + b*d)/(c*c + d*d)) + ((b*c - a*d)/(c*c + d*d))*i</B>
<DD>
</DL>
<P>
Nearly all math function have a complex counterpart but there are
some complex-only functions.
<A NAME="lbAE">&nbsp;</A>
<H2>EXAMPLE</H2>
Your C-compiler can work with complex numbers if it supports the C99 standard.
Link with <I>-lm</I>.
The imaginary unit is represented by I.
<P>
/* check that exp(i * pi) == -1 */
#include &lt;<A HREF="file:///usr/include/math.h">math.h</A>&gt; /* for atan */
#include &lt;<A HREF="file:///usr/include/stdio.h">stdio.h</A>&gt;
#include &lt;<A HREF="file:///usr/include/complex.h">complex.h</A>&gt;
<P>
int
main(void)
{
<BR>&nbsp;&nbsp;&nbsp;&nbsp;double&nbsp;pi&nbsp;=&nbsp;4&nbsp;*&nbsp;atan(1.0);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;double&nbsp;complex&nbsp;z&nbsp;=&nbsp;cexp(I&nbsp;*&nbsp;pi);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;%f&nbsp;+&nbsp;%f&nbsp;*&nbsp;i\n&quot;,&nbsp;creal(z),&nbsp;cimag(z));
}
<A NAME="lbAF">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?3+cabs">cabs</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+cacos">cacos</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+cacosh">cacosh</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+carg">carg</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+casin">casin</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+casinh">casinh</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+catan">catan</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+catanh">catanh</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+ccos">ccos</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+ccosh">ccosh</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+cerf">cerf</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+cexp">cexp</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+cexp2">cexp2</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+cimag">cimag</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+clog">clog</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+clog10">clog10</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+clog2">clog2</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+conj">conj</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+cpow">cpow</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+cproj">cproj</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+creal">creal</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+csin">csin</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+csinh">csinh</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+csqrt">csqrt</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+ctan">ctan</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+ctanh">ctanh</A></B>(3)
<A NAME="lbAG">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="4"><A HREF="#lbAB">NAME</A><DD>
<DT id="5"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="6"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="7"><A HREF="#lbAE">EXAMPLE</A><DD>
<DT id="8"><A HREF="#lbAF">SEE ALSO</A><DD>
<DT id="9"><A HREF="#lbAG">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:06:08 GMT, March 31, 2021
</BODY>
</HTML>