| 1 |
'\" t |
| 2 |
.\" Copyright 2002, Walter Harms <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: GPL-1.0-or-later |
| 6 |
.\" |
| 7 |
.TH carg 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
carg, cargf, cargl \- calculate the complex argument |
| 10 |
.SH LIBRARY |
| 11 |
Math library |
| 12 |
.RI ( libm ,\~ \-lm ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <complex.h> |
| 16 |
.P |
| 17 |
.BI "double carg(double complex " z ");" |
| 18 |
.BI "float cargf(float complex " z ");" |
| 19 |
.BI "long double cargl(long double complex " z ");" |
| 20 |
.fi |
| 21 |
.SH DESCRIPTION |
| 22 |
These functions calculate the complex argument (also called phase angle) of |
| 23 |
.IR z , |
| 24 |
with a branch cut along the negative real axis. |
| 25 |
.P |
| 26 |
A complex number can be described by two real coordinates. |
| 27 |
One may use rectangular coordinates and gets |
| 28 |
.P |
| 29 |
.in +4n |
| 30 |
.EX |
| 31 |
z = x + I * y |
| 32 |
.EE |
| 33 |
.in |
| 34 |
.P |
| 35 |
where |
| 36 |
.I x\~=\~creal(z) |
| 37 |
and |
| 38 |
.IR y\~=\~cimag(z) . |
| 39 |
.P |
| 40 |
Or one may use polar coordinates and gets |
| 41 |
.P |
| 42 |
.in +4n |
| 43 |
.EX |
| 44 |
z = r * cexp(I * a) |
| 45 |
.EE |
| 46 |
.in |
| 47 |
.P |
| 48 |
where |
| 49 |
.I r\~=\~cabs(z) |
| 50 |
is the "radius", the "modulus", the absolute value of |
| 51 |
.IR z , |
| 52 |
and |
| 53 |
.I a\~=\~carg(z) |
| 54 |
is the "phase angle", the argument of |
| 55 |
.IR z . |
| 56 |
.P |
| 57 |
One has: |
| 58 |
.P |
| 59 |
.in +4n |
| 60 |
.EX |
| 61 |
tan(carg(z)) = cimag(z) / creal(z) |
| 62 |
.EE |
| 63 |
.in |
| 64 |
.SH RETURN VALUE |
| 65 |
The return value is in the range of [\-pi,pi]. |
| 66 |
.SH ATTRIBUTES |
| 67 |
For an explanation of the terms used in this section, see |
| 68 |
.BR attributes (7). |
| 69 |
.TS |
| 70 |
allbox; |
| 71 |
lbx lb lb |
| 72 |
l l l. |
| 73 |
Interface Attribute Value |
| 74 |
T{ |
| 75 |
.na |
| 76 |
.nh |
| 77 |
.BR carg (), |
| 78 |
.BR cargf (), |
| 79 |
.BR cargl () |
| 80 |
T} Thread safety MT-Safe |
| 81 |
.TE |
| 82 |
.SH STANDARDS |
| 83 |
C11, POSIX.1-2008. |
| 84 |
.SH HISTORY |
| 85 |
glibc 2.1. |
| 86 |
C99, POSIX.1-2001. |
| 87 |
.SH SEE ALSO |
| 88 |
.BR cabs (3), |
| 89 |
.BR complex (7) |