Asymptotics of $\sum_{n\leq x}d(kn)$ where $k$ is composite

As shown by @NoamD.Elkies here, $\sum_{n \leq x} d(kn)$ can be reduced to a linear combination of values of $D$ at multiples of $x$ (where $D(x)=\sum_{n\leq x}d(n)$ is the sum of the number of divisors less than $x$), so \begin{align} &\sum_{n \leq x} d(pn) = 2D(x) - D(x/p), \ p\in\mathbb{P}\\ \end{align}

which gives us

\begin{align} &\sum_{n \leq x} d(2n) = 2D(x) - D(x/2)\sim x (3 \log (x)+6 \gamma -3+\log (2))/2\\ &\sum_{n \leq x} d(3n) = 2D(x) - D(x/3)\sim x (5 \log (x)+10 \gamma -5+\log (3))/3\\ &\sum_{n \leq x} d(5n) = 2D(x) - D(x/5)\sim x (9 \log (x)+18 \gamma -9+\log (5))/5\\ &\vdots \end{align}

but for composite $k$ things seem a little less straightforward:

\begin{align} &\sum_{n \leq x} d(4n) = 3D(x) - 2D(x/2)\sim x (2 \log (x)+4 \gamma -2+\log (2))\\ &\sum_{n \leq x} d(6n) = ?\\ \end{align}

How can $\sum_{n \leq x} d(6n)$ be written in this form? Is there a general way to find the linear combination for composite $k$?

$\sum_{n\leq x} d(6n) = 4D(x) - 2D(x/2) - 2D(x/3) + D(x/6)$, which should suggest the general pattern for $k$ squarefree.

• I have found the general solution, which is simple to code (below), but difficult to put in standard notation. Is there a simple way of doing this? – martin Jan 24 '16 at 6:23

I am answering this question largely for my own records, but also posting incase useful to anybody else. Easy to code, difficult to put in standard notation:

ds[n_, x_] :=
If[n == 1, {{1, 0}, {1, 1}},
With[{a = Transpose@FactorInteger[n]},
With[{b = Times @@@ Subsets[a[]]},
With[{c = x[#] & /@ Range@Length@a[]},
Total[#[] Sum[DivisorSigma[0, k], {k, 1, x/#[]}] & /@
Transpose@{b, (-1)^PrimeOmega@b Reverse[(-1)^PrimeNu@n Total[
Times @@@ #] & /@ -(aa[c, #] & /@ Subsets[c] /.
Thread[c -> a[] + 1])]}]]]]]

With[{n = 24}, {ds[n, #] & /@ Range@10,
Sum[DivisorSigma[0, n k], {k, 1, #}] & /@ Range@10}] // Column

(*
{8, 18, 30, 42, 58, 73, 89, 103, 119, 139}
{8, 18, 30, 42, 58, 73, 89, 103, 119, 139}
*)
{"ft_lang_label":"__label__en","ft_lang_prob":0.55216694,"math_prob":0.999944,"size":942,"snap":"2019-43-2019-47","text_gpt3_token_len":413,"char_repetition_ratio":0.19189766,"word_repetition_ratio":0.0,"special_character_ratio":0.44798303,"punctuation_ratio":0.037037037,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99999595,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-20T02:59:43Z\",\"WARC-Record-ID\":\"<urn:uuid:3be067f9-2fd0-4b6f-a109-828a1e7976ce>\",\"Content-Length\":\"146483\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7dfeb143-c5df-4bfe-93ff-ecdcb62cea69>\",\"WARC-Concurrent-To\":\"<urn:uuid:0490f3a2-adc8-44f1-abfb-683d78ed6346>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://math.stackexchange.com/questions/1617231/asymptotics-of-sum-n-leq-xdkn-where-k-is-composite\",\"WARC-Payload-Digest\":\"sha1:55T4AD5U63ULPNV5ZGLUGQL7RCEUQ4DA\",\"WARC-Block-Digest\":\"sha1:OQGAOB7VIWXKEJMWNRWWBTSW3D33YD74\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570986702077.71_warc_CC-MAIN-20191020024805-20191020052305-00004.warc.gz\"}"}