Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math functions log1p and expm1 #17

Closed
sanjayjain159 opened this issue Oct 6, 2021 · 1 comment
Closed

math functions log1p and expm1 #17

sanjayjain159 opened this issue Oct 6, 2021 · 1 comment

Comments

@sanjayjain159
Copy link

  1. In kuroko documentation, log1p(x) is defined as log(x) +1. At the same time it is said that this libc math function. This is inconsistent. I would like to point out that in libc log1p(x) is ln(1+x) where ln is the natural logarithm and log1p is used when x <1. When x<<1, there are truncation/roundoff errors in adding a large number 1 to a small floating point number x, and to avoid these a separate function log1p has been provided in libc which is used for small x. There is corresponding assembly instruction in x87 for this function also. So if you are computing log1p as log(1+x) it is inaccurate, and if you are computing log1p as log(x) +1 it is wrong.
  2. There is a corresponding function expm1(x) in libc, which is defined as (e^x -1), which is as necessary as log1p for the same reason for small x<1. The reason is for x<<1 e^x is close to 1 while the difference e^x -1 causes truncation/roundoff errors as before. So the expm1 function has been provided in libc to avoid these errors and there also a instruction to compute it x87 assembly. I request the libc function expm1(x) be added to kuroko.
  3. Having great fun with kuroko! Congrats!
@klange
Copy link
Collaborator

klange commented Oct 6, 2021

log1p was incorrectly bound I think because I misread something in Python documentation. Fixed that and added the binding for expm1.

@klange klange closed this as completed Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants