csqrtf, csqrt, csqrtl - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# csqrtf, csqrt, csqrtl

From cppreference.com
< c‎ | numeric‎ | complex

Defined in header `<complex.h>` |  |
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.

### [edit] Parameters

z | - | complex argument

### [edit] Return value

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

### [edit] Example

Run this code

    #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

### [edit] See also

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

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/numeric/complex/csqrt&oldid=70636"