I've implemented his method, it works for most integers, especially positive numbers
I've noticed that 0/X, X/0, and 0/0 all result in 0
The code:
#include <stdio.h>
// assume our virtual machine support 8 decimal places
#define DBL_8_MIN 0.00000001 /* min 8-decimal-places positive number */
double f (int y) { return ((double)y - (double)DBL_8_MIN); }
double g (int y) { return ((double)y + (double)DBL_8_MIN); }
double bhartiya (int x, int y)
{
return (x/2.0) * (1.0/f(y) + 1.0/g(y));
}
int main ()
{
int x = 1;
int y = 1;
int u = 0;
int v = 0;
while (x < 999)
{
y = 1;
while (y < 999)
{
u = bhartiya (x, y);
v = ( x / y );
if (u != v)
{
printf(" %d/%d = %d .. but Bhartiya gives %d with y'=%.8lf & y''=%.8lf \n",x,y,v,u);
}
y++;
}
x++;
}
return 0;
}