Logarithms and exponentiation in MUMPS: routines for the clinical biochemistry laboratory computer system

The BASIC language has a wide range of arithmetic functions such as natural and common logarithms, natural antilogarithm (exponential) and square root [1]. In addition, exponentiation is an available arithmetic operator. These features make BASIC a useful language for scientific work. By contrast, the very powerful data-base language MUMPS [2 and 3] lacks these imbedded arithmetic functions and operator, thus severely limiting the occasional use of this language in many scientific applications. For example, body surface area (m2) is calculated by the expression:


Introduction
The BASIC language has a wide range of arithmetic functions such as natural and common logarithms, natural antilogarithm (exponential) and square root [1]. In addition, exponentiation is an available arithmetic operator. These features make BASIC a useful language for scientific work. By contrast, the very powerful data-base language MUMPS [2 and 3] lacks these imbedded arithmetic functions and operator, thus severely limiting the occasional use of this language in many scientific applications. For example, body surface area (m2) is calculated by the expression: where W weight (kg) and H height (cm) [4]. This expression cannot currently be evaluated using Standard MUMPS. This is often inconvenient and alternative procedures are required to handle these requirements.
We have written two routines to generate common logarithms and antilogarithms thus allowing scientific functions such as exponentiations and root (including square root) calculations. These may be regarded as supplementing our CALCULATOR program [5], which allows a laboratory MUMPS system to be used as a simple calculator.

Materials and methods
The University Hospital Operating in this direct mode does not interfere with the main laboratory system or its data-base.

124
Instead of using standard series functions to represent logarithmic and exponential functions [7] two rational functions as described by Hastings were used [8]. These were, for log0 x over the range -< x -<_ 10: The LOG option returns the logarithm of a number to the selected decimal place; a decimal place entry greater than 15 forces the prompt 'Whole numbers 0 to 15 only'. At the beginning of each option, the user is asked to set the number of decimal places required in the answer. The default response is four; any response from 0 to 15 is valid.
Note that the SYstem is only capable of handling 16 significant figures. Numbers requiring more than 16 digits will be padded with place-holding-zeros to fit the requested format. Consider the following example of exponentiation for which six significant decimals were requested. BASE: 486"23 EXPONENT" 7 486.23 RAISED TO THE POWER 7 IS 6425282938784834000'000000 In the answer, the first 16 digits are arithmetically significant with the following zeros present as place holders and format fulfillers.

Log
In this routine, a number for which the log is to be determined is input (underlined), and the calculated log is returned. The logarithm of a fraction is a negative number which may be represented in one of two ways. It may be expressed with a positive mantissa and a negative characteristic or with a negative mantissa and a negative characteristic. The first format is typically expressed with a bar over the characteristic; this program will express the bar format by preceding the characteristic with an underscore. The all negative format is written with a preceding negative and will be shown in brackets.
HOW MANY DECIMALS? 4// NUMBER: 5"5 LOG OF 5"5 IS '7404 NUMBER: 10"05 LOG OF 10"05 IS 1"0022 NUMBER: .0098 LOG OF .0098 IS __3-9911 (-2'0089) Antilog The antilog routine accepts the logarithmic value for a number and then returns the value of that number. The log of a fraction may be input using either the bar notation or the log expressed as an all negative value. Note that a characteristic is required even if it is zero. HOW MANY DECIMALS? 4// LOG: m2"5200 ANTILOG OF m2"5200 IS "0331 LOG: 1"4803 ANTILOG OF 1"4803 IS "0331 LOG: 2"20 ANTILOG OF 2"20 IS 158.4893 LOG: 0"0154 ANTILOG OF 0.0154 IS 1"0361 Exponentiation This routine will accept a number and an exponent and then calculate the number raised by the exponent. The logarithm of a number <1 is expressed in two different ways [7]" negative characteristic--positive mantissa (for example log 0"0002 is '3010) or negative characteristicmnegative mantissa (for example log 0"0002 is -3"6990). Because '' is not available in our system we have used the nomenclature of '4'. Note that the wholly negative logarithm (-3"6990 in the example above) is necessary for certain manipulations (such as calculating the power of a number) so that availability of both forms is necessary. The ANTILOG option is self-explanatory; either form of logarithm can be used. 126 The EXPONENTIATION option requests the base and exponent and then responds: x RAISED TO THE POWERy IS NNNN. The ROOTS option requests the base and root then responds: x ROOTy IS NNNN. Finally, the BODY SURFACE AREA calculation is self-explanatory. The programs are listed in tables 2-5.    First a complete table of four-figure logarithms was produced and compared with a set of commercially available tables [8]; the values were identical. Next a set of oneto eight-digit numbers were converted to their logarithms using 15 significant decimal places, their antilogarithms were formed and the recovered number   (3) input value 2288"0677 recovered value 2288"0679. (4) input value 0"0005950 recovered value 0"0005950. The largest error (of the order of 0"000 05%) occurs when mixed (i.e. integer and decimal) numbers are used. If the number is either an entire integer or decimal, the error is smaller (for example log 2 example given above).
Finally a set of oneto eight-digit numbers were exponentiated, their roots obtained and the recovered number compared with its original value. Using 15 significant decimal places in the calculation--as shown above for example 1--maximum errors of about 0"000 05% were obtained.

Discussion
MUMPS routines have been provided for logarithms and exponentiation with defaults at four significant decimal places. If these defaults are over-ridden then the possibility of overor under-flow in the arithmetic registers occurs. As Nonweiler warns [10], one must neither assume that computers are inevitably accurate,