# Plotting Asymptotic Series

I apologise for being always here asking for the same questions, but I need to learn.

I have to plot this series

$$\frac{\pi}{2} - \frac{\cos x}{x}\left(\sum_{k = 0}^{+\infty} (-1)^k \frac{(2k)!}{x^{2k}}\right) - \frac{\sin x}{x}\left(\sum_{k = 0}^{+\infty} (-1)^k \frac{(2k+1)!}{x^{2k+1}}\right)$$

Hence I tried this with Mathematica:

f[k_, x_] := (-1)^k*((2*k)!)/(x^(2*k))
g[k_, x_] := (-1)^k*((2*k + 1)!)/(x^(2*k + 1))
s[x_] := (Cos[x]/x)*Sum[f[k, x], {k, 0, Infinity}]
t[x_] := (Sin[x]/x)*Sum[g[k, x], {k, 0, Infinity}]
u[x_] := Pi/2 + s[x] + t[x]
Plot[u[x], {x, 1, 2}, PlotRange -> Full]


But (obviously) it tells me the series don't converge. And it's ok, I know it. I knew the problema bout the infinity, so I tried with $10^4$, instead of infinity, and it took forever.

I tried with 100 and littler numbers and it was ok, except the fact that I am not sure if I gave the right and correct commands for that series.

Are there some mistakes?

• Don't you have some sign errors in your definition of u[x_]? – David G. Stork Nov 8 '16 at 0:50
• @DavidG.Stork uhh lol, that is actually true :D it's 2:02 am here so I'll sleep. Tomorrow I'll try again with the correct signs, thanks!! – Henry Nov 8 '16 at 1:03