sqrt, sqrtl
Calculates square
root
Declaration:
Real:
double sqrt(double x);
long
double sqrtl(long double @E(x));
Complex:
complex sqrt(complex x);
Remarks:
sqrt calculates the positive square root of the input value.
For complex numbers x, sqrt(x) gives the complex root whose
arg is arg(x) /
2.The complex square root is defined by
sqrt(z) =
sqrt(abs(z)) * ( cos(arg(z)/2) + i * sin(arg(z)/2) )
Return Value:
Real sqrt and sqrtl return the square root of x.
If x is real and positive, the result is positive.
If x is real and negative, sqrt sets errno to EDOM (domain
error).
Error handling for real sqrt can be modified via matherr;
for sqrtl, via
Example:
#include
<math.h>
#include
<stdio.h>
int main(void)
{
double x = 4.0,
result;
result = sqrt(x);
printf("The
square root of %lf is %lf\n", x, result);
return 0;
}
0 comments:
Post a Comment