KG_is_back wrote:In general you should avoid it like a plague if you care about speed, because it's pretty much guaranteed to be the bottleneck in your code...
The following introduction is not for KG or Martin, but for other people, who might read here and are not so much into math. KG, Martin, please head over to the last paragraph.
The function I wrote in the first post is called "inverse power function". A power function is pretty easy to understand. Just imagine the exponent tells you, how many times you have to multiply the base.
- Code: Select all
x^3 = x * x * x
Inverse power tells you the opposite. Let's put x = 2, to get comprehensible results.
- Code: Select all
x^(1/x) == 2^(1/2) == 2^0.5
Obviously we can't multiply x with itself just a half time. Instead it tells us that the result, we are looking for is the number, that multiplied with itself results in 2. And that is easy in this case. It's the square root of 2.
2√2 = 1,4142135623730950488016887242097
- Code: Select all
2^(1/2) == 2√2
x^(1/x) == x√x
Both, power and inverse power are building blocks in quite some DSP functions. So, I really wonder, do any of you know of a way to realize inverse power with just simple arithmetics? That's way over my head.