Re: Inaccurate results from numeric ln(), log(), exp() and pow()
От | Dean Rasheed |
---|---|
Тема | Re: Inaccurate results from numeric ln(), log(), exp() and pow() |
Дата | |
Msg-id | CAEZATCVFk1zRrAuT-nf8+gLNaEBL52njzz4N6QmsaP6Sy=qoOw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Inaccurate results from numeric ln(), log(), exp() and pow() (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Inaccurate results from numeric ln(), log(), exp() and pow()
|
Список | pgsql-hackers |
On 13 November 2015 at 23:10, Tom Lane <tgl@sss.pgh.pa.us> wrote: > One more thing: the approach you used in power_var() of doing a whole > separate exp * ln(base) calculation to approximate the result weight > seems mighty expensive, even if it is done at minimal precision. > Couldn't we get a good-enough approximation using basically > numericvar_to_double_no_overflow(exp) * estimate_ln_weight(base) ? > I can't see a way to make that work reliably. It would need to be 10^estimate_ln_weight(base) and the problem is that both exp and ln_weight could be too big to fit in double variables, and become HUGE_VAL, losing all precision. An interesting example is the limit of (1+1/x)^x as x approaches infinity which is e (the base of natural logarithms), so in that case both the exponent and ln_weight could be arbitrarily big (well too big for doubles anyway). For example (1+1/1.2e+500)^(1.2e500) = 2.7182818284... Regards, Dean
В списке pgsql-hackers по дате отправления: