From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/numeric%2Fcomplex%2Fcsqrt.html | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 devdocs/c/numeric%2Fcomplex%2Fcsqrt.html (limited to 'devdocs/c/numeric%2Fcomplex%2Fcsqrt.html') diff --git a/devdocs/c/numeric%2Fcomplex%2Fcsqrt.html b/devdocs/c/numeric%2Fcomplex%2Fcsqrt.html new file mode 100644 index 00000000..66c0b835 --- /dev/null +++ b/devdocs/c/numeric%2Fcomplex%2Fcsqrt.html @@ -0,0 +1,62 @@ +

csqrtf, csqrt, csqrtl

Defined in header <complex.h>
float complex       csqrtf( float complex z );
+
(1) (since C99)
double complex      csqrt( double complex z );
+
(2) (since C99)
long double complex csqrtl( long double complex z );
+
(3) (since C99)
Defined in header <tgmath.h>
#define sqrt( z )
+
(4) (since C99)
+1-3) Computes the complex square root of z with branch cut along the negative real axis.
+4) Type-generic macro: If z has type long double complex, csqrtl is called. if z has type double complex, csqrt is called, if z has type float complex, csqrtf is called. If z is real or integer, then the macro invokes the corresponding real function (sqrtf, sqrt, sqrtl). If z is imaginary, the corresponding complex number version is called.

Parameters

+ +
z - complex argument

Return value

If no errors occur, returns the square root of z, in the range of the right half-plane, including the imaginary axis ([0; +∞) along the real axis and (−∞; +∞) along the imaginary axis.)

+

Error handling and special values

Errors are reported consistent with math_errhandling

+

If the implementation supports IEEE floating-point arithmetic,

+

Example

#include <stdio.h>
+#include <complex.h>
+ 
+int main(void)
+{
+    double complex z1 = csqrt(-4);
+    printf("Square root of -4 is %.1f%+.1fi\n", creal(z1), cimag(z1));
+ 
+    double complex z2 = csqrt(conj(-4)); // or, in C11, CMPLX(-4, -0.0)
+    printf("Square root of -4-0i, the other side of the cut, is "
+           "%.1f%+.1fi\n", creal(z2), cimag(z2));
+}

Output:

+
Square root of -4 is 0.0+2.0i
+Square root of -4-0i, the other side of the cut, is 0.0-2.0i

References

See also

+ + +
+
(C99)(C99)(C99)
computes the complex power function
(function)
+
(C99)(C99)
computes square root (\(\small{\sqrt{x} }\)x)
(function)
C++ documentation for sqrt
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/numeric/complex/csqrt +

+
-- cgit v1.2.3