www.jupiterace.co.uk

Previous Page > Listings Index > Floating Point Dictionary 

Computing ToDay  Floating Point Dictionary, page 84 Software: Ace arithmetic
Stephen Renals


FLOATING POINT
DICTIONARY
This dictionary for the Jupiter Ace will let you calculate logarithms to the bases e and 10, exponentials, powers, and one root of an equation using the NewtonRaphson method.

added on to the sum at the end. The value of h is then calculated from the mantissa and the above series is summed. The natural logarithm of a number may therefore be found.
LOG finds the log to the base 10 of a number, using the relation:
log10X = ln x ln 10 EXP calculates the exponential function (exp x ex) of a floating point number. This is achieved by summing the Taylor Approximation to exp x:
exp h = l + h + h2 + h3 + h4 + h5 + . . .
where21 31 41 51
nl = n * (n  1) * (n  2) * . . . * 1
LN is accurate to around 3 significant figures (SF). The size of the operand is not important, as LN splits the number, as mentioned earlier.
EXP is accurate to 5 or 6 SF on numbers between about  2 and 12. It is accurate to 3 or 4 SF when the operand is between about 12 and 16, or  2 and  4. Above 22 of 23, or below  6 it is not very accurate.
From these definitions, F↑ may be defined, which finds the power of any number. This word is based upon the relation:
ab = exp(b * ln a) F↑ is accurate to between 4 and 6 SF on answers ranging from 0.05 to 1.25 million, and accurate to 2 or 3 SF on answers up to 500 million or between 0.05 and 0.007.
Finally SOLVE will find the root of an equation using 26 iterations of the NewtonRaphson method. In this word, the function to be equated to 0 is contained in the word FX. F'X contains the derived function of FX. The derived functions of some common functions are given,in Table 1.
Hence to use SOLVE to solve the following equation, for example:
9x5  4x4 + 2x = 3, ie 9x5  4x4 + 2x  3 = 0 type in:
: FX (9x5  4x4 + 2x  3)
2DUP 5. FI^ 9. F* 20VER 4. FI^ 4. F* F 2SWAP 2DUP F+ F+ 3. F ; REDEFINE X : F'X (45x4  16x3 + 2) 2DUP 4. FI^ 45. F* 2SWAP 3. FI^ 16. F* F 2. F+ ; REDEFINE F'X 

T he Jupiter Ace has only the most basic of floating point words defined in ROM. However, with a little effort, a fairly acceptable package of floating point words may be defined. Indeed, this process is started by the inclusion of floating point stack manipulation  words and square root and trigonometric functions in the Jupiter Ace manual.The words 2* and 2/ are machine coded words that perform the operations suggested by their names, included because they increase speed of operation. 2ROLL, 2PICK, 2?DUP,
2VARIABLE and 2CONSTANT are floating point variations of words that operate on ordinary 16bit numbers (they can be used on double length integers, also). FLOAT has been defined so that signed 16bit numbers may be transferred to floating point:  32 UFLOAT would leave 65504. on top of the stack  32 FLOAT will leave  32. on top of the stack FO< is the same as DO< given in the ACE manual, since it also works on floating point numbers.

FINPUT will wait for a floating point number to be entered, whereas INPUT (only included for completeness) will wait for a 16bit number to be entered.
FI↑ will calculate powers of floating point numbers, so long as the index is an integer (in floating point form) not less than 0. It is similar to a 16bit definition given in the ACE manual.
LN calculates the natural logarithm (log to the base e) of a floating point number. It does this by using the series: ln m = 2(h + h3 + h5 + h7+ h9 + . . .)
where35 79
h = m  l
m + l
This series gives a good approximation of ln m, when m is less than 10.
LN first splits the floating point number into mantissa and exponent. For example, 984.51
(= 9.8451E2) has a mantissa of 9.8451 and an exponent of 2. This is useful, since: ln 9.84E2 = 2*ln 10 + ln 9.84 Hence the exponent is multiplied by ln 10 (2.30528) to be



Computing ToDay  Foating Point Dictionary, page 85 FLOATING POINT DICTIONARY


Typng SOLVE will leave the solution to 9x5  4x4+ 2x  3 = 0 0n top of the stack (in fact SOLVE will leave .807163 on the stack).
These words occupy around 1100 bytes, with FX and F'X left 'empty', but including SIN, COS,TAN
and SQRT: hence the Jupiter Ace will require memory
expansion to run it all. The words may be cleared by typing FORGET ITPAL.

FXF'X
axm + bxn maxml + nbxnl sin(ax + b)a*sin (ax + b) cos(ax + b)a*cos (ax + b) tan(ax + b)a / cos2(ax + b) axax * ln a exp xexp x ln xl / x Table 4 Some common functions and their derivatives


Listing 1. The floating point dictionary for the Ace.


