Let's assume that $g(x)$ is given and we try to find out $f(n)$
$$
f(n)=\sum_{i=1}^n g(i)
$$
$$
f(n+1)=\sum_{i=1}^{n+1}g(i)
$$
$$
f(n+1)-f(n)=g(n+1)
\tag 1$$
We know Taylor expansion
$$
f(x+h)=f(x)+hf'(x)+\frac{h^2 f''(x)}{2!}+\frac{h^3f'''(x)}{3!}+....
$$
Thus
$$
f(n+1)=f(n)+f'(n)+\frac{f''(n)}{2!}+\frac{f'''(n)}{3!}+....
$$
If we put $f(n+1)$ taylor expansion in Equation $1$
$$f(n+1)-f(n)=g(n+1)$$
$$
f(n)+f'(n)+\frac{f''(n)}{2!}+\frac{f'''(n)}{3!}+....-f(n)=g(n+1)
$$
$$
f'(n)+\frac{f''(n)}{2!}+\frac{f'''(n)}{3!}+...=g(n+1)
\tag 2$$
$$
f(n)+\frac{f'(n)}{2!}+\frac{f''(n)}{3!}+\frac{f'''(n)}{4!}+...=\int g(n+1) dn
$$
We need $f(n)$ if so we need to cancel $f'(n)$ . So we need to
$$
-\frac{1}{2} ( f'(n)+\frac{f''(n)}{2!}+\frac{f'''(n)}{3!}+...)=-\frac{1}{2}g(n+1)
$$
$$
f(n)+ (-\frac{1}{2.2} +\frac{1}{3!})f''(n)+(-\frac{1}{2.3!} +\frac{1}{4!})f'''(n)+...=\int g(n+1) dn-\frac{1}{2}g(n+1)
$$
$$
f''(n)+\frac{f'''(n)}{2!}+\frac{f^{4}(n)}{3!}+...=\frac{d(g(n+1))}{dn}
$$
If you continue in that way to cancel $f^{r}(n)$ terms step by step, you will get
$$
f(n)=\int g(n+1) dn-\frac{1}{2}g(n+1)+\frac{1}{12}\frac{d(g(n+1))}{dn}+a_4\frac{d^2(g(n+1))}{dn^2}+a_5\frac{d^3(g(n+1))}{dn^3}+...
$$
This is Euler-Maclaurin formula. (Please see also the Applications of the Bernoulli numbers). I just wanted to show Bernoulli numbers seen in one of the very important formulas in mathematics .
Where $$a_n= \frac{B_n}{n!}$$.
Because If you try to find out the coefficients of $\frac{t}{e^t-1}$ by polynomial division. You can get exactly same coefficients that seen in Euler-Maclaurin formula.
The Bernoulli numbers appear in Jacob Bernoulli's most original work "Ars Conjectandi" published in Basel in 1713 in a discussion of the exponential series.
You can also see that The Bernoulli numbers appears in the power series of $tan(x)$.
https://en.wikipedia.org/wiki/Taylor_series
(Check the List of Maclaurin series of some common functions)
Proof:
$$\frac{t}{e^t-1}=\frac{t}{t+\frac{t^2}{2!}+\frac{t^3}{3!}+\frac{t^4}{4!}+...}=1+\frac{(1-1)t-\frac{t^2}{2!}-\frac{t^3}{3!}-\frac{t^4}{4!}-...}{t+\frac{t^2}{2!}+\frac{t^3}{3!}+\frac{t^4}{4!}+...}=1-\frac{+\frac{t^2}{2!}+\frac{t^3}{3!}+\frac{t^4}{4!}+...}{t+\frac{t^2}{2!}+\frac{t^3}{3!}+\frac{t^4}{4!}+...}$$
$$\frac{t}{e^t-1}=1-\frac{t}{2}+\frac{+(\frac{1}{2}-\frac{1}{2!})t^2+(\frac{1}{2.2!}-\frac{1}{3!})t^3+(\frac{1}{2.3!}-\frac{1}{4!})t^4+...}{t+\frac{t^2}{2!}+\frac{t^3}{3!}+\frac{t^4}{4!}+...}=1-\frac{t}{2}+\frac{(\frac{1}{2.2!}-\frac{1}{3!})t^3+(\frac{1}{2.3!}-\frac{t^4}{4!})t^4+...}{t+\frac{t^2}{2!}+\frac{t^3}{3!}+\frac{t^4}{4!}+...}$$
$$\frac{t}{e^t-1}=1-\frac{1}{2}t+\frac{\frac{1}{12}t^3+\frac{1}{24}t^4+...}{t+\frac{t^2}{2!}+\frac{t^3}{3!}+\frac{t^4}{4!}+...}=1-\frac{1}{2}t+\frac{1}{12}t^2+\frac{(\frac{1}{24}-\frac{1}{2.12})t^4+...}{t+\frac{t^2}{2!}+\frac{t^3}{3!}+\frac{t^4}{4!}+...}$$
First of all, using the Taylor series for $e^z$ we have
$$
\frac{e^z-1}{z} = 1 + \frac{z}{2} + \frac{z^2}{6} + \frac{z^3}{24} + \cdots.
$$
Multiplying this by the power series for $z/(e^z-1)$ and comparing coefficients (the product should be $1$) we get
$$
\begin{align*}
1 &= B_0 \\
0 &= B_1 + 1/2 \\
0 &= (2B_2) + (1/2) B_1 + (1/6) B_0 \\
0 &= (6B_3) + (1/2) (2B_2) + (1/6) B_1 + (1/24) B_0
\end{align*}
$$
and so on. Therefore $B_0 = 1$, $B_1 = -1/2$, $B_2 = 1/6$, $B_3 = -1/30$, and so on.
If you look at the function
$$ f(z) = \frac{z}{e^z-1} + \frac{z}{2} $$
then you find out that
$$
\begin{align*}
f(-z) = \frac{-z}{e^{-z}-1} - \frac{z}{2} =
\frac{ze^z}{e^z-1} - \frac{z}{2} =
\frac{z}{e^z-1} + z - \frac{z}{2} = f(z).
\end{align*}
$$
Therefore $f(z)$ is even and all the odd coefficients in its power series vanish. This shows that apart from $B_1 = -1/2$, all other odd-indexed Bernoulli numbers vanish. Why do we need them, then? They're just the sequence whose exponential generating series is $z/(e^z-1)$.
Best Answer
If you start with $f(z):=\frac{z}{e^z-1}=\sum_{n=0}^\infty B_n\frac{z^n}{n!}$, consider what $f(z)+f(-z)$ is. You'll get a sum of only even bernoulli numbers. Now notice that
$f(z)+f(-z)=\frac{z(e^{t/2}+e^{-t/2})}{(e^{t/2}-e^{-t/2})}$
which you can reverse engineer to verify (multiply by the right ratio which equuals 1). This essentially gives you an expansion for $\cot(z)$ in terms of the even Bernoulli numbers. However you want $\csc(z)$. This is amenable by recalling that
$\cot(z)-\cot(2z)=\csc(2z)$
So subtract the power series to get your result.
The correct answer is:
$$\csc(z)=\sum_{n=0}^\infty \frac{(-1)^{n+1}2(2^{2n-1}-1)B_{2n}}{(2n)!}z^{2n-1}$$