8000 BUG: Inaccurate `log1p` for small complex input · Issue #22609 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Inaccurate log1p for small complex input #22609

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

Open
mfkasim1 opened this issue Nov 17, 2022 · 0 comments · May be fixed by #22611 or #26798
Open

BUG: Inaccurate log1p for small complex input #22609

mfkasim1 opened this issue Nov 17, 2022 · 0 comments · May be fixed by #22611 or #26798
Labels

Comments

@mfkasim1
Copy link
Contributor

Describe the issue:

The reason for log1p existence is to provide a more numerically stable function for small input, compared to log(1 + x).
If the input is real valued, np.log1p can serve its purpose.
However, when the input is complex and small, np.log1p loses its accuracy.

Reproduce the code example:

import numpy as np
print(np.log1p(1e-18 + 1e-18j))  # wrongly produces 1e-18j, should be 1e-18 + 1e-18j

Error message:

No response

NumPy/Python version information:

1.23.4 3.9.15 (main, Nov 4 2022, 16:13:54) [GCC 11.2.0]

Context for the issue:

No response

@mfkasim1 mfkasim1 linked a pull request Nov 17, 2022 that will close this issue
WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Aug 14, 2023
Reimplement the complex log1p function.  Use the log1p trick from Theorem 4
of Goldberg's paper "What every computer scientist should know about
floating-point arithmetic".  Include special handling of an input with
imaginary part 0.0 to ensure the sign of the imaginary part of the result
is correct and consistent with the complex log function.

Closes numpygh-22609.
WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Jun 5, 2024
Reimplement the complex log1p function.  Use the log1p trick from Theorem 4
of Goldberg's paper "What every computer scientist should know about
floating-point arithmetic".  Include special handling of an input with
imaginary part 0.0 to ensure the sign of the imaginary part of the result
is correct and consistent with the complex log function.

Closes numpygh-22609.
WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Jun 18, 2024
WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Jun 18, 2024
WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Jun 22, 2024
Reimplement the complex log1p function.  Use the log1p trick from Theorem 4
of Goldberg's paper "What every computer scientist should know about
floating-point arithmetic".  Include special handling of an input with
imaginary part 0.0 to ensure the sign of the imaginary part of the result
is correct and consistent with the complex log function.

Closes numpygh-22609.
WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Jun 22, 2024
WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Jun 22, 2024
WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Jun 26, 2024
@WarrenWeckesser WarrenWeckesser linked a pull request Jun 26, 2024 that will close this issue
WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Jun 26, 2024
WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
0