5
$\begingroup$

I want to compute asymptotic approximations to partial sum of harmonic series in Mathematica, using Euler-Maclaurin summation formula.

f[x_] := 1/x

em[n_] := Integrate[f[x], {x, 1, n}]
   + (f[1] + f[n])/2
   + Sum[BernoulliB[2k]/(2k)! ((D[ f[x], {x, 2 k - 1}] /. x -> n)
   - D[f[x], {x, 2 k - 1}] /. x -> 1), {k, 1, Infinity}]

em[k] // FullSimplify

enter image description here

FullSimplify does not work..

How to simplify this expression? Where is a $\gamma$?

I try it in Maple:

enter image description here

How to do something like this in Mathematica?

$\endgroup$
1
  • 1
    $\begingroup$ I think the missing $\gamma$ comes from the 'remainder' term of the Euler-Maclaurin formula. $\endgroup$
    – QuantumDot
    Feb 3, 2016 at 21:38

2 Answers 2

6
$\begingroup$

I would suggest adding option GenerateConditions->False to Integrate to speed up the integration. Then, instead of D, use Derivative. Then, to generate a SeriesData apply Series:

f[x_] := 1/x;
max = 4;

em[n_Symbol] := 
 Series[Integrate[f[x], {x, 1, n}, 
  GenerateConditions -> False] + (f[1] + f[n])/2 + 
  Sum[BernoulliB[2 k]/(2 k)! (Derivative[2 k - 1][f][n] - 
    Derivative[2 k - 1][f][1]), {k, 1, max+3}], {n, Infinity, max}]

Then

em[n]

enter image description here

Note: if you do em[k], you get conflict of local variables.

$\endgroup$
3
  • $\begingroup$ I get 2897/5040 for max=1, but for max=4 (in example) I get 51621/80080 $\endgroup$ Feb 4, 2016 at 10:13
  • 2
    $\begingroup$ In addition, for max=10 I get 8268803161823011/160626866400, these terms does not converge to (correct) EulerGamma. This program need a correction. $\endgroup$ Feb 4, 2016 at 10:20
  • 1
    $\begingroup$ Had you a chance to fix this interesting piece of code ? $\endgroup$ Sep 1, 2017 at 4:48
2
$\begingroup$

According to AsymptoticSum,

In[1]:= AsymptoticSum[1/k, {k, 1, n}, n \[Rule] Infinity, SeriesTermGoal \[Rule] 7]

                       1        1        1      1
Out[1]= EulerGamma - ------ + ------ - ----- + --- + Log[n]
                          6        4       2   2 n
                     252 n    120 n    12 n

Alternatively,

In[2]:= Series[Unevaluated[Sum[1/k, {k, 1, n}]], {n, Infinity, 7}]

                                 1      1       1        1          -8
Out[2]= (EulerGamma + Log[n]) + --- - ----- + ------ - ------ + O[n]
                                2 n       2        4        6
                                      12 n    120 n    252 n

Both of them give the same result as Maple's eulermac(1/k, k = 1 .. n, 5);.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.