How to solve $1+sum_{k=1}^r 3^kbinom{n}{k}$ (using, say, $ S{n} = frac{a_1(1-r^n)}{1-r} $) so I can use it...
$begingroup$
Following the solution to my previous post in:
Counting unique element output from a product of combination
where the number of unique string-variants generated from a given string is:
$$
1+sum_{k=1}^r 3^kbinom{n}{k}
$$
How to solve the summation so that I could use this formula for large $r$?
My attempt:
I try to solve it using a general formula:
$$
S{n} = frac{a_1(1-r^n)}{1-r}
$$
for $a = 3$ and the common factor $r = 3$. But it turns out that is wrong since the formula above did not has anything to do with the binomial coefficient. Anyone can help?
combinatorics summation binomial-coefficients
$endgroup$
add a comment |
$begingroup$
Following the solution to my previous post in:
Counting unique element output from a product of combination
where the number of unique string-variants generated from a given string is:
$$
1+sum_{k=1}^r 3^kbinom{n}{k}
$$
How to solve the summation so that I could use this formula for large $r$?
My attempt:
I try to solve it using a general formula:
$$
S{n} = frac{a_1(1-r^n)}{1-r}
$$
for $a = 3$ and the common factor $r = 3$. But it turns out that is wrong since the formula above did not has anything to do with the binomial coefficient. Anyone can help?
combinatorics summation binomial-coefficients
$endgroup$
$begingroup$
I've edited the $LaTeX$. Did you mean $S{ n}$ or something else?
$endgroup$
– Shaun
Dec 28 '18 at 7:21
$begingroup$
What is an example of a large $r$? Are $n$ and $r$ integers? positive?
$endgroup$
– Eric Towers
Dec 28 '18 at 7:27
add a comment |
$begingroup$
Following the solution to my previous post in:
Counting unique element output from a product of combination
where the number of unique string-variants generated from a given string is:
$$
1+sum_{k=1}^r 3^kbinom{n}{k}
$$
How to solve the summation so that I could use this formula for large $r$?
My attempt:
I try to solve it using a general formula:
$$
S{n} = frac{a_1(1-r^n)}{1-r}
$$
for $a = 3$ and the common factor $r = 3$. But it turns out that is wrong since the formula above did not has anything to do with the binomial coefficient. Anyone can help?
combinatorics summation binomial-coefficients
$endgroup$
Following the solution to my previous post in:
Counting unique element output from a product of combination
where the number of unique string-variants generated from a given string is:
$$
1+sum_{k=1}^r 3^kbinom{n}{k}
$$
How to solve the summation so that I could use this formula for large $r$?
My attempt:
I try to solve it using a general formula:
$$
S{n} = frac{a_1(1-r^n)}{1-r}
$$
for $a = 3$ and the common factor $r = 3$. But it turns out that is wrong since the formula above did not has anything to do with the binomial coefficient. Anyone can help?
combinatorics summation binomial-coefficients
combinatorics summation binomial-coefficients
edited Dec 28 '18 at 7:27
Shaun
9,544113684
9,544113684
asked Dec 28 '18 at 7:15
Vic BrownVic Brown
213
213
$begingroup$
I've edited the $LaTeX$. Did you mean $S{ n}$ or something else?
$endgroup$
– Shaun
Dec 28 '18 at 7:21
$begingroup$
What is an example of a large $r$? Are $n$ and $r$ integers? positive?
$endgroup$
– Eric Towers
Dec 28 '18 at 7:27
add a comment |
$begingroup$
I've edited the $LaTeX$. Did you mean $S{ n}$ or something else?
$endgroup$
– Shaun
Dec 28 '18 at 7:21
$begingroup$
What is an example of a large $r$? Are $n$ and $r$ integers? positive?
$endgroup$
– Eric Towers
Dec 28 '18 at 7:27
$begingroup$
I've edited the $LaTeX$. Did you mean $S{ n}$ or something else?
$endgroup$
– Shaun
Dec 28 '18 at 7:21
$begingroup$
I've edited the $LaTeX$. Did you mean $S{ n}$ or something else?
$endgroup$
– Shaun
Dec 28 '18 at 7:21
$begingroup$
What is an example of a large $r$? Are $n$ and $r$ integers? positive?
$endgroup$
– Eric Towers
Dec 28 '18 at 7:27
$begingroup$
What is an example of a large $r$? Are $n$ and $r$ integers? positive?
$endgroup$
– Eric Towers
Dec 28 '18 at 7:27
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
This sum does not have an elementary representation. Let $f(r,n)$ be your sum. By a CAS
begin{align*}
f(r,n) &= 1 + sum_{k=1}^r 3^k binom{n}{k} \
&= 4^n - 3^{r+1}binom{n}{r+1}{}_2F_1(1,r-n+1;r+2;-3)
end{align*}
where ${}_2F_1$ is the Gaussian hypergeometric function. Even assuming $r$ and $n$ integers with $0 < r < n$, there are no simplifications to elementary functions.
For $1 leq r < n$, use the sum. This is easy as long as $n$ is not large. You give no hints about the size of $n$ in your question. Your prior post claims you are only interested in $1 leq r leq 4$, so this sum is nearly immediate.
For $r geq n$, $f(r,n) = 4^n$. This follows from your sum since $binom{n}{n+1} = binom{n}{n+2} = cdots = 0$, so the sum cuts itself off after $r = n$, and a standard identity (first one at that link, taking $x = 3$ and realizing the $k = 0$ term is the "$1+$" in $f$). In the context of your previous post (not having read it in detail) -- once you've decided to replace every character in your string, then you have any $n$-length string you want from your 4 character alphabet, giving $4^n$ possibilities.
Digging through OP's referenced Question, he most likely intends $1 leq r leq 4$ and $r leq n$. These constraints appear nowhere in the current Question. With those constraints ...
begin{align*}
f(1,n) &= 1 + 3n text{,} \
f(2,n) &= 1 + 3n + frac{9}{2}n(n-1) text{,} \
f(3,n) &= frac{1}{2}(9n^2 -3n+2) + frac{9}{2}n(n-1)(n-2) text{, and} \
f(4,n) &= frac{1}{2}(9n^3 - 18 n^2 + 15 n + 2) + frac{27}{8}n(n-1)(n-2)(n-3) text{.}
end{align*}
For example, $f(4,10,000) = 33,734,252,812,372,501$. I note this because representing such quantities in a programming language as precise integers (instead of imprecise floating point approximations) can require some effort. Letting $r$ and $n$ be "large" necessitates this effort. If you intend to generate these numbers in a programming language, it would help to know which language you are targetting.
Just testing for timing, I get the complete set of results for $n = 10,000$ in about 180 ms using this code:
import itertools
import time
class sumterm:
"""Iterator to produce terms of a specific sum counting replaced strings."""
def __init__(self, nInit):
# Rememember: Iterators start in a "prior to the first element" state
# and are expected to yield the first element on the first call to
# __next__().
self.n = nInit
self.k = 0
self.term = 1 # 3^k binom(n,k) = 1 binom(n,0) = 1, when k = 0
def __iter__(self):
try: self.n
except NameError: raise ValueError("sumterm objects must be initialized before iterating.")
return self
def __next__(self):
if self.k < self.n:
# 3^(k+1) binom(n,k+1) = 3^k binom(n,k) * 3(n-k)/(k+1)
# Integer division ( // ) is safe because divisibility is ensured.
self.term = self.term * 3*(self.n - self.k) // (self.k+1)
self.k += 1
return self.term
else:
raise StopIteration
n = 10000
tBefore = time.time()
terms = list(iter(sumterm(n)))
partialSums = [1+x for x in itertools.accumulate(terms) ]
tAfter = time.time()
print("For n = ", n, ", k = 1 .. 11: ", partialSums[:11])
print("Took", tAfter - tBefore, " seconds.")
Don't bother trying to print the last few terms. $4^{10,000}$ is too large to usefully look at.
Note that partialSums[k-1]
is $f(k,n)$ for $k leq n$.
begin{align*}
f(1,n) &= 1 + sum_{k=1}^1 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} \
&= 1 + 3 n text{, } \
f(2,n) &= 1 + sum_{k=1}^2 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} \
&= 1 + 3 n + 9frac{n(n-1)}{2} text{, } \
f(3,n) &= 1 + sum_{k=1}^3 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} + 3^3 binom{n}{3} \
&= 1 + 3 n + 9frac{n(n-1)}{2} + 27frac{n(n-1)(n-2)}{6} \
&= frac{1}{2}(2 + 6n + 9n(n-1)) + frac{9}{2}n(n-1)(n-2) \
&= frac{1}{2}(9n^2 - 3 n + 2) + frac{9}{2}n(n-1)(n-2) text{,}
end{align*}
and
begin{align*}
f(4,n) &= 1 + sum_{k=1}^4 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} + 3^3 binom{n}{3} + 3^4 binom{n}{4} \
&= 1 + 3 n + 9frac{n(n-1)}{2} + 27frac{n(n-1)(n-2)}{6} + 81frac{n(n-1)(n-2)(n-3)}{24} \
&= frac{1}{2}(2 + 6n + 9n(n-1) + 9n(n-1)(n-2)) + frac{27}{8}n(n-1)(n-2)(n-3) \
&= frac{1}{2}(9 n^3 - 18 n^2 + 15 n + 2) + frac{27}{8}n(n-1)(n-2)(n-3) text{.} \
end{align*}
$endgroup$
$begingroup$
Thanks. Yes, I only intend to use $1 leq r < 4$ since the substituents only composed of four characters. I am just curious whether the formula $1+sum_{k=1}^r 3^kbinom{n}{k}$ could be simplified to elementary function so that it could be used for n let's say 10,000 and r at most equals to n. Sum it up for such n and r would be cumbersome.
$endgroup$
– Vic Brown
Dec 30 '18 at 5:35
$begingroup$
@VicBrown : So it can't be simplified to an elementary function. Perhaps it can be approximated with something elementary. Would an approximation (and if so, how precise and accurate would you require) suffice?
$endgroup$
– Eric Towers
Dec 30 '18 at 18:25
$begingroup$
@VicBrown : Officially, answers to questions on this site are evaluated (by the crowds) as answers to the Question as asked. Your Question does not include the constraints $1 leq r leq 4$ and $r leq n$, which I infer from your referenced question. Since those are not part of the current question, they cannot be assumed in an Answer.
$endgroup$
– Eric Towers
Dec 30 '18 at 22:57
$begingroup$
@VicBrown : As the extension to my question shows, for $n = 10,000$, $f(r,n)$ quickly exceeds usual integral representations in some programming languages. If you intend to compute these with software, it would be helpful to know what your targetted software is.
$endgroup$
– Eric Towers
Dec 30 '18 at 23:16
$begingroup$
Your solution above and it is similar to what I solve using polynomial equation for r = 1 to 4 and n = 3 to 10, where: $$ f(1,n) = 3n + 1 $$ $$ f(2,n) = frac{9}{2}n^2 - frac{3}{2}n + 1 $$ $$ f(3,n) = frac{27}{6}n^3 - 9n^2 + 15n + 1 $$ $$ f(4,n) = frac{27}{8}n^4 - frac{63}{4}n^3 + frac{225}{8}n^2 - frac{51}{4}n + 1 $$ I do not intend to apply such equation into my program (I am using Python 3 by the way). I just only wanted to provide mathematical proof that a list of unique string variants generated by the program is correct.
$endgroup$
– Vic Brown
Dec 31 '18 at 5:36
|
show 3 more comments
$begingroup$
In case you are interested in asymptotics:
$$begin{align}
s(n,r)&=sum_{k=1}^r 3^kbinom{n}{k}\
&=2^nsum_{k=1}^r 3^kfrac{binom{n}{k}}{2^n}\
&approx frac{2^n}{sqrt{pi n /2}} int_0^r 3^x expleft( -frac{2}{n}(x-n/2)^2 right)
dx \
end{align}$$
If $r > 0.78 n$ we can apply Laplace's method and get the first order approximation:
$$ frac{log (s(n,r))}{n} to log(2) + frac{log^2(3)+ 4 log 3}{8}approx 1.393$$
For smaller $r$ , a similar approximation can be obtained (tell me if you are interested) but it involves both $(n,r)$ variables.
$endgroup$
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',
autoActivateHeartbeat: false,
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%2f3054644%2fhow-to-solve-1-sum-k-1r-3k-binomnk-using-say-s-n-fraca-1%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
$begingroup$
This sum does not have an elementary representation. Let $f(r,n)$ be your sum. By a CAS
begin{align*}
f(r,n) &= 1 + sum_{k=1}^r 3^k binom{n}{k} \
&= 4^n - 3^{r+1}binom{n}{r+1}{}_2F_1(1,r-n+1;r+2;-3)
end{align*}
where ${}_2F_1$ is the Gaussian hypergeometric function. Even assuming $r$ and $n$ integers with $0 < r < n$, there are no simplifications to elementary functions.
For $1 leq r < n$, use the sum. This is easy as long as $n$ is not large. You give no hints about the size of $n$ in your question. Your prior post claims you are only interested in $1 leq r leq 4$, so this sum is nearly immediate.
For $r geq n$, $f(r,n) = 4^n$. This follows from your sum since $binom{n}{n+1} = binom{n}{n+2} = cdots = 0$, so the sum cuts itself off after $r = n$, and a standard identity (first one at that link, taking $x = 3$ and realizing the $k = 0$ term is the "$1+$" in $f$). In the context of your previous post (not having read it in detail) -- once you've decided to replace every character in your string, then you have any $n$-length string you want from your 4 character alphabet, giving $4^n$ possibilities.
Digging through OP's referenced Question, he most likely intends $1 leq r leq 4$ and $r leq n$. These constraints appear nowhere in the current Question. With those constraints ...
begin{align*}
f(1,n) &= 1 + 3n text{,} \
f(2,n) &= 1 + 3n + frac{9}{2}n(n-1) text{,} \
f(3,n) &= frac{1}{2}(9n^2 -3n+2) + frac{9}{2}n(n-1)(n-2) text{, and} \
f(4,n) &= frac{1}{2}(9n^3 - 18 n^2 + 15 n + 2) + frac{27}{8}n(n-1)(n-2)(n-3) text{.}
end{align*}
For example, $f(4,10,000) = 33,734,252,812,372,501$. I note this because representing such quantities in a programming language as precise integers (instead of imprecise floating point approximations) can require some effort. Letting $r$ and $n$ be "large" necessitates this effort. If you intend to generate these numbers in a programming language, it would help to know which language you are targetting.
Just testing for timing, I get the complete set of results for $n = 10,000$ in about 180 ms using this code:
import itertools
import time
class sumterm:
"""Iterator to produce terms of a specific sum counting replaced strings."""
def __init__(self, nInit):
# Rememember: Iterators start in a "prior to the first element" state
# and are expected to yield the first element on the first call to
# __next__().
self.n = nInit
self.k = 0
self.term = 1 # 3^k binom(n,k) = 1 binom(n,0) = 1, when k = 0
def __iter__(self):
try: self.n
except NameError: raise ValueError("sumterm objects must be initialized before iterating.")
return self
def __next__(self):
if self.k < self.n:
# 3^(k+1) binom(n,k+1) = 3^k binom(n,k) * 3(n-k)/(k+1)
# Integer division ( // ) is safe because divisibility is ensured.
self.term = self.term * 3*(self.n - self.k) // (self.k+1)
self.k += 1
return self.term
else:
raise StopIteration
n = 10000
tBefore = time.time()
terms = list(iter(sumterm(n)))
partialSums = [1+x for x in itertools.accumulate(terms) ]
tAfter = time.time()
print("For n = ", n, ", k = 1 .. 11: ", partialSums[:11])
print("Took", tAfter - tBefore, " seconds.")
Don't bother trying to print the last few terms. $4^{10,000}$ is too large to usefully look at.
Note that partialSums[k-1]
is $f(k,n)$ for $k leq n$.
begin{align*}
f(1,n) &= 1 + sum_{k=1}^1 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} \
&= 1 + 3 n text{, } \
f(2,n) &= 1 + sum_{k=1}^2 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} \
&= 1 + 3 n + 9frac{n(n-1)}{2} text{, } \
f(3,n) &= 1 + sum_{k=1}^3 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} + 3^3 binom{n}{3} \
&= 1 + 3 n + 9frac{n(n-1)}{2} + 27frac{n(n-1)(n-2)}{6} \
&= frac{1}{2}(2 + 6n + 9n(n-1)) + frac{9}{2}n(n-1)(n-2) \
&= frac{1}{2}(9n^2 - 3 n + 2) + frac{9}{2}n(n-1)(n-2) text{,}
end{align*}
and
begin{align*}
f(4,n) &= 1 + sum_{k=1}^4 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} + 3^3 binom{n}{3} + 3^4 binom{n}{4} \
&= 1 + 3 n + 9frac{n(n-1)}{2} + 27frac{n(n-1)(n-2)}{6} + 81frac{n(n-1)(n-2)(n-3)}{24} \
&= frac{1}{2}(2 + 6n + 9n(n-1) + 9n(n-1)(n-2)) + frac{27}{8}n(n-1)(n-2)(n-3) \
&= frac{1}{2}(9 n^3 - 18 n^2 + 15 n + 2) + frac{27}{8}n(n-1)(n-2)(n-3) text{.} \
end{align*}
$endgroup$
$begingroup$
Thanks. Yes, I only intend to use $1 leq r < 4$ since the substituents only composed of four characters. I am just curious whether the formula $1+sum_{k=1}^r 3^kbinom{n}{k}$ could be simplified to elementary function so that it could be used for n let's say 10,000 and r at most equals to n. Sum it up for such n and r would be cumbersome.
$endgroup$
– Vic Brown
Dec 30 '18 at 5:35
$begingroup$
@VicBrown : So it can't be simplified to an elementary function. Perhaps it can be approximated with something elementary. Would an approximation (and if so, how precise and accurate would you require) suffice?
$endgroup$
– Eric Towers
Dec 30 '18 at 18:25
$begingroup$
@VicBrown : Officially, answers to questions on this site are evaluated (by the crowds) as answers to the Question as asked. Your Question does not include the constraints $1 leq r leq 4$ and $r leq n$, which I infer from your referenced question. Since those are not part of the current question, they cannot be assumed in an Answer.
$endgroup$
– Eric Towers
Dec 30 '18 at 22:57
$begingroup$
@VicBrown : As the extension to my question shows, for $n = 10,000$, $f(r,n)$ quickly exceeds usual integral representations in some programming languages. If you intend to compute these with software, it would be helpful to know what your targetted software is.
$endgroup$
– Eric Towers
Dec 30 '18 at 23:16
$begingroup$
Your solution above and it is similar to what I solve using polynomial equation for r = 1 to 4 and n = 3 to 10, where: $$ f(1,n) = 3n + 1 $$ $$ f(2,n) = frac{9}{2}n^2 - frac{3}{2}n + 1 $$ $$ f(3,n) = frac{27}{6}n^3 - 9n^2 + 15n + 1 $$ $$ f(4,n) = frac{27}{8}n^4 - frac{63}{4}n^3 + frac{225}{8}n^2 - frac{51}{4}n + 1 $$ I do not intend to apply such equation into my program (I am using Python 3 by the way). I just only wanted to provide mathematical proof that a list of unique string variants generated by the program is correct.
$endgroup$
– Vic Brown
Dec 31 '18 at 5:36
|
show 3 more comments
$begingroup$
This sum does not have an elementary representation. Let $f(r,n)$ be your sum. By a CAS
begin{align*}
f(r,n) &= 1 + sum_{k=1}^r 3^k binom{n}{k} \
&= 4^n - 3^{r+1}binom{n}{r+1}{}_2F_1(1,r-n+1;r+2;-3)
end{align*}
where ${}_2F_1$ is the Gaussian hypergeometric function. Even assuming $r$ and $n$ integers with $0 < r < n$, there are no simplifications to elementary functions.
For $1 leq r < n$, use the sum. This is easy as long as $n$ is not large. You give no hints about the size of $n$ in your question. Your prior post claims you are only interested in $1 leq r leq 4$, so this sum is nearly immediate.
For $r geq n$, $f(r,n) = 4^n$. This follows from your sum since $binom{n}{n+1} = binom{n}{n+2} = cdots = 0$, so the sum cuts itself off after $r = n$, and a standard identity (first one at that link, taking $x = 3$ and realizing the $k = 0$ term is the "$1+$" in $f$). In the context of your previous post (not having read it in detail) -- once you've decided to replace every character in your string, then you have any $n$-length string you want from your 4 character alphabet, giving $4^n$ possibilities.
Digging through OP's referenced Question, he most likely intends $1 leq r leq 4$ and $r leq n$. These constraints appear nowhere in the current Question. With those constraints ...
begin{align*}
f(1,n) &= 1 + 3n text{,} \
f(2,n) &= 1 + 3n + frac{9}{2}n(n-1) text{,} \
f(3,n) &= frac{1}{2}(9n^2 -3n+2) + frac{9}{2}n(n-1)(n-2) text{, and} \
f(4,n) &= frac{1}{2}(9n^3 - 18 n^2 + 15 n + 2) + frac{27}{8}n(n-1)(n-2)(n-3) text{.}
end{align*}
For example, $f(4,10,000) = 33,734,252,812,372,501$. I note this because representing such quantities in a programming language as precise integers (instead of imprecise floating point approximations) can require some effort. Letting $r$ and $n$ be "large" necessitates this effort. If you intend to generate these numbers in a programming language, it would help to know which language you are targetting.
Just testing for timing, I get the complete set of results for $n = 10,000$ in about 180 ms using this code:
import itertools
import time
class sumterm:
"""Iterator to produce terms of a specific sum counting replaced strings."""
def __init__(self, nInit):
# Rememember: Iterators start in a "prior to the first element" state
# and are expected to yield the first element on the first call to
# __next__().
self.n = nInit
self.k = 0
self.term = 1 # 3^k binom(n,k) = 1 binom(n,0) = 1, when k = 0
def __iter__(self):
try: self.n
except NameError: raise ValueError("sumterm objects must be initialized before iterating.")
return self
def __next__(self):
if self.k < self.n:
# 3^(k+1) binom(n,k+1) = 3^k binom(n,k) * 3(n-k)/(k+1)
# Integer division ( // ) is safe because divisibility is ensured.
self.term = self.term * 3*(self.n - self.k) // (self.k+1)
self.k += 1
return self.term
else:
raise StopIteration
n = 10000
tBefore = time.time()
terms = list(iter(sumterm(n)))
partialSums = [1+x for x in itertools.accumulate(terms) ]
tAfter = time.time()
print("For n = ", n, ", k = 1 .. 11: ", partialSums[:11])
print("Took", tAfter - tBefore, " seconds.")
Don't bother trying to print the last few terms. $4^{10,000}$ is too large to usefully look at.
Note that partialSums[k-1]
is $f(k,n)$ for $k leq n$.
begin{align*}
f(1,n) &= 1 + sum_{k=1}^1 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} \
&= 1 + 3 n text{, } \
f(2,n) &= 1 + sum_{k=1}^2 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} \
&= 1 + 3 n + 9frac{n(n-1)}{2} text{, } \
f(3,n) &= 1 + sum_{k=1}^3 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} + 3^3 binom{n}{3} \
&= 1 + 3 n + 9frac{n(n-1)}{2} + 27frac{n(n-1)(n-2)}{6} \
&= frac{1}{2}(2 + 6n + 9n(n-1)) + frac{9}{2}n(n-1)(n-2) \
&= frac{1}{2}(9n^2 - 3 n + 2) + frac{9}{2}n(n-1)(n-2) text{,}
end{align*}
and
begin{align*}
f(4,n) &= 1 + sum_{k=1}^4 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} + 3^3 binom{n}{3} + 3^4 binom{n}{4} \
&= 1 + 3 n + 9frac{n(n-1)}{2} + 27frac{n(n-1)(n-2)}{6} + 81frac{n(n-1)(n-2)(n-3)}{24} \
&= frac{1}{2}(2 + 6n + 9n(n-1) + 9n(n-1)(n-2)) + frac{27}{8}n(n-1)(n-2)(n-3) \
&= frac{1}{2}(9 n^3 - 18 n^2 + 15 n + 2) + frac{27}{8}n(n-1)(n-2)(n-3) text{.} \
end{align*}
$endgroup$
$begingroup$
Thanks. Yes, I only intend to use $1 leq r < 4$ since the substituents only composed of four characters. I am just curious whether the formula $1+sum_{k=1}^r 3^kbinom{n}{k}$ could be simplified to elementary function so that it could be used for n let's say 10,000 and r at most equals to n. Sum it up for such n and r would be cumbersome.
$endgroup$
– Vic Brown
Dec 30 '18 at 5:35
$begingroup$
@VicBrown : So it can't be simplified to an elementary function. Perhaps it can be approximated with something elementary. Would an approximation (and if so, how precise and accurate would you require) suffice?
$endgroup$
– Eric Towers
Dec 30 '18 at 18:25
$begingroup$
@VicBrown : Officially, answers to questions on this site are evaluated (by the crowds) as answers to the Question as asked. Your Question does not include the constraints $1 leq r leq 4$ and $r leq n$, which I infer from your referenced question. Since those are not part of the current question, they cannot be assumed in an Answer.
$endgroup$
– Eric Towers
Dec 30 '18 at 22:57
$begingroup$
@VicBrown : As the extension to my question shows, for $n = 10,000$, $f(r,n)$ quickly exceeds usual integral representations in some programming languages. If you intend to compute these with software, it would be helpful to know what your targetted software is.
$endgroup$
– Eric Towers
Dec 30 '18 at 23:16
$begingroup$
Your solution above and it is similar to what I solve using polynomial equation for r = 1 to 4 and n = 3 to 10, where: $$ f(1,n) = 3n + 1 $$ $$ f(2,n) = frac{9}{2}n^2 - frac{3}{2}n + 1 $$ $$ f(3,n) = frac{27}{6}n^3 - 9n^2 + 15n + 1 $$ $$ f(4,n) = frac{27}{8}n^4 - frac{63}{4}n^3 + frac{225}{8}n^2 - frac{51}{4}n + 1 $$ I do not intend to apply such equation into my program (I am using Python 3 by the way). I just only wanted to provide mathematical proof that a list of unique string variants generated by the program is correct.
$endgroup$
– Vic Brown
Dec 31 '18 at 5:36
|
show 3 more comments
$begingroup$
This sum does not have an elementary representation. Let $f(r,n)$ be your sum. By a CAS
begin{align*}
f(r,n) &= 1 + sum_{k=1}^r 3^k binom{n}{k} \
&= 4^n - 3^{r+1}binom{n}{r+1}{}_2F_1(1,r-n+1;r+2;-3)
end{align*}
where ${}_2F_1$ is the Gaussian hypergeometric function. Even assuming $r$ and $n$ integers with $0 < r < n$, there are no simplifications to elementary functions.
For $1 leq r < n$, use the sum. This is easy as long as $n$ is not large. You give no hints about the size of $n$ in your question. Your prior post claims you are only interested in $1 leq r leq 4$, so this sum is nearly immediate.
For $r geq n$, $f(r,n) = 4^n$. This follows from your sum since $binom{n}{n+1} = binom{n}{n+2} = cdots = 0$, so the sum cuts itself off after $r = n$, and a standard identity (first one at that link, taking $x = 3$ and realizing the $k = 0$ term is the "$1+$" in $f$). In the context of your previous post (not having read it in detail) -- once you've decided to replace every character in your string, then you have any $n$-length string you want from your 4 character alphabet, giving $4^n$ possibilities.
Digging through OP's referenced Question, he most likely intends $1 leq r leq 4$ and $r leq n$. These constraints appear nowhere in the current Question. With those constraints ...
begin{align*}
f(1,n) &= 1 + 3n text{,} \
f(2,n) &= 1 + 3n + frac{9}{2}n(n-1) text{,} \
f(3,n) &= frac{1}{2}(9n^2 -3n+2) + frac{9}{2}n(n-1)(n-2) text{, and} \
f(4,n) &= frac{1}{2}(9n^3 - 18 n^2 + 15 n + 2) + frac{27}{8}n(n-1)(n-2)(n-3) text{.}
end{align*}
For example, $f(4,10,000) = 33,734,252,812,372,501$. I note this because representing such quantities in a programming language as precise integers (instead of imprecise floating point approximations) can require some effort. Letting $r$ and $n$ be "large" necessitates this effort. If you intend to generate these numbers in a programming language, it would help to know which language you are targetting.
Just testing for timing, I get the complete set of results for $n = 10,000$ in about 180 ms using this code:
import itertools
import time
class sumterm:
"""Iterator to produce terms of a specific sum counting replaced strings."""
def __init__(self, nInit):
# Rememember: Iterators start in a "prior to the first element" state
# and are expected to yield the first element on the first call to
# __next__().
self.n = nInit
self.k = 0
self.term = 1 # 3^k binom(n,k) = 1 binom(n,0) = 1, when k = 0
def __iter__(self):
try: self.n
except NameError: raise ValueError("sumterm objects must be initialized before iterating.")
return self
def __next__(self):
if self.k < self.n:
# 3^(k+1) binom(n,k+1) = 3^k binom(n,k) * 3(n-k)/(k+1)
# Integer division ( // ) is safe because divisibility is ensured.
self.term = self.term * 3*(self.n - self.k) // (self.k+1)
self.k += 1
return self.term
else:
raise StopIteration
n = 10000
tBefore = time.time()
terms = list(iter(sumterm(n)))
partialSums = [1+x for x in itertools.accumulate(terms) ]
tAfter = time.time()
print("For n = ", n, ", k = 1 .. 11: ", partialSums[:11])
print("Took", tAfter - tBefore, " seconds.")
Don't bother trying to print the last few terms. $4^{10,000}$ is too large to usefully look at.
Note that partialSums[k-1]
is $f(k,n)$ for $k leq n$.
begin{align*}
f(1,n) &= 1 + sum_{k=1}^1 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} \
&= 1 + 3 n text{, } \
f(2,n) &= 1 + sum_{k=1}^2 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} \
&= 1 + 3 n + 9frac{n(n-1)}{2} text{, } \
f(3,n) &= 1 + sum_{k=1}^3 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} + 3^3 binom{n}{3} \
&= 1 + 3 n + 9frac{n(n-1)}{2} + 27frac{n(n-1)(n-2)}{6} \
&= frac{1}{2}(2 + 6n + 9n(n-1)) + frac{9}{2}n(n-1)(n-2) \
&= frac{1}{2}(9n^2 - 3 n + 2) + frac{9}{2}n(n-1)(n-2) text{,}
end{align*}
and
begin{align*}
f(4,n) &= 1 + sum_{k=1}^4 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} + 3^3 binom{n}{3} + 3^4 binom{n}{4} \
&= 1 + 3 n + 9frac{n(n-1)}{2} + 27frac{n(n-1)(n-2)}{6} + 81frac{n(n-1)(n-2)(n-3)}{24} \
&= frac{1}{2}(2 + 6n + 9n(n-1) + 9n(n-1)(n-2)) + frac{27}{8}n(n-1)(n-2)(n-3) \
&= frac{1}{2}(9 n^3 - 18 n^2 + 15 n + 2) + frac{27}{8}n(n-1)(n-2)(n-3) text{.} \
end{align*}
$endgroup$
This sum does not have an elementary representation. Let $f(r,n)$ be your sum. By a CAS
begin{align*}
f(r,n) &= 1 + sum_{k=1}^r 3^k binom{n}{k} \
&= 4^n - 3^{r+1}binom{n}{r+1}{}_2F_1(1,r-n+1;r+2;-3)
end{align*}
where ${}_2F_1$ is the Gaussian hypergeometric function. Even assuming $r$ and $n$ integers with $0 < r < n$, there are no simplifications to elementary functions.
For $1 leq r < n$, use the sum. This is easy as long as $n$ is not large. You give no hints about the size of $n$ in your question. Your prior post claims you are only interested in $1 leq r leq 4$, so this sum is nearly immediate.
For $r geq n$, $f(r,n) = 4^n$. This follows from your sum since $binom{n}{n+1} = binom{n}{n+2} = cdots = 0$, so the sum cuts itself off after $r = n$, and a standard identity (first one at that link, taking $x = 3$ and realizing the $k = 0$ term is the "$1+$" in $f$). In the context of your previous post (not having read it in detail) -- once you've decided to replace every character in your string, then you have any $n$-length string you want from your 4 character alphabet, giving $4^n$ possibilities.
Digging through OP's referenced Question, he most likely intends $1 leq r leq 4$ and $r leq n$. These constraints appear nowhere in the current Question. With those constraints ...
begin{align*}
f(1,n) &= 1 + 3n text{,} \
f(2,n) &= 1 + 3n + frac{9}{2}n(n-1) text{,} \
f(3,n) &= frac{1}{2}(9n^2 -3n+2) + frac{9}{2}n(n-1)(n-2) text{, and} \
f(4,n) &= frac{1}{2}(9n^3 - 18 n^2 + 15 n + 2) + frac{27}{8}n(n-1)(n-2)(n-3) text{.}
end{align*}
For example, $f(4,10,000) = 33,734,252,812,372,501$. I note this because representing such quantities in a programming language as precise integers (instead of imprecise floating point approximations) can require some effort. Letting $r$ and $n$ be "large" necessitates this effort. If you intend to generate these numbers in a programming language, it would help to know which language you are targetting.
Just testing for timing, I get the complete set of results for $n = 10,000$ in about 180 ms using this code:
import itertools
import time
class sumterm:
"""Iterator to produce terms of a specific sum counting replaced strings."""
def __init__(self, nInit):
# Rememember: Iterators start in a "prior to the first element" state
# and are expected to yield the first element on the first call to
# __next__().
self.n = nInit
self.k = 0
self.term = 1 # 3^k binom(n,k) = 1 binom(n,0) = 1, when k = 0
def __iter__(self):
try: self.n
except NameError: raise ValueError("sumterm objects must be initialized before iterating.")
return self
def __next__(self):
if self.k < self.n:
# 3^(k+1) binom(n,k+1) = 3^k binom(n,k) * 3(n-k)/(k+1)
# Integer division ( // ) is safe because divisibility is ensured.
self.term = self.term * 3*(self.n - self.k) // (self.k+1)
self.k += 1
return self.term
else:
raise StopIteration
n = 10000
tBefore = time.time()
terms = list(iter(sumterm(n)))
partialSums = [1+x for x in itertools.accumulate(terms) ]
tAfter = time.time()
print("For n = ", n, ", k = 1 .. 11: ", partialSums[:11])
print("Took", tAfter - tBefore, " seconds.")
Don't bother trying to print the last few terms. $4^{10,000}$ is too large to usefully look at.
Note that partialSums[k-1]
is $f(k,n)$ for $k leq n$.
begin{align*}
f(1,n) &= 1 + sum_{k=1}^1 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} \
&= 1 + 3 n text{, } \
f(2,n) &= 1 + sum_{k=1}^2 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} \
&= 1 + 3 n + 9frac{n(n-1)}{2} text{, } \
f(3,n) &= 1 + sum_{k=1}^3 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} + 3^3 binom{n}{3} \
&= 1 + 3 n + 9frac{n(n-1)}{2} + 27frac{n(n-1)(n-2)}{6} \
&= frac{1}{2}(2 + 6n + 9n(n-1)) + frac{9}{2}n(n-1)(n-2) \
&= frac{1}{2}(9n^2 - 3 n + 2) + frac{9}{2}n(n-1)(n-2) text{,}
end{align*}
and
begin{align*}
f(4,n) &= 1 + sum_{k=1}^4 3^k binom{n}{k} \
&= 1 + 3^1 binom{n}{1} + 3^2 binom{n}{2} + 3^3 binom{n}{3} + 3^4 binom{n}{4} \
&= 1 + 3 n + 9frac{n(n-1)}{2} + 27frac{n(n-1)(n-2)}{6} + 81frac{n(n-1)(n-2)(n-3)}{24} \
&= frac{1}{2}(2 + 6n + 9n(n-1) + 9n(n-1)(n-2)) + frac{27}{8}n(n-1)(n-2)(n-3) \
&= frac{1}{2}(9 n^3 - 18 n^2 + 15 n + 2) + frac{27}{8}n(n-1)(n-2)(n-3) text{.} \
end{align*}
edited Jan 2 at 17:56
answered Dec 28 '18 at 8:12
Eric TowersEric Towers
32.9k22370
32.9k22370
$begingroup$
Thanks. Yes, I only intend to use $1 leq r < 4$ since the substituents only composed of four characters. I am just curious whether the formula $1+sum_{k=1}^r 3^kbinom{n}{k}$ could be simplified to elementary function so that it could be used for n let's say 10,000 and r at most equals to n. Sum it up for such n and r would be cumbersome.
$endgroup$
– Vic Brown
Dec 30 '18 at 5:35
$begingroup$
@VicBrown : So it can't be simplified to an elementary function. Perhaps it can be approximated with something elementary. Would an approximation (and if so, how precise and accurate would you require) suffice?
$endgroup$
– Eric Towers
Dec 30 '18 at 18:25
$begingroup$
@VicBrown : Officially, answers to questions on this site are evaluated (by the crowds) as answers to the Question as asked. Your Question does not include the constraints $1 leq r leq 4$ and $r leq n$, which I infer from your referenced question. Since those are not part of the current question, they cannot be assumed in an Answer.
$endgroup$
– Eric Towers
Dec 30 '18 at 22:57
$begingroup$
@VicBrown : As the extension to my question shows, for $n = 10,000$, $f(r,n)$ quickly exceeds usual integral representations in some programming languages. If you intend to compute these with software, it would be helpful to know what your targetted software is.
$endgroup$
– Eric Towers
Dec 30 '18 at 23:16
$begingroup$
Your solution above and it is similar to what I solve using polynomial equation for r = 1 to 4 and n = 3 to 10, where: $$ f(1,n) = 3n + 1 $$ $$ f(2,n) = frac{9}{2}n^2 - frac{3}{2}n + 1 $$ $$ f(3,n) = frac{27}{6}n^3 - 9n^2 + 15n + 1 $$ $$ f(4,n) = frac{27}{8}n^4 - frac{63}{4}n^3 + frac{225}{8}n^2 - frac{51}{4}n + 1 $$ I do not intend to apply such equation into my program (I am using Python 3 by the way). I just only wanted to provide mathematical proof that a list of unique string variants generated by the program is correct.
$endgroup$
– Vic Brown
Dec 31 '18 at 5:36
|
show 3 more comments
$begingroup$
Thanks. Yes, I only intend to use $1 leq r < 4$ since the substituents only composed of four characters. I am just curious whether the formula $1+sum_{k=1}^r 3^kbinom{n}{k}$ could be simplified to elementary function so that it could be used for n let's say 10,000 and r at most equals to n. Sum it up for such n and r would be cumbersome.
$endgroup$
– Vic Brown
Dec 30 '18 at 5:35
$begingroup$
@VicBrown : So it can't be simplified to an elementary function. Perhaps it can be approximated with something elementary. Would an approximation (and if so, how precise and accurate would you require) suffice?
$endgroup$
– Eric Towers
Dec 30 '18 at 18:25
$begingroup$
@VicBrown : Officially, answers to questions on this site are evaluated (by the crowds) as answers to the Question as asked. Your Question does not include the constraints $1 leq r leq 4$ and $r leq n$, which I infer from your referenced question. Since those are not part of the current question, they cannot be assumed in an Answer.
$endgroup$
– Eric Towers
Dec 30 '18 at 22:57
$begingroup$
@VicBrown : As the extension to my question shows, for $n = 10,000$, $f(r,n)$ quickly exceeds usual integral representations in some programming languages. If you intend to compute these with software, it would be helpful to know what your targetted software is.
$endgroup$
– Eric Towers
Dec 30 '18 at 23:16
$begingroup$
Your solution above and it is similar to what I solve using polynomial equation for r = 1 to 4 and n = 3 to 10, where: $$ f(1,n) = 3n + 1 $$ $$ f(2,n) = frac{9}{2}n^2 - frac{3}{2}n + 1 $$ $$ f(3,n) = frac{27}{6}n^3 - 9n^2 + 15n + 1 $$ $$ f(4,n) = frac{27}{8}n^4 - frac{63}{4}n^3 + frac{225}{8}n^2 - frac{51}{4}n + 1 $$ I do not intend to apply such equation into my program (I am using Python 3 by the way). I just only wanted to provide mathematical proof that a list of unique string variants generated by the program is correct.
$endgroup$
– Vic Brown
Dec 31 '18 at 5:36
$begingroup$
Thanks. Yes, I only intend to use $1 leq r < 4$ since the substituents only composed of four characters. I am just curious whether the formula $1+sum_{k=1}^r 3^kbinom{n}{k}$ could be simplified to elementary function so that it could be used for n let's say 10,000 and r at most equals to n. Sum it up for such n and r would be cumbersome.
$endgroup$
– Vic Brown
Dec 30 '18 at 5:35
$begingroup$
Thanks. Yes, I only intend to use $1 leq r < 4$ since the substituents only composed of four characters. I am just curious whether the formula $1+sum_{k=1}^r 3^kbinom{n}{k}$ could be simplified to elementary function so that it could be used for n let's say 10,000 and r at most equals to n. Sum it up for such n and r would be cumbersome.
$endgroup$
– Vic Brown
Dec 30 '18 at 5:35
$begingroup$
@VicBrown : So it can't be simplified to an elementary function. Perhaps it can be approximated with something elementary. Would an approximation (and if so, how precise and accurate would you require) suffice?
$endgroup$
– Eric Towers
Dec 30 '18 at 18:25
$begingroup$
@VicBrown : So it can't be simplified to an elementary function. Perhaps it can be approximated with something elementary. Would an approximation (and if so, how precise and accurate would you require) suffice?
$endgroup$
– Eric Towers
Dec 30 '18 at 18:25
$begingroup$
@VicBrown : Officially, answers to questions on this site are evaluated (by the crowds) as answers to the Question as asked. Your Question does not include the constraints $1 leq r leq 4$ and $r leq n$, which I infer from your referenced question. Since those are not part of the current question, they cannot be assumed in an Answer.
$endgroup$
– Eric Towers
Dec 30 '18 at 22:57
$begingroup$
@VicBrown : Officially, answers to questions on this site are evaluated (by the crowds) as answers to the Question as asked. Your Question does not include the constraints $1 leq r leq 4$ and $r leq n$, which I infer from your referenced question. Since those are not part of the current question, they cannot be assumed in an Answer.
$endgroup$
– Eric Towers
Dec 30 '18 at 22:57
$begingroup$
@VicBrown : As the extension to my question shows, for $n = 10,000$, $f(r,n)$ quickly exceeds usual integral representations in some programming languages. If you intend to compute these with software, it would be helpful to know what your targetted software is.
$endgroup$
– Eric Towers
Dec 30 '18 at 23:16
$begingroup$
@VicBrown : As the extension to my question shows, for $n = 10,000$, $f(r,n)$ quickly exceeds usual integral representations in some programming languages. If you intend to compute these with software, it would be helpful to know what your targetted software is.
$endgroup$
– Eric Towers
Dec 30 '18 at 23:16
$begingroup$
Your solution above and it is similar to what I solve using polynomial equation for r = 1 to 4 and n = 3 to 10, where: $$ f(1,n) = 3n + 1 $$ $$ f(2,n) = frac{9}{2}n^2 - frac{3}{2}n + 1 $$ $$ f(3,n) = frac{27}{6}n^3 - 9n^2 + 15n + 1 $$ $$ f(4,n) = frac{27}{8}n^4 - frac{63}{4}n^3 + frac{225}{8}n^2 - frac{51}{4}n + 1 $$ I do not intend to apply such equation into my program (I am using Python 3 by the way). I just only wanted to provide mathematical proof that a list of unique string variants generated by the program is correct.
$endgroup$
– Vic Brown
Dec 31 '18 at 5:36
$begingroup$
Your solution above and it is similar to what I solve using polynomial equation for r = 1 to 4 and n = 3 to 10, where: $$ f(1,n) = 3n + 1 $$ $$ f(2,n) = frac{9}{2}n^2 - frac{3}{2}n + 1 $$ $$ f(3,n) = frac{27}{6}n^3 - 9n^2 + 15n + 1 $$ $$ f(4,n) = frac{27}{8}n^4 - frac{63}{4}n^3 + frac{225}{8}n^2 - frac{51}{4}n + 1 $$ I do not intend to apply such equation into my program (I am using Python 3 by the way). I just only wanted to provide mathematical proof that a list of unique string variants generated by the program is correct.
$endgroup$
– Vic Brown
Dec 31 '18 at 5:36
|
show 3 more comments
$begingroup$
In case you are interested in asymptotics:
$$begin{align}
s(n,r)&=sum_{k=1}^r 3^kbinom{n}{k}\
&=2^nsum_{k=1}^r 3^kfrac{binom{n}{k}}{2^n}\
&approx frac{2^n}{sqrt{pi n /2}} int_0^r 3^x expleft( -frac{2}{n}(x-n/2)^2 right)
dx \
end{align}$$
If $r > 0.78 n$ we can apply Laplace's method and get the first order approximation:
$$ frac{log (s(n,r))}{n} to log(2) + frac{log^2(3)+ 4 log 3}{8}approx 1.393$$
For smaller $r$ , a similar approximation can be obtained (tell me if you are interested) but it involves both $(n,r)$ variables.
$endgroup$
add a comment |
$begingroup$
In case you are interested in asymptotics:
$$begin{align}
s(n,r)&=sum_{k=1}^r 3^kbinom{n}{k}\
&=2^nsum_{k=1}^r 3^kfrac{binom{n}{k}}{2^n}\
&approx frac{2^n}{sqrt{pi n /2}} int_0^r 3^x expleft( -frac{2}{n}(x-n/2)^2 right)
dx \
end{align}$$
If $r > 0.78 n$ we can apply Laplace's method and get the first order approximation:
$$ frac{log (s(n,r))}{n} to log(2) + frac{log^2(3)+ 4 log 3}{8}approx 1.393$$
For smaller $r$ , a similar approximation can be obtained (tell me if you are interested) but it involves both $(n,r)$ variables.
$endgroup$
add a comment |
$begingroup$
In case you are interested in asymptotics:
$$begin{align}
s(n,r)&=sum_{k=1}^r 3^kbinom{n}{k}\
&=2^nsum_{k=1}^r 3^kfrac{binom{n}{k}}{2^n}\
&approx frac{2^n}{sqrt{pi n /2}} int_0^r 3^x expleft( -frac{2}{n}(x-n/2)^2 right)
dx \
end{align}$$
If $r > 0.78 n$ we can apply Laplace's method and get the first order approximation:
$$ frac{log (s(n,r))}{n} to log(2) + frac{log^2(3)+ 4 log 3}{8}approx 1.393$$
For smaller $r$ , a similar approximation can be obtained (tell me if you are interested) but it involves both $(n,r)$ variables.
$endgroup$
In case you are interested in asymptotics:
$$begin{align}
s(n,r)&=sum_{k=1}^r 3^kbinom{n}{k}\
&=2^nsum_{k=1}^r 3^kfrac{binom{n}{k}}{2^n}\
&approx frac{2^n}{sqrt{pi n /2}} int_0^r 3^x expleft( -frac{2}{n}(x-n/2)^2 right)
dx \
end{align}$$
If $r > 0.78 n$ we can apply Laplace's method and get the first order approximation:
$$ frac{log (s(n,r))}{n} to log(2) + frac{log^2(3)+ 4 log 3}{8}approx 1.393$$
For smaller $r$ , a similar approximation can be obtained (tell me if you are interested) but it involves both $(n,r)$ variables.
edited Jan 3 at 14:44
answered Jan 2 at 1:39
leonbloyleonbloy
41.6k647108
41.6k647108
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.
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%2f3054644%2fhow-to-solve-1-sum-k-1r-3k-binomnk-using-say-s-n-fraca-1%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
$begingroup$
I've edited the $LaTeX$. Did you mean $S{ n}$ or something else?
$endgroup$
– Shaun
Dec 28 '18 at 7:21
$begingroup$
What is an example of a large $r$? Are $n$ and $r$ integers? positive?
$endgroup$
– Eric Towers
Dec 28 '18 at 7:27