December 2005
Beginner to intermediate
618 pages
20h 19m
English
csqrt
Calculates the square root of a complex number
#include <complex.h> double complexcsqrt( double complexz); float complexcsqrtf( float complexz); long double complexcsqrtl( long double complexz);
The csqrt() function
returns the complex square root of its complex number
argument.
double complex z = 1.35 − 2.46 * I;
double complex c, d;
c =csqrt( z );
d = c * c;
printf("If the square root of %.2f %+.2f \xD7 I equals %.2f %+.2f \xD7 I,"
"\n", creal(z), cimag(z), creal(c), cimag(c) );
printf("then %.2f %+.2f \xD7 I squared should equal %.2f %+.2f \xD7 I.\n",
creal(c), cimag(c), creal(d), cimag(d) );This code produces the following output:
If the square root of 1.35 -2.46 × I equals 1.44 -0.85 × I, then 1.44 -0.85 × I squared should equal 1.35 -2.46 × I.
Read now
Unlock full access