I am having difficulties with Euler Maclaurin summation. Lets use the next example to illustrate the issue. We pretend to calculate $S( {1 \over 2})$ as follows
$$ S\big({1 \over 2}\big) = \sum\limits_{n=1}^{2}{\frac{1}{n^{\frac{1}{2}}}}$$
Obviously the value is:
$$ S\big({1 \over 2}\big) = 1 + \frac{1}{\sqrt{2}} \approx 1.7071067$$
My understanding is the formula -is exact- and can be written as:
${\displaystyle \sum _{i=m}^{n}f(i)=\int _{m}^{n}f(x)\,dx+{\frac {f(n)+f(m)}{2}}+\sum _{k=1}^{\lfloor p/2\rfloor }{\frac {B_{2k}}{(2k)!}}(f^{(2k-1)}(n)-f^{(2k-1)}(m))+R_{p}}$
For example can as stated here.
Where
${\displaystyle R_{p}=(-1)^{p+1}\int _{m}^{n}f^{(p)}(x){P_{p}(x) \over p!}\,dx.}$
So if we apply the former expression taking $p=2$ I get:
$1.59099$.
I am using PARI/GP with the next function:
maclaurin(s,a,b)= b^(1-s)/(1-s)- a^(1-s)/(1-s)+ 1/2*(b^(-s) +a^(-s) ) + bernreal(2)/2!*( (-s)*( b^(-s-1) - a^(-s-1) )) + (-1)^(2+1)* intnum(x=a,b, (-s)*(-s-1)*x^(-s-2)/2*(x^2 - x + 1/6))
As follows:
maclaurin(0.5,1,2)=1.5909902576697319299018998147359103384
What I am doing wrong? Why I am not getting an exact result?
As written in the Wiki text, you must use the periodic Bernoulli polynomials $P_p(x)=B_p(x-\lfloor x\rfloor)=B_p(\{x\})$ not the standard polynomials in the integral for the remainder term. If you insert this in your Pari function, e.g.
ml(s,a,b)= b^(1-s)/(1-s)- a^(1-s)/(1-s)+ 1/2*(b^(-s) +a^(-s) ) + bernreal(2)/2!*( (-s)*( b^(-s-1) - a^(-s-1) )) + (-1)^(2+1)* intnum(x=a,b, (-s)*(-s-1)*x^(-s-2)/2*(frac(x)^2 - frac(x) + 1/6))you get