# How to do this series expansion with Mathematica

Consider for large integers $$n$$ the expression $$\sin \left(\pi \sqrt{4 n^2+n}\right)$$.

Since

$$\sqrt{4 n^2+n}=2 n \sqrt{1 + \frac{1}{4 n}}$$

we can use the standard series for the square root and next the standard series for $$sin$$ to find a series expansion of this expression around $$\infty$$. That is a simple first year exercise.

I was unable to do this computation in an elegant way with Mathematica. I expected the following to work:

Series[Sin[Sqrt[n+4 n^2] π], {n,∞,3}, Assumptions->{n ∈ Integers}]


$$\sin \left(2 \pi n+\frac{\pi }{4}-\frac{\pi }{64 n}+\frac{\pi }{512 n^2}-\frac{5 \pi }{16384 n^3}+O\left(\left(\frac{1}{n}\right)^4\right)\right)$$

To my surprise, the expansion is only inside Sin and the fact that n is an integer is not used.

I tried to use Normal and TrigExpand without success. Finally I found a rather dirty trick to obtain the result I was looking for:

Series[Sin[Sqrt[n + 4 n^2] π], {n, ∞, 3}]  /.  Sin[x_] :> Sin[x - 2 π n]


$$\frac{1}{\sqrt{2}}-\frac{\pi }{64 \sqrt{2} n}+\frac{\frac{\pi }{512 \sqrt{2}}-\frac{\pi ^2}{8192 \sqrt{2}}}{n^2}+\frac{-\frac{5 \pi }{16384 \sqrt{2}}+\frac{\pi ^2}{32768 \sqrt{2}}+\frac{\pi ^3}{1572864 \sqrt{2}}}{n^3}+O\left(\left(\frac{1}{n}\right)^4\right)$$

Can this result be found in a more straightforward way?

Edit

Let us reconsider

Series[Sin[Sqrt[n + 4 n^2] π], {n, ∞, 3}, Assumptions -> {n ∈ Integers}]


$$\sin \left(2 \pi n+\frac{\pi }{4}-\frac{\pi }{64 n}+\frac{\pi }{512 n^2}-\frac{5 \pi }{16384 n^3}+O\left(\left(\frac{1}{n}\right)^4\right)\right)$$

Henric Schumacher is quite right in his assumption that we do not find a series expansion, but only a series expansion wrapped in Sin, because Sin has an essential singularity at Infinity. The documentation of Series, under Possible Issues, shows something similar. So this should not have surprised me.

The assumption that nis an integer has not prevented the appearance of the term 2πn in the argument of Sin. Without that term, the result would immediately further evaluate to the result we are looking for. So we have to get rid of this term.

The argument of Sin is a SeriesData expression, which is atomic. Therefore, the substitution 2πn->0 does not work. But assignment is possible:

sd=Series[Sin[Sqrt[n+4 n^2] π],{n,∞,3}];
sd[[1,3,1]]=0;
sd


$$\frac{1}{\sqrt{2}}-\frac{\pi }{64 \sqrt{2} n}+\frac{\frac{\pi }{512 \sqrt{2}}-\frac{\pi ^2}{8192 \sqrt{2}}}{n^2}+\frac{-\frac{5 \pi }{16384 \sqrt{2}}+\frac{\pi ^2}{32768 \sqrt{2}}+\frac{\pi ^3}{1572864 \sqrt{2}}}{n^3}+O\left(\left(\frac{1}{n}\right)^4\right)$$

Another way of getting rid of the term 2πn is to use Normal and FullSimplify with the assumption that n is an integer, as done in the answer of Mikado. After that, we need another call of Series to arrive at the desired result.

To summarize: at the moment, it seems that there is no straightforward way for finding this series expansion by Mathematica, while it is easily found with pen and paper.

• Maybe the reason is that there are infinitely many summands in the Laurant series expansion of Sin at Infinity? Exactly as Exp, Sin has an essential singularity at Infinity. Things like SeriesCoefficient[Sin[x], {x, Infinity, -5}] work fine. – Henrik Schumacher Aug 31 '18 at 19:37
• @Henrik: please see the edit. – Fred Simons Sep 1 '18 at 8:02
• Could use Series twice, with Normal and Refine in the middle to handle the n integrality. In:= Series[ Refine[Normal[ Series[Sin[Sqrt[n + 4 n^2] \[Pi]], {n, \[Infinity], 3}]], Assumptions -> {n \[Element] Integers}], {n, \[Infinity], 3}] Out= SeriesData[n, DirectedInfinity, { 2^Rational[-1, 2], Rational[-1, 64] 2^Rational[-1, 2] Pi, Rational[1, 512] 2^Rational[-1, 2] Pi + Rational[-1, 8192] 2^Rational[-1, 2] Pi^2, Rational[1, 3145728] ((-480) 2^Rational[1, 2] Pi + 48 2^Rational[1, 2] Pi^2 + 2^Rational[ 1, 2] Pi^3)}, 0, 4, 1] – Daniel Lichtblau Sep 1 '18 at 18:05
• Oops, I missed the substantially similar response by @Mikado. (I thought I had made the same comment yesterday but I guess I never submitted it.) – Daniel Lichtblau Sep 1 '18 at 18:08

The following gives the same result, but with less explicit fiddling

Assuming[n ∈ Integers,
Series[FullSimplify[Normal[Series[
Sin[Sqrt[n + 4 n^2] π], {n, ∞,3}]]], {n, ∞, 3}]]

• Very nice, thanks. I tried Simplify, but that did not work. See also the edit. – Fred Simons Sep 1 '18 at 8:03

Similar to my answer to this question, we can split the argument of Sin into a finite part and an infinite part and then use the identity: $$\sin (x+y)=\sin (x) \cos (y)+\cos (x) \sin (y)$$

Here is some code to obtain the finite and infinite parts of a series.

infinitePart[s:HoldPattern @ SeriesData[x_, x0_, _, _, _, inc_]] := Normal[
s + SeriesData[x, x0, {}, 0, 0, inc]
]
finitePart[s_SeriesData] := s - infinitePart[s]


Making use of the identity:

s = ReplaceAll[
Series[Sin[Sqrt[n + 4 n^2] π], {n, ∞, 3}],
Sin[s_SeriesData] :> With[{i = infinitePart[s], f = finitePart[s]},
Sin[i] Cos[f] + Cos[i] Sin[f]
]
];
s //TeXForm


$$\left(\frac{1}{\sqrt{2}}+\frac{\pi }{64 \sqrt{2} n}+\frac{-\frac{\pi }{512 \sqrt{2}}-\frac{\pi ^2}{8192 \sqrt{2}}}{n^2}+\frac{\frac{5 \pi }{16384 \sqrt{2}}+\frac{\pi ^2}{32768 \sqrt{2}}-\frac{\pi ^3}{1572864 \sqrt{2}}}{n^3}+O\left(\left(\frac{1}{n}\right)^4\right)\right) \sin (2 \pi n)+\left(\frac{1}{\sqrt{2}}-\frac{\pi }{64 \sqrt{2} n}+\frac{\frac{\pi }{512 \sqrt{2}}-\frac{\pi ^2}{8192 \sqrt{2}}}{n^2}+\frac{-\frac{5 \pi }{16384 \sqrt{2}}+\frac{\pi ^2}{32768 \sqrt{2}}+\frac{\pi ^3}{1572864 \sqrt{2}}}{n^3}+O\left(\left(\frac{1}{n}\right)^4\right)\right) \cos (2 \pi n)$$

Now, we can simplify the series assuming that n is an integer:

Simplify[s, n ∈ Integers] //TeXForm


$$\frac{1}{\sqrt{2}}-\frac{\pi }{64 \sqrt{2} n}-\frac{(\pi -16) \pi }{8192 \sqrt{2} n^2}+\frac{\pi \left(-480+48 \pi +\pi ^2\right)}{1572864 \sqrt{2} n^3}+O\left(\left(\frac{1}{n}\right)^4\right)$$