What is the best estimation of the factorial function?
up vote
0
down vote
favorite
I have to calculate factorials of an arbitrarily large integers mod another arbitrarily large integer. i have considered Stirling's Approximation and Ramanujan’s factorial approximation. is it possible to get better estimates?
factorial
|
show 8 more comments
up vote
0
down vote
favorite
I have to calculate factorials of an arbitrarily large integers mod another arbitrarily large integer. i have considered Stirling's Approximation and Ramanujan’s factorial approximation. is it possible to get better estimates?
factorial
3
If you are using modular arithmetic, analytic estimates might not be the most useful thing for you, depending on what exactly your problem is. Instead things like en.wikipedia.org/wiki/Wilson%27s_theorem might help.
– Alex J Best
Nov 22 at 11:53
1
There's the gamma function but I don't think it will help you much in contexts of modular arithmetic...
– Prasun Biswas
Nov 22 at 11:57
1
Have a look at math.stackexchange.com/questions/676952/…. For $n=20$, what I wrote gives $2432902008176665737$ to be compared to the exact $2432902008176640000$
– Claude Leibovici
Nov 22 at 12:32
1
I don't know if this could be of interest since the coefficients start to be huge. Using the same kind of expression with degree $2$ in numerator and degree $3$ in denominator, for $n=20$, I get $2432902008176639896$. If you want, I could post the numbers in an answer.
– Claude Leibovici
Nov 22 at 13:05
1
Comparing to high order expansion of Stirling formula.
– Claude Leibovici
Nov 22 at 13:41
|
show 8 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have to calculate factorials of an arbitrarily large integers mod another arbitrarily large integer. i have considered Stirling's Approximation and Ramanujan’s factorial approximation. is it possible to get better estimates?
factorial
I have to calculate factorials of an arbitrarily large integers mod another arbitrarily large integer. i have considered Stirling's Approximation and Ramanujan’s factorial approximation. is it possible to get better estimates?
factorial
factorial
asked Nov 22 at 11:47
Malik Hamza Murtaza
247
247
3
If you are using modular arithmetic, analytic estimates might not be the most useful thing for you, depending on what exactly your problem is. Instead things like en.wikipedia.org/wiki/Wilson%27s_theorem might help.
– Alex J Best
Nov 22 at 11:53
1
There's the gamma function but I don't think it will help you much in contexts of modular arithmetic...
– Prasun Biswas
Nov 22 at 11:57
1
Have a look at math.stackexchange.com/questions/676952/…. For $n=20$, what I wrote gives $2432902008176665737$ to be compared to the exact $2432902008176640000$
– Claude Leibovici
Nov 22 at 12:32
1
I don't know if this could be of interest since the coefficients start to be huge. Using the same kind of expression with degree $2$ in numerator and degree $3$ in denominator, for $n=20$, I get $2432902008176639896$. If you want, I could post the numbers in an answer.
– Claude Leibovici
Nov 22 at 13:05
1
Comparing to high order expansion of Stirling formula.
– Claude Leibovici
Nov 22 at 13:41
|
show 8 more comments
3
If you are using modular arithmetic, analytic estimates might not be the most useful thing for you, depending on what exactly your problem is. Instead things like en.wikipedia.org/wiki/Wilson%27s_theorem might help.
– Alex J Best
Nov 22 at 11:53
1
There's the gamma function but I don't think it will help you much in contexts of modular arithmetic...
– Prasun Biswas
Nov 22 at 11:57
1
Have a look at math.stackexchange.com/questions/676952/…. For $n=20$, what I wrote gives $2432902008176665737$ to be compared to the exact $2432902008176640000$
– Claude Leibovici
Nov 22 at 12:32
1
I don't know if this could be of interest since the coefficients start to be huge. Using the same kind of expression with degree $2$ in numerator and degree $3$ in denominator, for $n=20$, I get $2432902008176639896$. If you want, I could post the numbers in an answer.
– Claude Leibovici
Nov 22 at 13:05
1
Comparing to high order expansion of Stirling formula.
– Claude Leibovici
Nov 22 at 13:41
3
3
If you are using modular arithmetic, analytic estimates might not be the most useful thing for you, depending on what exactly your problem is. Instead things like en.wikipedia.org/wiki/Wilson%27s_theorem might help.
– Alex J Best
Nov 22 at 11:53
If you are using modular arithmetic, analytic estimates might not be the most useful thing for you, depending on what exactly your problem is. Instead things like en.wikipedia.org/wiki/Wilson%27s_theorem might help.
– Alex J Best
Nov 22 at 11:53
1
1
There's the gamma function but I don't think it will help you much in contexts of modular arithmetic...
– Prasun Biswas
Nov 22 at 11:57
There's the gamma function but I don't think it will help you much in contexts of modular arithmetic...
– Prasun Biswas
Nov 22 at 11:57
1
1
Have a look at math.stackexchange.com/questions/676952/…. For $n=20$, what I wrote gives $2432902008176665737$ to be compared to the exact $2432902008176640000$
– Claude Leibovici
Nov 22 at 12:32
Have a look at math.stackexchange.com/questions/676952/…. For $n=20$, what I wrote gives $2432902008176665737$ to be compared to the exact $2432902008176640000$
– Claude Leibovici
Nov 22 at 12:32
1
1
I don't know if this could be of interest since the coefficients start to be huge. Using the same kind of expression with degree $2$ in numerator and degree $3$ in denominator, for $n=20$, I get $2432902008176639896$. If you want, I could post the numbers in an answer.
– Claude Leibovici
Nov 22 at 13:05
I don't know if this could be of interest since the coefficients start to be huge. Using the same kind of expression with degree $2$ in numerator and degree $3$ in denominator, for $n=20$, I get $2432902008176639896$. If you want, I could post the numbers in an answer.
– Claude Leibovici
Nov 22 at 13:05
1
1
Comparing to high order expansion of Stirling formula.
– Claude Leibovici
Nov 22 at 13:41
Comparing to high order expansion of Stirling formula.
– Claude Leibovici
Nov 22 at 13:41
|
show 8 more comments
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
Writing
$$n!approxsqrt{pi}left(frac{n}{e}right)^nrootLARGE{6}of{8n^3+4n^2+n+frac 1 {30}color{red}{-}x(n)}$$ with
$$x(n)=frac{a_0+a_1n+a_2n^2}{b_0+b_1n+b_2n^2+b_3n^3}$$ the coefficients are
$$left(
begin{array}{cc}
a_0 & 12521740840824081\
a_1 & 132077016740516320 \
a_2 & 261892615461486240 \
b_0 &3339455095907419720 \
b_1 & 7902477164268212400 \
b_2 & 5812898776788230400
end{array}
right)$$
A few values
$$left(
begin{array}{ccc}
n & text{approximation} & text{exact} \
10 & 3628800 & 3628800 \
15 & 1307674368000 & 1307674368000 \
20 & 2432902008176639896 & 2432902008176640000 \
25 & 15511210043330985910414618 & 15511210043330985984000000 \
30 & 265252859812191058429178640362769 & 265252859812191058636308480000000
end{array}
right)$$
Edit
Using ratios of polyomials (as done in this answer and the previous one) leads to incredibly huge coefficients. Thinking more about it, I thought that is would be better to just write
$$x(n)=sum_{k=1}^m frac{a_k}{n^k}$$ and, when required, transform this expansion to the desired $[p,p+1]$ Padé approximant. The coefficients so obtained are listed below
$$left(
begin{array}{cc}
k & a_k \
1 & frac{11}{240} \
2 & -frac{79}{3360} \
3 & -frac{3539}{201600} \
4 & frac{9511}{403200} \
5 & frac{10051}{716800} \
6 & -frac{233934691}{6386688000} \
7 & -frac{3595113569}{178827264000} \
8 & frac{403527851669}{4649508864000} \
9 & frac{25622861661869}{557941063680000} \
10 & -frac{30016604936501}{101443829760000} \
11 & -frac{685661227463561}{4463528509440000} \
12 & frac{109896661164737049961}{79673983893504000000}
end{array}
right)$$ For $n=25$, this would lead to $color{blue}{1551121004333098598400000}5$.
For $n=30$ , this would lead to $color{blue}{26525285981219105863630848}5359781$.
This seems to be significantly better.
add a comment |
up vote
0
down vote
Stirlings approximation is good ... especially if in the expression for $ln(n!)$ you include the series in odd powers of 1/n. Are you aware of that series - Stirlings aporoximation is all-too-often given without it. The coefficients of it are not too compliated - Bernoulli numbers multiplied by simple factors. Ah yes! maybe it is troublesome for very large n then because of that - the way the Bernoulli numbers 'turn round'.
This might answer your question though.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3009040%2fwhat-is-the-best-estimation-of-the-factorial-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Writing
$$n!approxsqrt{pi}left(frac{n}{e}right)^nrootLARGE{6}of{8n^3+4n^2+n+frac 1 {30}color{red}{-}x(n)}$$ with
$$x(n)=frac{a_0+a_1n+a_2n^2}{b_0+b_1n+b_2n^2+b_3n^3}$$ the coefficients are
$$left(
begin{array}{cc}
a_0 & 12521740840824081\
a_1 & 132077016740516320 \
a_2 & 261892615461486240 \
b_0 &3339455095907419720 \
b_1 & 7902477164268212400 \
b_2 & 5812898776788230400
end{array}
right)$$
A few values
$$left(
begin{array}{ccc}
n & text{approximation} & text{exact} \
10 & 3628800 & 3628800 \
15 & 1307674368000 & 1307674368000 \
20 & 2432902008176639896 & 2432902008176640000 \
25 & 15511210043330985910414618 & 15511210043330985984000000 \
30 & 265252859812191058429178640362769 & 265252859812191058636308480000000
end{array}
right)$$
Edit
Using ratios of polyomials (as done in this answer and the previous one) leads to incredibly huge coefficients. Thinking more about it, I thought that is would be better to just write
$$x(n)=sum_{k=1}^m frac{a_k}{n^k}$$ and, when required, transform this expansion to the desired $[p,p+1]$ Padé approximant. The coefficients so obtained are listed below
$$left(
begin{array}{cc}
k & a_k \
1 & frac{11}{240} \
2 & -frac{79}{3360} \
3 & -frac{3539}{201600} \
4 & frac{9511}{403200} \
5 & frac{10051}{716800} \
6 & -frac{233934691}{6386688000} \
7 & -frac{3595113569}{178827264000} \
8 & frac{403527851669}{4649508864000} \
9 & frac{25622861661869}{557941063680000} \
10 & -frac{30016604936501}{101443829760000} \
11 & -frac{685661227463561}{4463528509440000} \
12 & frac{109896661164737049961}{79673983893504000000}
end{array}
right)$$ For $n=25$, this would lead to $color{blue}{1551121004333098598400000}5$.
For $n=30$ , this would lead to $color{blue}{26525285981219105863630848}5359781$.
This seems to be significantly better.
add a comment |
up vote
1
down vote
accepted
Writing
$$n!approxsqrt{pi}left(frac{n}{e}right)^nrootLARGE{6}of{8n^3+4n^2+n+frac 1 {30}color{red}{-}x(n)}$$ with
$$x(n)=frac{a_0+a_1n+a_2n^2}{b_0+b_1n+b_2n^2+b_3n^3}$$ the coefficients are
$$left(
begin{array}{cc}
a_0 & 12521740840824081\
a_1 & 132077016740516320 \
a_2 & 261892615461486240 \
b_0 &3339455095907419720 \
b_1 & 7902477164268212400 \
b_2 & 5812898776788230400
end{array}
right)$$
A few values
$$left(
begin{array}{ccc}
n & text{approximation} & text{exact} \
10 & 3628800 & 3628800 \
15 & 1307674368000 & 1307674368000 \
20 & 2432902008176639896 & 2432902008176640000 \
25 & 15511210043330985910414618 & 15511210043330985984000000 \
30 & 265252859812191058429178640362769 & 265252859812191058636308480000000
end{array}
right)$$
Edit
Using ratios of polyomials (as done in this answer and the previous one) leads to incredibly huge coefficients. Thinking more about it, I thought that is would be better to just write
$$x(n)=sum_{k=1}^m frac{a_k}{n^k}$$ and, when required, transform this expansion to the desired $[p,p+1]$ Padé approximant. The coefficients so obtained are listed below
$$left(
begin{array}{cc}
k & a_k \
1 & frac{11}{240} \
2 & -frac{79}{3360} \
3 & -frac{3539}{201600} \
4 & frac{9511}{403200} \
5 & frac{10051}{716800} \
6 & -frac{233934691}{6386688000} \
7 & -frac{3595113569}{178827264000} \
8 & frac{403527851669}{4649508864000} \
9 & frac{25622861661869}{557941063680000} \
10 & -frac{30016604936501}{101443829760000} \
11 & -frac{685661227463561}{4463528509440000} \
12 & frac{109896661164737049961}{79673983893504000000}
end{array}
right)$$ For $n=25$, this would lead to $color{blue}{1551121004333098598400000}5$.
For $n=30$ , this would lead to $color{blue}{26525285981219105863630848}5359781$.
This seems to be significantly better.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Writing
$$n!approxsqrt{pi}left(frac{n}{e}right)^nrootLARGE{6}of{8n^3+4n^2+n+frac 1 {30}color{red}{-}x(n)}$$ with
$$x(n)=frac{a_0+a_1n+a_2n^2}{b_0+b_1n+b_2n^2+b_3n^3}$$ the coefficients are
$$left(
begin{array}{cc}
a_0 & 12521740840824081\
a_1 & 132077016740516320 \
a_2 & 261892615461486240 \
b_0 &3339455095907419720 \
b_1 & 7902477164268212400 \
b_2 & 5812898776788230400
end{array}
right)$$
A few values
$$left(
begin{array}{ccc}
n & text{approximation} & text{exact} \
10 & 3628800 & 3628800 \
15 & 1307674368000 & 1307674368000 \
20 & 2432902008176639896 & 2432902008176640000 \
25 & 15511210043330985910414618 & 15511210043330985984000000 \
30 & 265252859812191058429178640362769 & 265252859812191058636308480000000
end{array}
right)$$
Edit
Using ratios of polyomials (as done in this answer and the previous one) leads to incredibly huge coefficients. Thinking more about it, I thought that is would be better to just write
$$x(n)=sum_{k=1}^m frac{a_k}{n^k}$$ and, when required, transform this expansion to the desired $[p,p+1]$ Padé approximant. The coefficients so obtained are listed below
$$left(
begin{array}{cc}
k & a_k \
1 & frac{11}{240} \
2 & -frac{79}{3360} \
3 & -frac{3539}{201600} \
4 & frac{9511}{403200} \
5 & frac{10051}{716800} \
6 & -frac{233934691}{6386688000} \
7 & -frac{3595113569}{178827264000} \
8 & frac{403527851669}{4649508864000} \
9 & frac{25622861661869}{557941063680000} \
10 & -frac{30016604936501}{101443829760000} \
11 & -frac{685661227463561}{4463528509440000} \
12 & frac{109896661164737049961}{79673983893504000000}
end{array}
right)$$ For $n=25$, this would lead to $color{blue}{1551121004333098598400000}5$.
For $n=30$ , this would lead to $color{blue}{26525285981219105863630848}5359781$.
This seems to be significantly better.
Writing
$$n!approxsqrt{pi}left(frac{n}{e}right)^nrootLARGE{6}of{8n^3+4n^2+n+frac 1 {30}color{red}{-}x(n)}$$ with
$$x(n)=frac{a_0+a_1n+a_2n^2}{b_0+b_1n+b_2n^2+b_3n^3}$$ the coefficients are
$$left(
begin{array}{cc}
a_0 & 12521740840824081\
a_1 & 132077016740516320 \
a_2 & 261892615461486240 \
b_0 &3339455095907419720 \
b_1 & 7902477164268212400 \
b_2 & 5812898776788230400
end{array}
right)$$
A few values
$$left(
begin{array}{ccc}
n & text{approximation} & text{exact} \
10 & 3628800 & 3628800 \
15 & 1307674368000 & 1307674368000 \
20 & 2432902008176639896 & 2432902008176640000 \
25 & 15511210043330985910414618 & 15511210043330985984000000 \
30 & 265252859812191058429178640362769 & 265252859812191058636308480000000
end{array}
right)$$
Edit
Using ratios of polyomials (as done in this answer and the previous one) leads to incredibly huge coefficients. Thinking more about it, I thought that is would be better to just write
$$x(n)=sum_{k=1}^m frac{a_k}{n^k}$$ and, when required, transform this expansion to the desired $[p,p+1]$ Padé approximant. The coefficients so obtained are listed below
$$left(
begin{array}{cc}
k & a_k \
1 & frac{11}{240} \
2 & -frac{79}{3360} \
3 & -frac{3539}{201600} \
4 & frac{9511}{403200} \
5 & frac{10051}{716800} \
6 & -frac{233934691}{6386688000} \
7 & -frac{3595113569}{178827264000} \
8 & frac{403527851669}{4649508864000} \
9 & frac{25622861661869}{557941063680000} \
10 & -frac{30016604936501}{101443829760000} \
11 & -frac{685661227463561}{4463528509440000} \
12 & frac{109896661164737049961}{79673983893504000000}
end{array}
right)$$ For $n=25$, this would lead to $color{blue}{1551121004333098598400000}5$.
For $n=30$ , this would lead to $color{blue}{26525285981219105863630848}5359781$.
This seems to be significantly better.
edited Nov 23 at 5:40
answered Nov 22 at 13:39
Claude Leibovici
118k1156131
118k1156131
add a comment |
add a comment |
up vote
0
down vote
Stirlings approximation is good ... especially if in the expression for $ln(n!)$ you include the series in odd powers of 1/n. Are you aware of that series - Stirlings aporoximation is all-too-often given without it. The coefficients of it are not too compliated - Bernoulli numbers multiplied by simple factors. Ah yes! maybe it is troublesome for very large n then because of that - the way the Bernoulli numbers 'turn round'.
This might answer your question though.
add a comment |
up vote
0
down vote
Stirlings approximation is good ... especially if in the expression for $ln(n!)$ you include the series in odd powers of 1/n. Are you aware of that series - Stirlings aporoximation is all-too-often given without it. The coefficients of it are not too compliated - Bernoulli numbers multiplied by simple factors. Ah yes! maybe it is troublesome for very large n then because of that - the way the Bernoulli numbers 'turn round'.
This might answer your question though.
add a comment |
up vote
0
down vote
up vote
0
down vote
Stirlings approximation is good ... especially if in the expression for $ln(n!)$ you include the series in odd powers of 1/n. Are you aware of that series - Stirlings aporoximation is all-too-often given without it. The coefficients of it are not too compliated - Bernoulli numbers multiplied by simple factors. Ah yes! maybe it is troublesome for very large n then because of that - the way the Bernoulli numbers 'turn round'.
This might answer your question though.
Stirlings approximation is good ... especially if in the expression for $ln(n!)$ you include the series in odd powers of 1/n. Are you aware of that series - Stirlings aporoximation is all-too-often given without it. The coefficients of it are not too compliated - Bernoulli numbers multiplied by simple factors. Ah yes! maybe it is troublesome for very large n then because of that - the way the Bernoulli numbers 'turn round'.
This might answer your question though.
answered Nov 23 at 7:06
AmbretteOrrisey
51110
51110
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3009040%2fwhat-is-the-best-estimation-of-the-factorial-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
If you are using modular arithmetic, analytic estimates might not be the most useful thing for you, depending on what exactly your problem is. Instead things like en.wikipedia.org/wiki/Wilson%27s_theorem might help.
– Alex J Best
Nov 22 at 11:53
1
There's the gamma function but I don't think it will help you much in contexts of modular arithmetic...
– Prasun Biswas
Nov 22 at 11:57
1
Have a look at math.stackexchange.com/questions/676952/…. For $n=20$, what I wrote gives $2432902008176665737$ to be compared to the exact $2432902008176640000$
– Claude Leibovici
Nov 22 at 12:32
1
I don't know if this could be of interest since the coefficients start to be huge. Using the same kind of expression with degree $2$ in numerator and degree $3$ in denominator, for $n=20$, I get $2432902008176639896$. If you want, I could post the numbers in an answer.
– Claude Leibovici
Nov 22 at 13:05
1
Comparing to high order expansion of Stirling formula.
– Claude Leibovici
Nov 22 at 13:41