| Types and the imaginary constant | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
| Manipulation | |||||||||||||||||||||||||||||||
| Power and exponential functions | |||||||||||||||||||||||||||||||
| Trigonometric functions | |||||||||||||||||||||||||||||||
| Hyperbolic functions | |||||||||||||||||||||||||||||||
Defined in header <complex.h> | ||
| (1) | (since C99) | |
| (2) | (since C99) | |
| (3) | (since C99) | |
Defined in header <tgmath.h> | ||
#define acos( z ) | (4) | (since C99) |
z with branch cuts outside the interval[−1,+1] along the real axis.z has typelongdoublecomplex,cacosl is called. ifz has typedoublecomplex,cacos is called, ifz has typefloatcomplex,cacosf is called. Ifz is real or integer, then the macro invokes the corresponding real function (acosf,acos,acosl). Ifz is imaginary, then the macro invokes the corresponding complex number version.Contents |
| z | - | complex argument |
If no errors occur, complex arc cosine ofz is returned, in the range a strip unbounded along the imaginary axis and in the interval [0; π] along the real axis.
Errors are reported consistent withmath_errhandling.
If the implementation supports IEEE floating-point arithmetic,
z is±0+0i, the result isπ/2-0iz is±0+NaNi, the result isπ/2+NaNiz isx+∞i (for any finite x), the result isπ/2-∞iz isx+NaNi (for any nonzero finite x), the result isNaN+NaNi andFE_INVALID may be raised.z is-∞+yi (for any positive finite y), the result isπ-∞iz is+∞+yi (for any positive finite y), the result is+0-∞iz is-∞+∞i, the result is3π/4-∞iz is+∞+∞i, the result isπ/4-∞iz is±∞+NaNi, the result isNaN±∞i (the sign of the imaginary part is unspecified)z isNaN+yi (for any finite y), the result isNaN+NaNi andFE_INVALID may be raisedz isNaN+∞i, the result isNaN-∞iz isNaN+NaNi, the result isNaN+NaNiInverse cosine (or arc cosine) is a multivalued function and requires a branch cut on the complex plane. The branch cut is conventially placed at the line segments(-∞,-1) and(1,∞) of the real axis.
The mathematical definition of the principal value of arc cosine isacos z =| 1 |
| 2 |
For any z,acos(z) = π - acos(-z)
#include <stdio.h>#include <math.h>#include <complex.h> int main(void){doublecomplex z= cacos(-2);printf("cacos(-2+0i) = %f%+fi\n",creal(z),cimag(z)); doublecomplex z2= cacos(conj(-2));// or CMPLX(-2, -0.0)printf("cacos(-2-0i) (the other side of the cut) = %f%+fi\n",creal(z2),cimag(z2)); // for any z, acos(z) = pi - acos(-z)double pi=acos(-1);doublecomplex z3=ccos(pi-z2);printf("ccos(pi - cacos(-2-0i) = %f%+fi\n",creal(z3),cimag(z3));}
Output:
cacos(-2+0i) = 3.141593-1.316958icacos(-2-0i) (the other side of the cut) = 3.141593+1.316958iccos(pi - cacos(-2-0i) = 2.000000+0.000000i
(C99)(C99)(C99) | computes the complex arc sine (function)[edit] |
(C99)(C99)(C99) | computes the complex arc tangent (function)[edit] |
(C99)(C99)(C99) | computes the complex cosine (function)[edit] |
(C99)(C99) | computes arc cosine (\({\small\arccos{x} }\)arccos(x)) (function)[edit] |
C++ documentation foracos | |