Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C programming/complex.h/carg

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Prototypes double carg(double complex z); float cargf(float complex z); long double cargl(long double complex z); Description carg is a standard library function which calculates the argument (phase angle) of a complex number. It takes a single parameter and returns the phase angle of that value (converted if necessary to a complex number) within the range [π, −π]. This function takes a single parameter of type complex and returns a result of type double. A complex number can be represented: in rectangular co-ordinates as in polar co-ordinates as where: A = creal(Z) is the real part B = cimag(Z) is the imaginary part r = cabs(z) is the radius a = carg(z) is the phase (angle or the argument) Hence this function returns phase of complex number Z used in polar co-ordinates. The return value is in radians, in the range [π, -π]. When we use this function, we must include the <complex.h> header file. Synopsis carg function #include <complex.h> double carg(double complex z); float cargf(float complex z); long double cargl(long double complex z); Example 1 /* conversion of a real number from its Cartesian to polar form */ #include <stdio.h> #include <complex.h> int main() { double complex z = -4.4 + 3.3 * I; double x = creal(z); double y = cimag(z); double radius = cabs(z); double argument = carg(z); printf("cartesian(x, y): (%4.1f, %4.1f)\n", x, y); printf("polar(r, theta): (%4.1f, %4.1f)\n", radius, argument); return 0; } Output: C in a Nutshell:carg Cartesian(x, y): (-4.4, 3.3) polar(r, theta): (5.5, 2.5) References deep