Deterministic ln(x) approximation

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Deterministic ln(x) approximation

Post by raidho36 »

Having error is fine as long as it's consistent. I'd suggest that you replace integer exponentiation with consecutive multiplications - just in case.
User avatar
wolfboyft
Prole
Posts: 20
Joined: Sat Oct 21, 2017 5:28 pm
Location: London
Contact:

Re: Deterministic ln(x) approximation

Post by wolfboyft »

raidho36 wrote: Sat Jan 18, 2020 1:51 am Having error is fine as long as it's consistent.
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.
raidho36 wrote: Sat Jan 18, 2020 1:51 am I'd suggest that you replace integer exponentiation with consecutive multiplications - just in case.
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
User avatar
pgimeno
Party member
Posts: 3673
Joined: Sun Oct 18, 2015 2:58 pm

Re: Deterministic ln(x) approximation

Post by pgimeno »

Glad you got it working :)
wolfboyft wrote: Fri Jan 17, 2020 5:31 pmleaves me with some serious error magnification too.
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).
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests