SQRT(3M) SQRT(3M)
sqrt, fsqrt, sqrtf, sqrtl, cbrt, cbrtl  cube root, square root
#include <math.h>
double sqrt(double x);
float fsqrt(float x);
float sqrtf(float x);
long double sqrtl(long double x);
double cbrt(double x);
long double cbrtl(long double x);
The singleprecision and long doubleprecision routines listed above are
only available in the standard math library, lm, and in lmx.
The sqrt functions return the nonnegative square root of their single
argument x. The function sqrt both accepts and returns values of type
double. The functions fsqrt and sqrtf accept and return float values.
The function sqrtl both accepts and returns values of type long double.
A fast version of sqrt and fsqrt which are slightly less accurate are
available in the library lfastm. On mips2 and newer processors, those
routines are identical to the ones in libm.a, because there are hardware
square root instructions.
The cbrt functions return the cube root of their single argument x. The
function cbrt both accepts and returns values of type double. The
function cbrtl both accepts and returns values of type long double.
In the diagnostics below, functions in the standard math library libm.a,
are referred to as lm versions, those in math library libmx.a are
referred to as lmx versions, and those in the the BSD math library
libm43.a are referred to as lm43 versions. The lm and lmx versions
always return the default Quiet NaN and set errno to EDOM when a NaN is
used as an argument. A NaN argument usually causes the lm43 versions to
return the same argument. The lm43 versions never set errno.
If x is negative, the sqrt functions return a quiet NaN. The lm and
lm43 versions also set the flag in the floatingpoint coprocessor to
indicate an invalid operation. The functions in the standard math library
lm and in library lmx also set errno to EDOM.
See matherr(3M) for a description of error handling for lmx functions.
Long double operations on this system are only supported in round to
nearest rounding mode (the default). The system must be in round to
nearest rounding mode when calling any of the long double functions, or
Page 1
SQRT(3M) SQRT(3M)
incorrect answers will result.
Users concerned with portability to other computer systems should note
that the long double and float versions of these functions are optional
according to the ANSI C Programming Language Specification ISO/IEC 9899 :
1990 (E).
Long double functions have been renamed to be compliant with the ANSIC
standard, however to be backward compatible, they may still be called
with the double precision function name prefixed with a q.
User's code which calls sqrt() or sqrtf() will be compiled into the
machine instruction sqrt.d or sqrt.s if the code #includes <math.h>.
ERROR (due to Roundoff etc.) [Toc] [Back] cbrt is accurate to within 0.7 ulps.
libm.a sqrt conforms to IEEE 754 and is correctly rounded in accordance
with the rounding mode in force; the error is less than half an ulp in
the default mode (round to nearest).
The libfastm.a sqrt and fsqrt error is a maximum of one ulp. (See
however, the comments regarding lfastm above.)
An ulp is one Unit in the Last Place carried.
math(3M), libmx(3M)
W. Kahan
Page 2
CPLXEXP(3C++) CPLXEXP(3C++)
exp, log, pow, sqrt  exponential, logarithm, power, square root
functions for the C++ complex library
#include <complex.h>
class complex {
public:
friend complex exp(complex);
friend complex log(complex);
friend complex pow(double, complex);
friend complex pow(complex, int);
friend complex pow(complex, double);
friend complex pow(complex, complex);
friend complex sqrt(complex);
};
The following math functions are overloaded by the complex library,
where:
 x, y, and z are of type complex.
z <b>= exp(x<b>) Returns ex.
z <b>= log(x<b>) Returns the natural logarithm of x.
z <b>= pow(x<b>, y<b>) Returns xy.
z <b>= sqrt(x<b>) Returns the square root of x, contained in the first or
fourth quadrants of the complex plane.
complex(3C++), cartpol(3C++), cplxerr(3C++), cplxops(3C++), and
cplxtrig(3C++).
exp returns (0, 0) when the real part of x is so small, or the imaginary
part is so large, as to cause overflow. When the real part is large
enough to cause overflow, exp returns (HUGE, HUGE) if the cosine and sine
of the imaginary part of x are positive, (HUGE, HUGE) if the cosine is
positive and the sine is not, (HUGE, HUGE) if the sine is positive and
the cosine is not, and (HUGE, HUGE) if neither sine nor cosine is
positive. In all these cases, errno is set to ERANGE.
log returns (HUGE, 0) and sets errno to EDOM when x is (0, 0). A
message indicating SING error is printed on the standard error output.
These errorhandling procedures may be changed with the function
complex_error (cplxerr(3C++)).
Page 1
SQRT(3F) SQRT(3F)
sqrt, dsqrt, qsqrt, csqrt, zsqrt, cqsqrt  FORTRAN square root intrinsic
function
real r1, r2
double precision dp1, dp2
real*16 qp1, qp2
complex cx1, cx2
complex*16 cd1, cd2
complex*32 cq1, cq2
r2 = sqrt(r1)
dp2 = dsqrt(dp1)
dp2 = sqrt(dp1)
qp2 = qsqrt(qp1)
qp2 = sqrt(qp1)
cx2 = csqrt(cx1)
cx2 = sqrt(cx1)
cd2 = zsqrt(cd1)
cd2 = sqrt(cd1)
cq2 = cqsqrt(cq1)
cq2 = sqrt(cq1)
sqrt returns the real square root of its real argument. dsqrt returns
the doubleprecision square root of its doubleprecision argument. qsqrt
returns the real*16 square root of its real*16 argument. The value of
the argument of sqrt, dsqrt, and qsqrt must be greater than or equal to
zero.
csqrt returns the complex square root of its complex argument. The
result of csqrt is the principle value with the real part greater than or
equal to zero. When the real part is zero, the imaginary part is greater
than or equal to zero.
zsqrt returns the complex*16 square root of its complex*16 argument.
cqsqrt returns the complex*32 square root of its complex*32 argument.
sqrt, the generic form, will become dsqrt, qsqrt, csqrt, zsqrt, or cqsqrt
as required by its argument type.
exp(3M).
Page 1
SQRT(3M) Last changed: 1698
SQRT, DSQRT, CSQRT, CDSQRT  Computes square root
UNICOS and UNICOS/mk systems:
SQRT ([X=]x)
DSQRT ([X=]x)
CSQRT ([X=]x)
UNICOS and IRIX systems:
CDSQRT ([X=]x)
UNICOS, UNICOS/mk, and IRIX systems
Fortran 90
CDSQRT is a compiler extension to Fortran 90.
SQRT is the generic function name. These functions are elemental
functions for the CF90 compiler.
A vector version of this intrinsic exists on UNICOS and UNICOS/mk
systems. On UNICOS/mk systems, the vector version of this intrinsic
is used when h vector3 (C compiler) or O vector3 or O3 (Fortran
compiler) has been specified on the compiler command line.
The entry point CDSQRT is provided for support in other languages. It
is not recognized as an intrinsic function; therefore, you must use
the CDIR$ VFUNCTION directive to allow vectorization.
CDSQRT is called implicitly by the Fortran 90 compiler as a result of
a generic SQRT call with a complex doubleprecision argument.
1/2
These functions evaluate y = x .
CAL Register Usage (Cray Research Systems Only)
Scalar SQRT: SQRT% (callbyregister)
on entry (S1) = argument
on exit (S1) = result
Vector SQRT: %SQRT% (callbyregister)
on entry (V1) = argument vector
on exit (V1) = result vector
Scalar DSQRT: DSQRT% (callbyregister)
on entry (S1) and (S2) = argument
on exit (S1) and (S2) = result
Vector DSQRT: %DSQRT% (callbyregister)
on entry (V1) and (V2) = argument vector
on exit (V1) and (V2) = result vector
Scalar CSQRT: CSQRT% (callbyregister)
on entry (S1) and (S2) = argument
on exit (S1) and (S2) = result
Vector CSQRT: %CSQRT% (callbyregister)
on entry (V1) and (V2) = argument vector
on exit (V1) and (V2) = result vector
Argument Range [Toc] [Back]
SQRT, DSQRT:
2450
0 <= x < infinity (infinity is approximately 10 )
308
On UNICOS/mk systems, infinity is approximately 10
CSQRT:
x  < infinity, x  < infinity
r i
CDSQRT:
x  < infinity, x  < infinity
r i CDSQRT is an outmoded routine for the CF90 compiler. Refer to the
Fortran Language Reference Manual, Volume 3, publication SR3905, for
information about outmoded features and their preferred standard
alternatives.
The name of the SQRT, DSQRT, and CSQRT intrinsic can be passed as an
argument. The name of the CDSQRT intrinsic cannot be passed as an
argument.
SQRT returns the real square root of its real argument.
DSQRT returns the doubleprecision square root of its doubleprecision
argument.
CSQRT returns the complex square root of its complex argument.
CDSQRT returns the complex doubleprecision square root of its complex
doubleprecision argument.
On CRAY T90 systems that support IEEE arithmetic, the following return
values occur:
SQRT(0) = 0
SQRT(0) = 0
SQRT(x) = NaN if x < 0
SQRT(NaN) = NaN
SQRT( infinity ) = infinity
Intrinsic Procedures Reference Manual, publication SR2138, for the
printed version of this man page.
SQRT(3M) Last changed: 1698
SQRT, DSQRT, CSQRT, CDSQRT  Computes square root
UNICOS and UNICOS/mk systems:
SQRT ([X=]x)
DSQRT ([X=]x)
CSQRT ([X=]x)
UNICOS and IRIX systems:
CDSQRT ([X=]x)
UNICOS, UNICOS/mk, and IRIX systems
Fortran 90
CDSQRT is a compiler extension to Fortran 90.
SQRT is the generic function name. These functions are elemental
functions for the CF90 compiler.
A vector version of this intrinsic exists on UNICOS and UNICOS/mk
systems. On UNICOS/mk systems, the vector version of this intrinsic
is used when h vector3 (C compiler) or O vector3 or O3 (Fortran
compiler) has been specified on the compiler command line.
The entry point CDSQRT is provided for support in other languages. It
is not recognized as an intrinsic function; therefore, you must use
the CDIR$ VFUNCTION directive to allow vectorization.
CDSQRT is called implicitly by the Fortran 90 compiler as a result of
a generic SQRT call with a complex doubleprecision argument.
1/2
These functions evaluate y = x .
CAL Register Usage (Cray Research Systems Only)
Scalar SQRT: SQRT% (callbyregister)
on entry (S1) = argument
on exit (S1) = result
Vector SQRT: %SQRT% (callbyregister)
on entry (V1) = argument vector
on exit (V1) = result vector
Scalar DSQRT: DSQRT% (callbyregister)
on entry (S1) and (S2) = argument
on exit (S1) and (S2) = result
Vector DSQRT: %DSQRT% (callbyregister)
on entry (V1) and (V2) = argument vector
on exit (V1) and (V2) = result vector
Scalar CSQRT: CSQRT% (callbyregister)
on entry (S1) and (S2) = argument
on exit (S1) and (S2) = result
Vector CSQRT: %CSQRT% (callbyregister)
on entry (V1) and (V2) = argument vector
on exit (V1) and (V2) = result vector
Argument Range [Toc] [Back]
SQRT, DSQRT:
2450
0 <= x < infinity (infinity is approximately 10 )
308
On UNICOS/mk systems, infinity is approximately 10
CSQRT:
x  < infinity, x  < infinity
r i
CDSQRT:
x  < infinity, x  < infinity
r i CDSQRT is an outmoded routine for the CF90 compiler. Refer to the
Fortran Language Reference Manual, Volume 3, publication SR3905, for
information about outmoded features and their preferred standard
alternatives.
The name of the SQRT, DSQRT, and CSQRT intrinsic can be passed as an
argument. The name of the CDSQRT intrinsic cannot be passed as an
argument.
SQRT returns the real square root of its real argument.
DSQRT returns the doubleprecision square root of its doubleprecision
argument.
CSQRT returns the complex square root of its complex argument.
CDSQRT returns the complex doubleprecision square root of its complex
doubleprecision argument.
On CRAY T90 systems that support IEEE arithmetic, the following return
values occur:
SQRT(0) = 0
SQRT(0) = 0
SQRT(x) = NaN if x < 0
SQRT(NaN) = NaN
SQRT( infinity ) = infinity
Intrinsic Procedures Reference Manual, publication SR2138, for the
printed version of this man page.
[ Back ]
