Sunday, March 4, 2012

Approximation of Natural Log

Taking the Taylor series of ln(1+x) about x=0 gives the following result, as demonstrated by the MATLAB line:
>> syms x;
>> taylor(log(1+x))
ans =
x^5/5 - x^4/4 + x^3/3 - x^2/2 + x
The common approximation is that as long as x is small, ln(1+x) ~= x. How close is this approximation anyways? In the following Excel table, various small and incrementing values of x were chosen, along with the actual ln(1+x) values. In all cases, the approximation yields a slightly higher answer, since the most significant term of -x^2 was left out. The difference and the % error to the actual values were calculated:

x ln(1+x)  + / - % Error
0.000 0.00000 0.00000 #DIV/0!
0.005 0.00499 0.00001 0.250%
0.010 0.00995 0.00005 0.499%
0.015 0.01489 0.00011 0.748%
0.020 0.01980 0.00020 0.997%
0.025 0.02469 0.00031 1.245%
0.030 0.02956 0.00044 1.493%
0.035 0.03440 0.00060 1.740%
0.040 0.03922 0.00078 1.987%
0.045 0.04402 0.00098 2.233%
0.050 0.04879 0.00121 2.480%
0.075 0.07232 0.00268 3.705%
0.100 0.09531 0.00469 4.921%
0.200 0.18232 0.01768 9.696%
0.300 0.26236 0.03764 14.345%
0.400 0.33647 0.06353 18.881%
0.500 0.40547 0.09453 23.315%
0.750 0.55962 0.19038 34.021%
1.000 0.69315 0.30685 44.270%

Observing for x is 0.05 or smaller, it seems as though the absolute error grows in a quadratic manner, while the percentage error grows constantly. But most importantly, if the approximation of ln(1+x) = x wants to stay within 5% of the actual answer, the value of x shouldn't exceed 0.1.