[comp.sys.intel] 80387 computation

glenn@suphys.physics.su.OZ.AU (Glenn Geers) (06/19/91)

Hi,
	I've written most of the UNIX math library routines in 386/387 assembler
in order to get more bang for my buck. However, there is one that has eluded me
so far (at least efficiently) and thats exp(x)-1. The 387 has an instruction
for doing 2^x - 1 but I can't see a neat way of scaling the result or prescaling
the input. Anyone know how?

Thanks in adavnce,
	Glenn
--
___________________________________________________________________________
Glenn Geers                       | "So when it's over, 
                                  |  we're back to people.
Department of Theoretical Physics |  Just to prove that human touch
The University of Sydney          |  can have no equal."
Sydney NSW 2006 Australia         |  - Basia Trzetrzelewska, 'Prime Time TV'
                                  |
Phone: +61 2 692-3241 (voice)     |_________________________________________
       +61 2 660-2903 (fax)       |
                                  |
glenn@qed.physics.su.oz.au        | #include <standard_disclaimer.h>
                                  |
----------------------------------------------------------------------------

6600m00n@ucsbuxa.ucsb.edu (Steelworker) (06/20/91)

In article <1991Jun19.023041.25008@metro.ucc.su.OZ.AU>
glenn@suphys.physics.su.OZ.AU (Glenn Geers) writes:

]	I've written most of the UNIX math library routines in 386/387 assembler
]in order to get more bang for my buck. However, there is one that has eluded me
]so far (at least efficiently) and thats exp(x)-1. The 387 has an instruction
]for doing 2^x - 1 but I can't see a neat way of scaling the result or
]prescaling
]the input. Anyone know how?

]Thanks in adavnce,
]	Glenn

One way is to compute 2^( x * log e) -1  , where the log is in
base two.   That involves only a bit more work. ( precalculating log e 
of course).
one line proof:
ln(2^(x * log e)) = x * log e * ln 2 = x

Have fun with the math, 
Rob Blair
6600m00n@ucsbuxa.ucsb.edu
( One other task you might want to do is to make a library that takes
high precision 80 bit reals, for that extra accuracy.)