Thursday, August 28, 2008

Slide Rules




I just cleaned the garage & found a good old slide rule I used to use in our Taida’s day. It is a Hemmi 153 for EE. After so many years, I can barely remember the scales & functions. Most of you use Hemmi 255, also for EE.

For some reason, I seldom used it in my graduate classes in the US, although I was still an EE major. The discipline of EE consists of many fields such as communication, power, control system, computer & logic, circuit & network, electronics, solid state physics, etc. Most of these fields stress on theory & application. The numerical calculation is minimal. In other words, due to lack of case study or field application, the calculation is fairly limited & so the use of slide rule is rare. Compare to law & MBA programs, our EE seems less exciting & lack of colorful or hot discussion. I spent half day to review my good old slide rule & would like to share some of my finding. Of course, most of us knew these long time ago. Here are the scales I found in Hemmi 153:

L: Logarithm
K: Cube
A: Square
A,B: Multiply, Divide
C,D,CI: Multiply, Divide, Proportion
T: Tangent
GTheta: Gudermanian Angle for Sinh on T scale & Tanh on P scale
Theta: Angle of Trigonometry, 360 degrees in a circle
RTheta: Radian Angle of Theta, 2 pi in a circle
P,Q,Q’: Sin, Cos & Hypotenuse of Right Triangle
LL3, LL2, LL1: log log scale for exponential functions

The operation of the slide rule is by sliding center bar and finding the answer using various scales. So the operation is basically Addition & Subtraction in nature. However, if the scale is calibrated in a logarithmic fashion, then the multiplication becomes addition & division becomes subtraction. That is exactly what scale A,B,C,D & CI do. In fact, the scale L is calibrated from 0 to 10 in equal spacing. As to the calculation of exponential functions, it takes one more log to convert exponent to multiply. In LL3, LL2 & LL1, the scale is calibrated in log log fashion, so the calculations of exponent is converted to addition, a slide rule operation. GTheta is Gudermanian Angle for finding Sinh on T scale & Tanh on P scale. It is not obvious why hyperbolic functions have anything to do with Tangent & Square functions. I think the key is how GTheta is defined. Most electrical engineers are not really interested in the definition of GTheta. All we care is getting Sinh from T scale & Tanh from P scale. As a matter of fact, the graph of Sinh looks like Tan & Tanh looks like Sin in the range of principal values.

Nowadays we don’t see slide rules except the places like museums. This is one example that technology changes the way we calculate, and so the way we live. You might ask why. In 1972, HP introduced HP-35 Electronic Calculator. It has 35 buttons (so called HP-35) with four functions, trigonometric, logarithmic functions, square root & exponential functions. The accuracy of the calculation is 10 significant digits. Since it can perform all the functions of the slide rules & do them more accurately (10 significant vs 3 or 4 digits in slide rules) and efficiently (much faster), it sent the slide rules into oblivion. From then on, slide rules faded away like old soldiers & books of math tables disappeared in no time. In 1972, I worked for Mostek, a spin out of Texas Instrument. Mostek supplied three ROMs for HP-35. I had the chance to see the complete binary code of the algorithms & its architecture. The processor operates fetch, store, branch, add & shift with four registers. Each register has 56 bits, organized as 14x4, ie 14 digits in BCD. The internal register calculations are 14 digits and the accuracy is 10 digits. It is a very primitive but compact processor dedicated just for scientific calculations. The four functions are calculated with add & shift. Logarithm is calculated using Sequential Table Lookup (log 2, log 1.1, log 1.01 & log 1.001). For example, log 30 is converted to a series of numbers as follows:

Log 10*3 = log 10* 2*1.5 = log 10*2*1.1*1.36
= log 10*2*1.1*1.1*1.1*1.01*1.01
= Log 10 +log 2 + 3*log1.1 + 2*log 1.01.

Since log10=1, log 2, log 1.1, log 1.01 are the constants store in ROM, you just look them up & add to get the correct answer. The method seems cumbersome. But the processor is fast enough to get the most results within 3 seconds.

Trigonometric functions are calculated by Rotation Method (CORDIC) with Sequential Table Lookup (arctan 1, arctan 0.1, arctan 0.01, arctan 0.001 and arctan 0.0001). The angles correspond to 45°, 5.71°, 0.57°, 0.06° and 0.01°. For example, Tan 52° is converted to Tan (45+5.71+ 0.57 + 0.57 + 0.06 + 0.06 + 0.01 + 0.01 + 0.01). For each rotation, use the formula we learned from Analytic Geometry:

X’ = xcosA - ysinA
Y’ = xsinA + ycosA

The values of sin & cos of the angles 45° to 0.01° are stored in ROM.
The final result Tan 52° = X’/Y’. Sin52° = Y’/SQRT(X’²+Y’²) & Cos52° = X’/SQRT(X’²+Y’²).

Exponential function exp(x) can be obtained similar to logarithmic function. Convert x to m0*c0 + m1*c1 + m2*c2 + m3* c3 + m4*c4. The constants in ROM c0, c1, c2, c3, & c4 are the values of ln10, ln 2, ln 1.1, ln 1.01, ln 1.001, ln 1.0001. So exp(x)= exp(m0*c0 + m1*c1 + m2*c2 + m3* c3 + m4*c4) = 10^m0 * 2^m1 * 1.1^m2 * 1.01^m3 * 1.001^m4, can be calculated by add & shift operations.

Some of us might have chance to take a course called Numerical Analysis in graduate school. It is considered part of the computer science curriculum. Alas, it didn’t mention anything that I found in HP-35. One thing I did know at that time why HP didn’t use Infinite Series, it is the speed of the convergence. It is hard to find infinite series converges fast enough for the slow processor in 1972.

No comments: