Of the two versions in the github repo, I have only implemented the “faster” version, which is very crude, definitely not accurarte to 7 digits.
I doubt the “fast” version is that accurate either. In the test folder of the repo, there are tests run for the power function against random values with a target of 1e-4 relative error.
The problem with these approximations is not that they’re faster than base, that we know. The base standard library demands that these function are within an <= 1 ulp for all possible input values. Guaranteeing this is the case AND making these function perform as fast as possible is an incredibly hard thing to do. The proposed approximations are completely valid as long as you are aware that they are not accurate to 1 ulp over the full float range.
When you use a^b it will be slower than exp(b), because the function a^b has to make those guarantees for ALL a and b, whereas for exp(b) we can specialize the algorithm for the fact that a is now a constant ℯ .
If you are writing a general library where you can’t guarantee inputs are within a specified range or don’t understand the magnitude of the resulting errors by these crude approximations, in general, it is recommended to stick to the base library’s elementary functions to avoid unforeseen issues from user inputs.