Back in EE school in 1991, I installed an 8087 in my PC. The speed-up running Micro-CAP 3 was amazing, as a simple BJT CE amp sim only took a few minutes. Of course then I moved to a 486 and that same sim was finished before the mouse button lifted.
There has been an amazing amount of progress since then, but my PC is still too slow, as the simulations only get larger.
I couldn't figure out any explanation for that constant. If I had to guess, maybe some optimization for the base-2 log/exp CORDIC algorithm, like a polynomial approximation of base-2 log for the small remainder from CORDIC. The dividing by 3 might come from the Taylor series.
There was an instruction to load ln(2) onto the x87 stack. It didn't do anything else; it just pushed ln(2) onto the stack. ln(2) is to compute the natural log. The x87 log instruction had an additional scale factor; if you gave it ln(2) as the scale factor, it computed the natural log instead of the base 2 log.
I don't know what ln(3) would be used for. My guess is it's used as somewhere in the algorithm to compute log2(x). Probably as a fixed point in CORDIC, or possibly as a boundary condition: if the intermediate value is above ln(3), do a bitshift, and add a constant to the result. But I don't know.
The fact that the x87 is a separate processor is a key part of what made Quake what it was. Because math on the FPU ran concurrently with the main CPU, you could do integer math physics calculations on the x86 and floating point math graphics calculations on the x87. So you'd have a significant speedup by interleaving everything together. Must have been a nightmare to write that code. Some x86 clones were clever, and used the same circuitry for everything. I think Cyrix chips for instance didn't separate the circuitry for x86 and x87 instructions. So x86 heavy code ran similarly between Cyrix and Intel, and x87 heavy code did also, but Quake (which combined x86 and x87 instructions relatively equally) ran like garbage on Cyrix chips. At the time, this gave Cyrix chips a terrible reputation. These days, Intel and AMD put fairly little effort into making x87 instructions fast, because code that cares about floating point performance use AVX instructions.
>These days, Intel and AMD put fairly little effort into making x87 instructions fast, because code that cares about floating point performance use AVX instructions.
AFAIK x87 instructions were removed/deprecated in x86_64
Back in EE school in 1991, I installed an 8087 in my PC. The speed-up running Micro-CAP 3 was amazing, as a simple BJT CE amp sim only took a few minutes. Of course then I moved to a 486 and that same sim was finished before the mouse button lifted.
There has been an amazing amount of progress since then, but my PC is still too slow, as the simulations only get larger.