# Can Mathematica return the first few terms of a sequence given the first few terms of a Dirichlet Generating Function?

For example:

a = Sum[1/n^s, {n, 1, 6}];
Expand[a^2]


returns a big mess. I want to see something like:

$$1/1^s + 2/2^s + 2/3^s + 3/4^s + 2/5^s + 4/6^s + \cdots + 1/36^s$$

• I think in what you say you want has some typos, e.g., a transposed s^2 instead of 2^s etc. – Michael E2 Feb 1 '15 at 21:02
• Yes, thank you Micahael you are correct. I fixed the errors. – Geoffrey Critzer Feb 1 '15 at 23:40

Unfortunately, Mathematica's capabilities for manipulating Dirichlet series are not very extensive at the moment. In particular, there isn't anything built-in that does the inverse of DirichletTransform[]. (This MO question is apropos.)

Here is a workaround. It seems you're trying to generate the coefficients for $\zeta(s)^2$. Recall that $\zeta(s)$ is the DGF for the constant function $1$. Thus, to generate the coefficients for $\zeta(s)^2$, perform a Dirichlet auto-convolution (i.e. convolve with itself), and then generate the corresponding Dirichlet series from that. It might go like this:

zs[k_] = DirichletConvolve[1, 1, n, k]
DivisorSigma[0, k]

DirichletTransform[zs[k], k, s]
Zeta[s]^2

Table[zs[k], {k, 5}]
{1, 2, 2, 3, 2}


Explicitly displaying the terms of the Dirichlet series will require some finesse, however:

Row[Riffle[Table[FractionBox[DirichletConvolve[1, 1, n, k],
SuperscriptBox[k, s]] // DisplayForm, {k, 5}], "+"]]


$\dfrac1{1^s}+\dfrac2{2^s}+\dfrac2{3^s}+\dfrac3{4^s}+\dfrac2{5^s}$

Not sure if this is what you want.

a = Sum[1/n^s, {n, 1, 6}];

a2 = (a /. Power[n_, Times[-1, s]] :> t[n])^2 // Expand;

expr = (a2 /. {t[n_]^2 :> t[n^2], t[n_]*t[m_] :> t[n*m]}) /.
t[n_] :> HoldForm[1/n^s]


Simplify[a^2 == ReleaseHold[expr]]

(*  True  *)


EDIT : Perhaps this is closer

expr2 = (a2 /. {t[n_]^2 :> t[n^2], t[n_]*t[m_] :> t[n*m]}) /.
a_. * t[n_] :> HoldForm[a/n^s]


Simplify[a^2 == ReleaseHold[expr2]]

(*  True  *)