Mathematica's Help documentation on DirichletConvolve is economical, to say the least. It claims the function "gives the Dirichlet convolution of the expressions f and g" and that's it, except for the example

In[1]:= DirichletConvolve[n, n, n, m]
Out[1]= m DivisorSigma[0, m]

This is going to sound stupid, but here's what I take away from the help documentation:

According to their own definition, the expression DirichletConvolve[n, n, n, m] convolves a function n with some other function also called n to produce an output which ignores the third n completely, and produces a specific function of m as output - even though the original two separate functions both defined by n have not been specified...

So, obviously I have it wrong. But I genuinely cannot make any sense of it. Specifically:

  1. Dirichlet convolution convolves two functions f[n] and g[n] (with the same argument n) to produce Sum[f[d]*g[n/d], Divisible[n, d]]. Where does a fourth input quantity m feature in this? And where does the third quantity n disappear to? In some expressions, changing the third quantity does make a difference, but I can't riddle what that difference is, and why. This is because...
  2. In every case, the output seems to be a sum of multiples of DivisorSigma[0, m] (with some of those multiples being factors of n derived through some equality that I'm unaware of. This is emphatically not the case with actual Dirichlet convolution, so what gives?

I'm sure that these are dumb questions and there's a simple explanation, but it isn't there in the Help documentation.

Can anyone explain, perhaps with a worked-through example? It's a big ask, I know, but I'd really appreciate it.


2 Answers 2


Consider the following code

f[n_, p_] := n^p
g[n_, p_] := n*p
DirichletConvolve[f[n, p], g[n, p], n, 4]

First, we define two functions f and g. Then we compute their Dirichlet convolution.

The third argument in the Dirichlet convolution tells us that n is the function argument for which we want to do the convolution. p on the other hand is a parameter that happens to exist in the functions but is not related to the convolution. Changing the last line to

DirichletConvolve[f[n, p], g[n, p], p, 4]

means that we are using p as the variable for the convolution, whereas n now is some parameter.

Finally, the 4 says that we want to evaluate the resulting function at 4. If you want to evaluate this function at the general position m you use

DirichletConvolve[f[n, p], g[n, p], n, m]

Mathematical Way

Let me write this in a mathematical way: We have two functions

$$ f \colon \mathbb{N} \times \mathbb{N} \longrightarrow \mathbb{N} \\ (n,p) \longmapsto n^p $$


$$ g \colon \mathbb{N} \times \mathbb{N} \longrightarrow \mathbb{N} \\ (n,p) \longmapsto n\cdot p $$

Now DirichletConvolve[f[n, p], g[n, p], n, m] evaluates

$$ (f*g)(m, p) = \sum_{d \mid m} f(d, p) g \left(\frac{m}{d}, p\right) $$

whereas DirichletConvolve[f[n, p], g[n, p], p, m] evaluates

$$ (f*g)(m, p) = \sum_{d \mid m} f(p, d) g \left(p, \frac{m}{d}\right) $$

Example from the Documentation

If the functions f and g do not have any parameters, this looks like:

f[n_] := n (* or any other function depending only on n *)
g[n_] := n

DirichletConvolve[f[n], g[n], n, m]

This example is equivalent to the one from the documentation

DirichletConvolve[n, n, n, m]

We convolve the identity map with itself and evaluate it at m.

  • $\begingroup$ Hi @A.Z. - thank you, that makes sense - kinda... Could you explain one more thing and I'll mark it as answered? Here it is: What happens if there is no extra parameter p, if f and g both take argument n only? $\endgroup$ Jun 25, 2020 at 15:33
  • $\begingroup$ I updated it a little bit. I also wanted to insert a few mathematical formulas, but apparently I have some syntax error :-( $\endgroup$
    – A.Z.
    Jun 25, 2020 at 16:40
  • $\begingroup$ Hi @A.Z. I'm really grateful for the detail and thought you've put into this. Thank you. $\endgroup$ Jun 26, 2020 at 7:31

Let f,g be arithmetical functions.

Then (f*g)(n), where * is Dirichlet Multiplication or Convolution is equal to:


and also:


So for example,


I only recently tweeted about this to @WolframResearch https://twitter.com/ndroock1/status/1273593486491693062

  • 1
    $\begingroup$ Hi @nilo, yeah, for sure the documentation could be simpler - and so could the function! $\endgroup$ Jun 25, 2020 at 15:31

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.