invsqrt
Compute the reciprocal of the square root of x.
Interface Definition
C interface:
float invsqrtf(float x);
double invsqrt(double x);
long double invsqrtl(long double x);
Fortran interface:
RES = SQRTF(X);
RES = SQRT(X);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
Return Value
- If input x is +0, the return value is +∞.
- If input x is -0, the return value is -∞.
- If input x is less than 0, the return value is NaN.
- If input x is +∞, the return value is 0.0.
- If input x is NaN, the return value is NaN.
Dependencies
C: "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // typical usage double x1 = 1.0, x2 = 2.0, x3 = 3.0, x4 = 4.0; // special handling double a = 0.0, b = INFINITY, c = -INFINITY, d = NAN; // print result printf("invsqrt(1.0) = %.15f\n", invsqrt(x1)); printf("invsqrt(2.0) = %.15f\n", invsqrt(x2)); printf("invsqrt(3.0) = %.15f\n", invsqrt(x3)); printf("invsqrt(4.0) = %.15f\n", invsqrt(x4)); printf("invsqrt(0.0) = %.15f\n", invsqrt(a)); printf("invsqrt(INFINITY) = %.15f\n", invsqrt(b)); printf("invsqrt(-INFINITY) = %.15f\n", invsqrt(c)); printf("invsqrt(NAN) = %.15f\n", invsqrt(d)); /* * invsqrt(1.0) = 1.000000000000000 * invsqrt(2.0) = 0.707106781186548 * invsqrt(3.0) = 0.577350269189626 * invsqrt(4.0) = 0.500000000000000 * invsqrt(0.0) = inf * invsqrt(INFINITY) = 0.000000000000000 * invsqrt(-INFINITY) = nan * invsqrt(NAN) = nan * */ |
Parent topic: Power and Root Functions