Deterministic ln(x) approximation
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Deterministic ln(x) approximation
Having error is fine as long as it's consistent. I'd suggest that you replace integer exponentiation with consecutive multiplications - just in case.
Re: Deterministic ln(x) approximation
Dude, it's massive. See the graph. Sure, determinism is determinism, and any cases where you're pow-ing by huge exponents is probably going to be rare anyway, though if it's something like damage = pow(base, charge) the fact that a higher charge can be worse than one less than it by a difference of hundreds isn't OK.
Consecutive multiplication doesn't work with fractional exponents, and for the integer part, the algorithm I use is an optimised version of that. Considering that it works with binary for the optimisation part, I wouldn't be entirely surprised if it's the same. It's just as "right" though. (Time taken merely depends on the number of bits in the exponent.)
Tachytaenius
Re: Deterministic ln(x) approximation
Glad you got it working
Since you do 15 iterations, the lowest term you're adding is 0.00003051711247318638 so that's the best error you can aspire to in the logarithm. That of course propagates exponentially when you take the exp(). You can add more of these to get a better approximation (up to 52).
Who is online
Users browsing this forum: No registered users and 2 guests