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

Add "missing" irrationals #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

devmotion
Copy link
Member

This PR adds some irrationals that seem to be "missing" and would be useful e.g. in SpecialFunctions. E.g., currently pi (in base), 2 * pi, 4 * pi, pi / 2, and pi / 4 are defined but even though the inverse of all of these numbers is defined as well only log(pi), log(2 * pi), and log(4 * pi) are implemented but neither log(pi / 2) nor log(pi / 4). Similarly, currently sqrt(pi / 4) is not defined (all other square roots are) and only 1 / sqrt(2 * pi) is defined but no other inverse square roots.

@devmotion
Copy link
Member Author

Bump 🙂

In particular invsqrtπ and invsqrtquartπ would be very helpful for the ChainRules definition since it would allow us eg to implement the derivative of erfcx(x) as 2 * (x * Ω - invsqrtπ) or 2 * x * Ω - invsqrtquartπ which in contrast to 2 * x * Ω - 2 / sqrtπ does not lead to any undesired promotions for e.g. Float32.

@devmotion
Copy link
Member Author

Bump 🙂

invsqrthalfπ # 1 / √(π / 2)
invsqrtquartπ # 1 / √(π / 4)
loghalf # log(1 / 2)
logtwo # log(2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be log2 like log3?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, log2 is a function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, I see.

invsqrt2π # 1 / √2π
invsqrt4π # 1 / √4π
invsqrthalfπ # 1 / √(π / 2)
invsqrtquartπ # 1 / √(π / 4)
Copy link
Contributor

@hyrodium hyrodium Apr 25, 2022

Choose a reason for hiding this comment

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

The git diff is a little illegible, so I think it would be better to add more spaces before # for when someone registers a new variable with a long name in another PR.

Suggested change
invsqrtquartπ # 1 / √(π / 4)
invsqrtquartπ # 1 / √(π / 4)

Or, it could be fine without aligning #.

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.

2 participants