# Series expansion from the red book on special functions by Richard Askey

I want to check my calculations via mathematica.

In the book I am reading there's this expansion: $$\frac{(1+\frac{1}{j})^x}{1+x/j}=1+\frac{x(x-1)}{2j^2}+\mathcal{O}(1/j^3)$$

though I get instead of the term $$\frac{x(x-1)}{2j^2}$$ in the rhs the term: $$-\frac{x(x+1)}{2j^2}$$.

So I want to check by mathematica if my calculations are correct, how do you suggest me to implement it in mathematica?

Thanks!

• Series[(1 + 1/j)^x/(1 + x/j), {j, Infinity, 2}] results in $$1+\frac{(x-1) x}{2 j^2}+O\left(\left(\frac{1}{j}\right)^3\right) .$$ Mar 19, 2021 at 10:40
• Does this answer your question? How to "prepare" expression for Taylor expansion IMO this method is better to use as it is fully self-contained and does not run the risk of any unforeseen errors occurring from the use of ReplaceAll to perform substitutions, but YMMV. Mar 19, 2021 at 11:36

One way to do it is to use the Series functionality: Series[f[z], {z, c, n}] expands f[z] in z around c to order n. Here we want to expand in 1/j, so we'll make a new variable jinv ($$j$$-inverse) to represent 1/j, and write our function in terms of that. We then want to expand around jinv = 0 to order 2.

So, we get

Series[(1 + jinv)^x/(1 + x jinv), {jinv, 0, 2}]


which returns

1  +  1/2 (-1+x) x jinv^2  +  O[jinv]^3


So, unfortunately(?), it looks like the book is right.

This is how I think of expanding around a “composite variable” like $$1/j$$, but as @user64494 points out, you can also expand around $$j$$ directly in this case, by expanding around $$j=\infty$$!

Series[(1 + 1/j)^x/(1 + x/j), {j, Infinity, 2}]


which gives the same answer under interpreting jinv as 1/j.

To see why, you could possibly use Wolfram Alpha's step-by-step solution from within Mathematica!

WolframAlpha["D[(1 + w)^x/(1 + x w), {w, 2}]", IncludePods -> "Input",
AppearanceElements -> {"Pods"}, PodStates -> {"Input__Show steps"}]


(Here w = jinv, and we'd be substituting w = 0 at the end to get 1/2 (-1+x) x.)

• Ok, I think I see where I've gone wrong.
– Alan
Mar 19, 2021 at 10:01
• wait a minute, if you plug in $w=0$ you get zero. I just plugged the script your wrote (the one last of code), and we get:$\frac{w (x-1) x (w+1)^{x-1}}{(w x+1)^2}$, which when we plug $w=0$ vanishes, am I wrong here?
– Alan
Mar 19, 2021 at 10:14
• Ah, sorry, should have been the second derivative! Mar 19, 2021 at 10:16
• The coefficient of $1/j$ is, in fact, 0, so that's consistent with the book. Fixing the answer now... Mar 19, 2021 at 10:17
• thorimur, it might be helpful if you update your answer to show the full breadth of functionality that the Series framework offers. I.e. to show that direct expansion over 1/j as j -> 0 is possible. See the comment of @user64494 on the question itself. Mar 19, 2021 at 11:34
Series[(1 + 1/j)^x/(1 + x/j), {j, Infinity, 2}]


$$1+\frac{(x-1) x}{2 j^2}+O\left(\left(\frac{1}{j}\right)^3\right) .$$