Skip to content

Conversation

@nsajko
Copy link
Contributor

@nsajko nsajko commented Aug 1, 2025

Note which function the polynomial approximation approximates in a comment in the source code.

Might be useful if someone decided to search for a slightly different polynomial.

Note which function the polynomial approximation approximates in a
comment in the source code.

Might be useful if someone decided to search for a slightly different
polynomial.
@nsajko
Copy link
Contributor Author

nsajko commented Aug 1, 2025

The context here is that I tried to improve upon the existing polynomial by using Sollya, but I could not. Hats off to Oscar (I think the current polynomials were found by Oscar, not sure how he rounded the coefficients to machine precision?!)!

Copy link
Collaborator

@tpapp tpapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@tpapp tpapp requested a review from devmotion August 8, 2025 06:50
Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand the purpose of the PR - the polynomial and how it was found (with Remez.jl) is already documented in

# The kernel of log1pmx
# Accuracy within ~2ulps -0.227 < x < 0.315 for Float64
# Accuracy <2.18ulps -0.425 < x < 0.425 for Float32
# parameters foudn via Remez.jl, specifically:
# g(x) = evalpoly(x, big(2)./ntuple(i->2i+1, 50))
# p = T.(Tuple(ratfn_minimax(g, (1e-3, (.425/(.425+2))^2), 8, 0)[1]))
.

The comment explains that the polynomial is an approximation of $$\sum_{i=0}^{49} 2x^i/(2i + 3)$$ which is a truncation of the power series $$\sum_{i=0}^{\infty} 2x^i/(2i + 3) = 2 (atanh(x) - x) / x^3$$.

@nsajko
Copy link
Contributor Author

nsajko commented Aug 8, 2025

I don't really understand the purpose of the PR - the polynomial and how it was found (with Remez.jl) is already documented

The purpose is to expand the existing documentation with a more clear description. And the closed form is more useful for feeding to a tool like Sollya than the Taylor series is. If you think everything is clear already then I guess there's no improvement from your perspective?

@devmotion
Copy link
Member

I would suggest expanding the existing comment instead of adding a new separate one. I imagine it could be helpful for some readers to know that polynomial g that is approximated here is itself a truncation of the series expansion of 2(atanh(x) - x)/x^3.

@tpapp tpapp merged commit 8dee873 into JuliaStats:master Aug 17, 2025
4 checks passed
@tpapp tpapp mentioned this pull request Aug 17, 2025
@nsajko nsajko deleted the _log1pmx_ker branch August 17, 2025 18:21
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

Successfully merging this pull request may close these issues.

3 participants