HPlogo HP-UX Reference > R

rsqrt(3M)

HP Integrity Server Only
HP-UX 11i Version 2: December 2007 Update
» 

Technical documentation

 » Table of Contents

 » Index

NAME

rsqrt(), rsqrtf(), rsqrtl(), rsqrtw(), rsqrtq(), invsqrt(), invsqrtf(), invsqrtl(), invsqrtw(), invsqrtq() — reciprocal square root functions

SYNOPSIS

#include <math.h>

double rsqrt(double x);

float rsqrtf(float x);

long double rsqrtl(long double x);

extended rsqrtw(extended x);

quad rsqrtq(quad x);

double invsqrt(double x);

float invsqrtf(float x);

long double invsqrtl(long double x);

extended invsqrtw(extended x);

quad invsqrtq(quad x);

DESCRIPTION

rsqrt() returns the reciprocal of the non-negative square root of x.

The expression a*rsqrt(b) is intended as a higher performance alternative to a/sqrt(b). The two expressions are comparably accurate, but do not compute exactly the same value in every case. For example, a*rsqrt(a*a + b*b) can be just slightly greater than 1, in rare cases.

invsqrt() is equivalent to rsqrt(). It is provided in HP-UX to facilitate importing code from other platforms.

rsqrtf() and invsqrtf() are float versions of rsqrt() and invsqrt(); they take a float argument and returns a float result.

rsqrtl() and invsqrtl() are a long double version of rsqrt() and invsqrt(); they take a long double argument and returns a long double result.

rsqrtw() and invsqrtw() are an extended version of rsqrt() and invsqrt(); they take an extended argument and returns an extended result.

On HP-UX systems, rsqrtq() is equivalent to rsqrtl(), and invsqrtq() is equivalent to invsqrtl().

USAGE

To use these functions compile either with the default -Ae option or with the -Aa and the -D_HPUX_SOURCE options.

To use rsqrtw(), rsqrtq(), invsqrtw(), or invsqrtq(), compile also with the -fpwidetypes option.

To use any of these functions, make sure your program includes <math.h>, and link in the math library by specifying -lm on the compiler or linker command line.

RETURN VALUE

If x is ±0, rsqrt() returns ±INFINITY and raises the divide-by-zero exception.

If x is +INFINITY, rsqrt() returns +0.

If x is NaN, rsqrt() returns NaN.

If x is less than zero, rsqrt() returns NaN and raises the invalid floating-point exception.

rsqrt() raises the inexact exception whenever a rounded result does not equal the mathematical result.

ERRORS

No errors are defined.

SEE ALSO

sqrt(3M), math(5).

STANDARDS CONFORMANCE

These functions are not specified by any standard.