-
Notifications
You must be signed in to change notification settings - Fork 173
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
Gamma special function #625
Gamma special function #625
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. It looks already good to me, while I am not a user of such functions. A main question is why not all functions support all kinds of reals.
|
||
### Description | ||
|
||
Due to the different branch cut structures and a different principal branch, natural logarithm of gamma function log_gamma(z) with complex argument is different from the ln(Gamma(z)). The two have the same real part but different imaginary part. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain first the aim of this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to move these sentences to the section Returned value
.
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Very good question. Short answer is limits of precision. Detailed answer is as follows. During the calculation of most special functions such as Gamma, Bessel functions, there are no finite analytical formulae to exactly calculate the function values. Those functions have to be approximated by using various techniques, which introducing truncation error and rounding error. These errors are more pronouncing during complex value multiplication and division arithmetic of the special functions. Because of the propagation of these errors, the calculated results will have much less significant digits or even incorrect value if the same precision as calculated result is used during calculation. By using higher precision during calculation, the desired precision digits are guaranteed to be correct. So single precision uses double precision for calculation, double precision uses quadruple precision for calculation. Extended precision calculation may need higher precision a little over quadruple, while quadruple precision calculation need much higher precision not available right now. If there is a package for arbitrary precision, all kinds of reals can be supported. |
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (only a minor comment). Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
During implementing the gamma probability distribution(#278), I realized there is a need for gamma function and log_gamma with complex argument as well as incomplete gamma functions. So here is the PR for gamma special function. The gamma and log_gamma functions with complex argument was coded for single and double precision. All implemented functions were tested against available multi-precision package version with satisfactory results. This PR includes the following:
Please test it and provide any comment and suggestion.