# Applying the binomial theorem with an arbitrary exponent

I was asked a question by a student today. The solution I came up with seemed a bit suspicious, so I tried to verify it using Mathematica and failed. I created a PDF of my solution which can be found here. The problem:

Consider $\left(ax+\frac{1}{x^k}\right)^n$, where $k,n\in\mathbb{N}$. Generalize an expression for the constant term with respect to $x$.

Analytically, I know that if $c$ is the constant term then

$$c=\begin{cases}{n\choose nk/(k+1)}a^{nk/(k+1)}& \text{if k+1 divides n}\\0&\text{otherwise}\end{cases}$$

but cannot get Mathematica to confirm this generally. I've been playing with Refine with no progress. I guess I'm asking can Mathematica apply the binomial theorem for a general $n$, giving the answer in $\Sigma$ notation? Then I can use Coefficient[f[n,k],x,0] to get a general expression for the constant term.

I am not sure what you are looking for here exactly; your PDF proof is convincing, and the result can be checked up to arbitrarily large $n$ depending on how much time and computing power you have (notice that you left out of this question the limitation on the value of $k$ that you have in your original problem, i.e. $1 \le k \le 9$).

For instance, the following empirically checks your result for $n$ up to $20$ and for all admissible $k$ values; the last check returns True everywhere:

Table[
{n, k, Sum[Binomial[n, i] (a x)^(n - i) (1/x^k)^i, {i, 0, n}]},
{n, 20}, {k, 9}
];
DeleteCases[Flatten[Coefficient[%, x, 0], 1], {_, _, 0}];
Binomial[#1, #2 #1/(#2 + 1)] a^(#2 #1/(#2 + 1)) == #3 & @@@ %


Otherwise, I am not convinced that you can get Mathematica to draw such a non-trivial conclusion for you automatically, unless you nudge it forth in the right direction at every step of the way.

As an aside, you asked whether Mathematica can apply the binomial theorem for a general $n$, giving the answer in Σ notation. It turns out that Mathematica will not "unpack" a binomial by applying the binomial theorem, but it is nevertheless aware of it, as it will do the exact opposite:

Sum[Binomial[n, i] (a x)^(n - i) (1/x^k)^i, {i, 0, n}]

(* Out: (a x + x^-k)^n *)

• I am sure of the solution from the PDF. I was just seeing if Mathematica could also produce it. Based on what you said, it seems it can't without perhaps some more advanced techniques. – Gerald Dec 6 '16 at 5:55