Hello All,
I used my latest best polynomial program to determine the best empirical-polynomial model to fit ln(x) for 1 <= x <= 10. The Excel VBA program performs power-value transformations on x and y (= ln(x)) before using these transformed values in polynomial fits. Thus, the program goes through a large number of transformed-polynomial models. The result is an 8th order polynomial:
ln(x) = a0 + a1*y + a2*y^2 + ... + a8*y^8
Where y = sqrt(x).
Here is the pseudo code with the values for the coefficients a0 through a8. The maximum absolute error for the fit I obtained is 1.54E-5. I took the values of x using the sequence 1, 1.01, 1.02, 1.03, ..., 9.99, 10.0.
function ln(x)if x<=0 then raise error and exit
if x=1 then return 0
ln10 = 2.302585093
if x=10 then return ln10n=0
if x>10
do while x>10
x=x/10
n=n+1
loop
elseif x<1
do while x<1
x=10*x
n=n-1
loop
endy = sqrt(x)
z = -1.17472578289386e-03
z = z * y + 2.23235477256564e-02
z = z * y - 0.186434305125544
z = z * y + 0.899792871812638
z = z * y - 2.77773142836752
z = z * y + 5.74716024426924
z = z * y - 8.20298398274567
z = z * y + 8.74732523658923
z = z * y - 4.2482580027248return z + n*ln10
end function
Enjoy!
Namir
Edited: 12 Dec 2012, 6:09 a.m.