CodeCogs - An iteractive open source Numerical library Welcome... Login
CodeCogs
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Pages

Valid RSS

CMath.h

sqrt

About | FAQ | Contact
About FAQ Contact

Square root function

viewed 28036 times


+View other versions (3)
Contents -

Interface

#include <math.h>
double sqrt (double x)
long sqrtl (long double x)
float sqrtf (float x)

#include <complex.h>
complex sqrt (complex x)
double complex csqrt (double complex x)
float complex csqrtf (float complex x)
long double complex csqrtl (long double complex x)

Description

The sqrt function computes the non-negative square root of x, i.e

sqrt(x)=\sqrt x

For complex numbers x, sqrt returns the complex root of x, using the following formula

where \mathrm{arg}(x) is the argument of x.

Example 1:
#include <stdio.h>
#include <math.h>
 
int main()
{
  double x = 1234321;
  double result = sqrt(x);
  printf("The square root of %.2lf is %.2lf\n", x, result);
  return 0;
}

Ouput:
The square root of 1234321.00 is 1111.00

Special Values

sqrt ( -0 ) returns -0.
sqrt ( x ) returns a NaN and generates a domain error for x < 0.

Standards

The sqrt function conforms to ISO/IEC 9899:1999(E).

Compatibility

DOSUNIXWindowsANSI CC++ only
sqrtl
Real sqrt
Complex sqrt
Complex csqrt

Last Modified: 2009-11-01 08:42:53     Page Rendered: 2010-02-09 12:39:48

Page Comments

Format Excel Equations

  You must login to leave a messge


Valid CSS!   Valid XHTML 1.0 Transitional