Logarithmic Tables

Here is some real C code to compute (but with no error-checking) logarithm base e.



/*
 * This code is loosely based on Freeware;
 * x_log() is similar to log() but does no error-checking.
 * x_frexp() accomplishes the built-in function frexp()
 *  but is much slower.  It is included to make this
 *  wholly self-contained.
 * No copyright is claimed by Septimus G. Stevens VII.
 * Use of this code for satiric purposes is encouraged.
 */
 
double x_frexp(double x, int *xpon)
{
	int	xp = 0;
	while (x >= 1)
		x /= 2, xp++;
	while (x < 0.5)
		x *= 2, xp--;
	*xpon = xp;
	return x;
}

double x_log(double x)
{
        double  z, w;
        int     xpon;

        x = 1.4142135623730950488 * x_frexp(x, &xpon);
	z = 2 * (x-1) / (x+1);
	w = z * z;
	x = z;
	z *= 	- w * 64.124943423745581147
		+ w*w * 16.383943563021534222
		- w*w*w * 0.78956112887491257267;
	z /=    -769.49932108494879777
		+ w * 312.03222091924532844
		- w*w * 35.667977739034646171
		+ w*w*w;
        return x + z + xpon * .69314718055994530941
		- .3465735902799726547;
}