Building and Using a Logarithmic Table

Helmut Knaust, Department of Mathematical Sciences, UTEP, El Paso TX 79968
hknaust@utep.edu
10/22/2011

How to compute Square Roots?

To build a logarithmic table, one must be able to compute square roots. How to do this was already kown to the Babylonians.
An example: To compute (rational) approximations to  (Sqrt[10]), one starts with a reasonable guess such as (Subscript[x, 0])=3.
Since (Subscript[x, 0])=3 is too small (((Subscript[x, 0])^2)=9<10), (Subscript[y, 0])=(10/(Subscript[x, 0])) will be too large (((Subscript[y, 0])^2)=(100/9)>10), so a new guess will be their average:
(Subscript[x, 1])=(1/2)((Subscript[x, 0])+(10/(Subscript[x, o]))).
Computations using this algorithm are below. Note how fast the algorithm converges!

Square root of 10 :

x[0]=3;
x[n_]:=1/2(x[n-1]+10/x[n-1])
TableForm[Table[{x[k],N[x[k],20],N[x[k]^2,20]},{k,0,5}],TableHeadings->{None,{"(Subscript[x, n])","(Subscript[x, n])","((Subscript[x, n])^2)"}}]

Iteration yields approximations for (10^(1/4)), (10^(1/8)), etc.

4th root of 10:

x[0]=89/50;
x[n_]:=1/2(x[n-1]+(2161873163521/683644320912)/x[n-1])
TableForm[Table[{x[k],N[x[k],20],N[x[k]^4,20]},{k,0,3}],TableHeadings->{None,{"(Subscript[x, n])","(Subscript[x, n])","((Subscript[x, n])^4)"}}]

Building a Logarithmic Table

Using just (Sqrt[10])yields a very primitive logarithmic table. The first row contains numbers between 1 and 10, the second row their logarithms with base 10.

Table[{10^x,x},{x,0,1,1/2}]
Table[{10^x,x},{x,0,1,1/2}]//N

Using (Sqrt[10])and (10^(1/4)) yields a slightly more detailed table:

Table[{10^x,x},{x,0,1,1/4}]
Table[{10^x,x},{x,0,1,1/4}]//N

We will use a much more detailed table, using (10^(1/(1024))). Here is a subset of our table:

tab=Transpose[Table[{10^x,x},{x,0, 1, 1/1024}]//N];
Transpose[Table[Table[{10^x,x},{x,(k-1)/8,k/8-1/1024,2/1024}]//N,{k,1,8}]]

Here are some commands to look up the closest value in our table for a given number, and the two closest values (the “interpolation pair”), respectively.

lookupL[x_]:=tab[[All,Position[Abs[tab[[1]]-x],Min[Abs[tab[[1]]-x]]][[1,1]]]]
lookupL[7.008]

IntPairL[x_]:={tab[[All,Position[tab[[1]],Max[Select[tab[[1]],#≤ x&]]][[1,1]]]],
tab[[All,Position[tab[[1]],Min[Select[tab[[1]],#>x &]]][[1,1]]]]}
IntPairL[7.018]

lookupE[x_]:=tab[[All,Position[Abs[tab[[2]]-x],Min[Abs[tab[[2]]-x]]][[1,1]]]]
lookupE[.7]

IntPairE[x_]:={tab[[All,Position[tab[[2]],Max[Select[tab[[2]],#≤ x&]]][[1,1]]]],
tab[[All,Position[tab[[2]],Min[Select[tab[[2]],#>x &]]][[1,1]]]]}
IntPairE[.506]

Characteristic and Mantissa

A logarithmic table only contains logarithms for numbers between 1 and 10.
Logarithms for other positive numbers can be found by using the fact that log((10^n) x)=n + log(x).
Here is an example. Our table yields 0.845703 as the log of 7.00976.
Consequently 1.845703 is the log of 70.0976, 0.845703-1 is the log of 0.700976.
Instead of log(0.700976)= 0.845703-1, one writes log(0.700976)=(OverBar[1]).845703 .
With this convention, the number in front of the decimal point is called “characteristic”, the part after the decimal point is called “mantissa”.
log(0.700976) has characteristic -1 and mantissa 845703.

Multiplication and Division

Example: 2 · 3 = 6, using log (6) = log (2) + log (3)

We first look up values for log 2 and log 3, then add them:

lookupL[2]
lookupL[3]

sum=lookupL[2][[2]]+lookupL[3][[2]]

Now we look up which value in the table has this logarithm:

lookupE[sum]

So 2 · 3 is approximately equal to:

lookupE[sum][[1]]

Example: 356.4 ÷ 1.87 = 190.588, using log (190.588) = log (356.4) - log (1.87)

We look up values for log 3.564 and log 1.87:

lookupL[3.564]
lookupL[1.87]

Since log 3.564 ≈ 0.551758, log 356.4 ≈ 2.551758.
Subtraction yields:

diff=2+lookupL[3.564][[2]]-lookupL[1.87][[2]]

Then we look up which value in the table has this mantissa:

lookupE[diff-2]

Multiplying by (10^2) yields the  approximative answer

(10^(2 ))lookupE[diff-2][[1]]

How to compute (3^1.41)?

log((3^1.41))=1.41 log 3.

lookupL[3]

p1=1.41 lookupL[3][[2]]

Final answer :

lookupE[p1]
lookupE[p1][[1]]

Here is Mathematica’s answer:

(3^1.41)

How to compute (7^1.6)?

log((7^1.6))=1.6 log 7.

lookupL[7]

1.6 lookupL[7][[2]]

The mantissa of this logarithm is

mant=1.6 lookupL[7][[2]]-1

lookupE[mant]

Final answer :

10 lookupE[mant][[1]]

Mathematica gets:

(7^1.6)

Linear Interpolation

We can get better results by using linear interpolation.
Let us redo the last example: (7^1.6).
Below are the two entries closest to 7:

{pt1,pt2}=IntPairL[7]

Assuming that the log function is linear between these values, we can get a better approximation for log 7:

ptc={7,Fit[{pt1,pt2},{1,x},x]/.x->7}
ListPlot[{pt1,pt2,ptc},PlotStyle->Red,Joined->True,Epilog->{{AbsolutePointSize[7],Red,Point[pt1],Point[pt2]},{AbsolutePointSize[7],Blue,Point[ptc]}}]

1.6 ptc[[2]]

Subtract 1 to obtain the mantissa:

1.6 ptc[[2]]-1

Next we look up the interpolation pair for this mantissa:

{pt11,pt12}=Map[Reverse[#]&,IntPairE[0.352156]]

Linear interpolation yields:

ptc2={0.352156,Fit[{pt11,pt12},{1,x},x]/.x->0.352156}
ListPlot[{pt11,pt12,ptc2},Joined->True,PlotStyle->Red,Epilog->{{AbsolutePointSize[7],Red,Point[pt11],Point[pt12]},{AbsolutePointSize[7],Blue,Point[ptc2]}}]

Final answer :

10 ptc2[[2]]

Mathematica' s answer :

(7^1.6)

Fixing the Log Table

Linear interpolation is also used to “refine” the logarithmic table itself. 
The objective is to produce a table where the entries on the left are in arithmetic progression (constant difference between consecutive terms).
The example below shows how to produce a table of 10 entries in arithmetic progression from a raw logarithmic table with 17 entries (multiples of (10^(1/(16)))). 
The original values are depicted in red, the interpolated values in blue.

tabb=Table[{10^k,k},{k,0,1,1/16}];
f=Interpolation[tabb,InterpolationOrder->1];
Plot[f[x],{x,1,10},PlotStyle->Red,Epilog->{{Blue,AbsolutePointSize[8],Point[Table[{k,f[k]},{k,1,10,1}]]},{Red,AbsolutePointSize[5],Point[tabb]}}]

Table[{x,Chop[f[x]]},{x,1.,10,1}]

A German Logarithmic Table

Note the built-in interpolation table on the right side of the page below. The differences between consecutive entries in the table are mostly (0.0000)163 at the top, and then become 162 and 161 further down.

Slide Rules

Slide rules were used to multiply and divide quickly. The scale on the two rulers is chosen such that the distance between 1 and x is log x.

Below is the example how to multiply 3 by 2: We need to add the lengths log 3 and log 2 to obtain the length log 6.

Show[Graphics[{{AbsoluteThickness[4],Blue,Line[{{0,0},{1,0}}]},{AbsolutePointSize[10],Blue,Point[Table[{Log[10,k],0},{k,1,10}]]},{Table[Text[k,{Log[10,k],0},{0,3}],{k,1,10}]},{AbsoluteThickness[4],Blue,Line[{{Log[10,3],1},{1+Log[10,3],1}}]},{AbsolutePointSize[10],Blue,Point[Table[{Log[10,3]+Log[10,k],1},{k,1,10}]]},{Table[Text[k,{Log[10,3]+Log[10,k],1},{0,-3}],{k,1,10}]},{Dashed,Line[{{Log[10,3],-0.5},{Log[10,3],1.5}}]},{Dashed,Line[{{Log[10,6],-0.5},{Log[10,6],1.5}}]}},BaseStyle->14],ImageSize->{600,100},AspectRatio->1/12]

A working model of a slide rule  (Pickett N909-ES) can be found at http://www.antiquark.com/sliderule/sim/n909es/virtual-n909-es.html