Visit Our UNIX and Linux User Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #361
Difficulty: Medium
The rmdir command remove directories, even if they are not empty.
True or False?
Linux & Unix Commands - Search Man Pages

complex(7) [centos man page]

COMPLEX(7)						     Linux Programmer's Manual							COMPLEX(7)

NAME
complex - basics of complex mathematics SYNOPSIS
#include <complex.h> DESCRIPTION
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. 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)). The basic operations are defined on z = a+b*i and w = c+d*i as: addition: z+w = (a+c) + (b+d)*i multiplication: z*w = (a*c - b*d) + (a*d + b*c)*i division: z/w = ((a*c + b*d)/(c*c + d*d)) + ((b*c - a*d)/(c*c + d*d))*i Nearly all math function have a complex counterpart but there are some complex-only functions. EXAMPLE
Your C-compiler can work with complex numbers if it supports the C99 standard. Link with -lm. The imaginary unit is represented by I. /* check that exp(i * pi) == -1 */ #include <math.h> /* for atan */ #include <stdio.h> #include <complex.h> int main(void) { double pi = 4 * atan(1.0); double complex z = cexp(I * pi); printf("%f + %f * i ", creal(z), cimag(z)); } SEE ALSO
cabs(3), cacos(3), cacosh(3), carg(3), casin(3), casinh(3), catan(3), catanh(3), ccos(3), ccosh(3), cerf(3), cexp(3), cexp2(3), cimag(3), clog(3), clog10(3), clog2(3), conj(3), cpow(3), cproj(3), creal(3), csin(3), csinh(3), csqrt(3), ctan(3), ctanh(3) COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. 2011-09-16 COMPLEX(7)

Check Out this Related Man Page

COMPLEX(3)						   BSD Library Functions Manual 						COMPLEX(3)

NAME
complex -- complex floating-point functions SYNOPSIS
#include <complex.h> DESCRIPTION
The header file complex.h provides function prototypes and macros for working with complex floating-point values. The functions conform to the ISO/IEC 9899:2011 standard. In particular, arguments with infinite real or imaginary parts are regarded as infinities, even if the other part is a NaN. complex.h defines the macro complex for use as a type specifier, and the macro I to be the imaginary unit, which can be used to construct complex floating-point numbers from two real floating-point numbers. For example: #include <complex.h> double complex z = 1.0 + 1.0 * I; // z = 1 + i Note however that certain complex values cannot be initialized using this technique, because I is actually a complex value. For example: double complex z = 0.0 + INFINITY * I; does not produce the result that one might expect; because of the promotion rules, it is evaluated like this: 0.0 + INFINITY * I = 0.0 + inf*(0.0,1.0) = 0.0 + (inf,0.0)*(0.0,1.0) = 0.0 + (inf*0.0 - 1.0*0.0, inf*1.0 + 0.0*0.0) = 0.0 + (NaN - 0.0, inf + 0.0) = 0.0 + (NaN, inf) = (0.0, 0.0) + (NaN, inf) = (0.0 + NaN, 0.0 + inf) = (NaN, inf) For this reason, and to allow the initialization of complex objects with static or thread storage duration, C11 introduced the following macros: double complex CMPLX(double x, double y) float complex CMPLXF(float x, float y) long double complex CMPLXL(long double x, long double y) These produce a complex number with real part having the converted value x and imaginary part y. Each of the functions that use complex floating-point values are provided in single, double, and extended precision; the double precision prototypes are listed here. The man pages for the individual functions provide more details on their use, special cases, and prototypes for their single and extended precision versions. The double-precision functions defined in complex.h are: double creal(double complex z) double cimag(double complex z) creal() and cimag() take a complex floating-point number and return its real and imaginary part, respectively, as real floating-point num- bers. double cabs(double complex z) double carg(double complex z) cabs() and carg() take a complex floating-point number and return its norm and argument (phase angle), respectively, as real floating-point numbers. They are used to convert between rectangular and polar coordinates, and are fully specified in terms of real functions: cabs(x + iy) = hypot(x,y) carg(x + iy) = atan2(y,x) double complex conj(double complex z) conj() takes a complex floating-point number and returns its complex conjugate. double complex cproj(double complex z) cproj() takes a complex floating-point number and returns its projection onto the Riemann sphere, as defined in the C standard. For non- infinite inputs, the return value is equal to the input value. double complex csqrt(double complex z) csqrt() takes a complex floating-point number and returns its square root, with a branch cut on the negative real axis. double complex cexp(double complex z) double complex clog(double complex z) cexp() and clog() take a complex floating-point number and return its base-e exponential and logarithm, respectively. clog() has a branch cut on the negative real axis. double complex cpow(double complex z, double complex w) cpow() takes two complex floating-point numbers, and returns the first raised to the power of the second, with a branch cut for the first parameter along the negative real axis. double complex csin(double complex z) double complex ccos(double complex z) double complex ctan(double complex z) csin(), ccos(), and ctan() take a complex floating-point number and return its sine, cosine, and tangent, respectively. double complex casin(double complex z) double complex cacos(double complex z) double complex catan(double complex z) casin(), cacos(), and catan() take a complex floating-point number and return its inverse sine, cosine, and tangent, respectively. casin() and cacos() have branch cuts outside the interval [-1, 1] on the real axis, and catan() has a branch cut outside the interval [-i, i] on the imaginary axis. double complex csinh(double complex z) double complex ccosh(double complex z) double complex ctanh(double complex z) csinh(), ccosh(), and ctanh() take a complex floating-point number and return its hyperbolic sine, cosine, and tangent, respectively. double complex casinh(double complex z) double complex cacosh(double complex z) double complex catanh(double complex z) casinh(), cacosh(), and catanh() take a complex floating-point number and return its inverse hyperbolic sine, cosine, and tangent, respec- tively. casinh() has a branch cut outside the interval [-i, i] on the imaginary axis. cacosh() has a branch cut at values less than 1 on the real axis. catanh() has a branch cut outside the interval [-1, 1] on the real axis. NOTE
Note that the complex math functions are not, in general, equivalent to their real counterparts for inputs on the real axis. For example, csqrt(-1 + 0i) is 0 + i, whereas sqrt(-1) is NaN. SEE ALSO
cabs(3), cacos(3), cacosh(3), carg(3), casin(3), casinh(3), catan(3), catanh(3), ccos(3), ccosh(3), cexp(3), cimag(3), clog(3), conj(3), cpow(3), cproj(3), creal(3), csin(3), csinh(3), csqrt(3), ctan(3), ctanh(3), math(3) STANDARDS
The <complex.h> functions conform to ISO/IEC 9899:2011. BSD
August 16, 2012 BSD

Featured Tech Videos