_fyl2xp1 -- Calculate y * log2(x + 1)

Format

#include <builtin.h>
double _fyl2xp1(double x, double y);

Language Level: Extension
_fyl2xp1 computes the base-2 logarithm of x+1 and multiplies it by y (y * log2(x+1)). The variable x must be in the range -(1-(sqrt(2)/2)) to (sqrt(2) - 1). _fyl2xp1 provides improved accuracy over _fyl2x when logarithms of numbers very close to 1 are computed. When x is small, you can retain more significant digits by providing x to the _fyl2xp1 function than by providing x+1 as an argument to the _fyl2x function.

Because it is a built-in function and has no backing code in the library:

Return Value
_fyl2xp1 returns the result of the formula y * log2(x+1).

Example
This example calculates (y * log2(x + 1)), after prompting the user for values of x and y.

#include <builtin.h>
#include <stdio.h>
int main(void)
{
   double x, y;
   printf("Enter a value for x:\n");
   scanf("%lf", &x);
   printf("Enter a value for y:\n");
   scanf("%lf", &y);
   printf("%lf * log2(%lf + 1) is %lf.\n", y, x, _fyl2xp1(x, y));
   return 0;
   /*************************************************************
      Assuming you enter 0.001 for x and 2.0 for y.
      The output should be:
      2.000000 * log2(0.001000 + 1) is 0.002884.
   *************************************************************/
}



_fyl2x -- Calculate y * log2(x)
_f2xm1 -- Calculate (2**x) - 1
<builtin.h>