[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Exchange pow/frexp/ldexp (Lua power calculation)
- From: Doug Currie <doug.currie@...>
- Date: Mon, 18 Oct 2021 13:29:22 +0000
On Oct 18, 2021 at 9:15:53 AM, Flyer31 Test <firstname.lastname@example.org> wrote:
do you possibly some "most easy way" proposal, if I want to replace
the exponentiation by some "own calculation"?
(my STM32G473 controller has a so-called CORDIC interface for
high-speed calculation of sin, cos, tan, exp, log, sqrt on board, so I
want to use this for my Lua.
Using logarithmic identities, you can change b ^ x to K ^ (x * logK(b))
It looks more complicated, but if K is a convenient value, such as 2 or 10 or e, it becomes much easier.
For example, if K is e, then b ^ x = exp(x * ln(b))
If you have exp and ln in your library, you’re in luck, though you may need to deal with some edge cases.