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

Should factorial be defined in all or some domains? #26

Open
Rudxain opened this issue Apr 29, 2022 · 2 comments
Open

Should factorial be defined in all or some domains? #26

Rudxain opened this issue Apr 29, 2022 · 2 comments

Comments

@Rudxain
Copy link

Rudxain commented Apr 29, 2022

What I mean by "domain" is actually a math function domain. Should it return NaN for positive non-integer inputs? Or should it be defined in terms of the Gamma function (plus one)? If so, should it return NaN for negative args? or should it use the "raw" Gamma function definition where it returns "weird" values?

There are many conflicting definitions for negative inputs, so I guess the best choice is to return NaN.

About positive non-ints, I think it should definitely use Gamma. This is because interpolating the factorial function accurately and efficiently is very hard for most devs (including me). I know 1 person isn't enough evidence to assume most people have problems doing the same thing, but I'm sure if we do a survey we would get similar results.

MS calculator, Desmos, and WolframAlpha, all use an interpolated factorial, and (AFAIK) they all use Gamma internally. Again, these 3 pieces of software aren't enough justification to extend the domain of the factorial. Extending the factorial "just because some people do it" is an ad-populum fallacy. But we should be aware that the extended definition exists and try to reach a consensus if the factorial is actually added

@Prashant0664
Copy link

The factorials of negative integers have no defined meaning.
The factorial of a negative integer is undefined, however, there are some nifty ways we can get around to negative non-integers
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4247832/#:~:text=The%20factorials%20of%20real%20negative%20integers%20have%20their,equal%20to%20their%20respective%20real%20positive%20number%20factorials.

@Rudxain
Copy link
Author

Rudxain commented Apr 29, 2022

I meant positive non-ints, I've edited my comment to include the word "positive". Sorry for the confusion.

About the link, thanks for the info, it's very complete and useful for this Issue

@Rudxain Rudxain changed the title Should Math.factorial be defined in all or some domains? Should factorial be defined in all or some domains? Jun 3, 2022
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