csqrtf, csqrt, csqrtl

< c‎ | numeric‎ | complex
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

C
 Language Standard Library Type support Dynamic memory management Error handling Program utilities Date and time utilities Strings library Algorithms Numerics Input/output support Localization support Thread support (C11) Atomic operations (C11)

Complex number arithmetic
Types and the imaginary constant
Manipulation
Power and exponential functions
 cpow csqrt
Trigonometric functions
Hyperbolic functions

 Defined in header `` float complex       csqrtf( float complex z ); (since C99) double complex      csqrt( double complex z ); (since C99) long double complex csqrtl( long double complex z ); (since C99)

Computes the complex square root of `z` with branch cut along the negative real axis.

Contents

Parameters

 z - complex argument

Return value

The complex square root of `z` in the interval [0; +∞) along the real axis and in the interval (−∞; +∞) along the imaginary axis.

Example

```#include <stdio.h>
#include <complex.h>

int main(void)
{
double complex z = csqrt(-1.0 + 0.0*I);
printf("%f%+fi\n", creal(z), cimag(z));

z = csqrt(1.0 + 2.0*I);
printf("%f%+fi\n", creal(z), cimag(z));

return 0;
}```

Output:

```0.000000+1.000000i
1.272020+0.786151i```

See also

 cpowcpowfcpowl(C99)(C99)(C99) computes the complex power function (function)  sqrtsqrtfsqrtl(C99)(C99) computes square root (√x) (function)  C++ documentation for sqrt