carg


carg

Calculates the argument of a complex number

 #include <complex.h> double carg ( double complex z  ); float cargf ( float complex z  ); long double cargl ( long double complex z  ); 

The carg( ) function determines the argument of a complex number, or the angle it forms with the origin and the positive part of the real axis. A complex number is defined in polar coordinates by its argument and modulus (or radius), which is the same as the absolute value of the complex number, given by cabs( ). The return value of carg( ) is in radians, and within the range [-p, p]. For a complex number z = x + y x i, where x and y are real numbers, carg(z) is equal to atan2( y, x).

Example

 /* Convert a real number from Cartesian to polar coordinates. */ double complex z = -4.4 + 3.3 * I; double radius = cabs( z ); double argument = carg( z ); double x = creal( z ); double y = cimag( z ); printf( "Cartesian (x, y): (%4.1f, %4.1f)\n", x, y ); printf( "Polar (r, theta): (%4.1f, %4.1f)\n", radius, argument ); 

This code produces the following output:

 Cartesian (x, y): (-4.4,  3.3) Polar (r, theta): ( 5.5,  2.5) 

See Also

cabs( ), cimag( ), creal( ), carg( ), conj( ), cproj( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net