# Generalised raindrop function

Given a sequence of reals $$(a_n)_{n > 0}$$, let $$f: [0, 1] \to R$$ be the generalised raindrop function defined:

$$f(x) = a_q$$ if $$x$$ is rational, with denominator $$q$$ in lowest form; $$0$$ otherwise.

Questions:

• What are necessary and sufficient conditions on $$a_n$$for $$f$$ to be differentiable a.e.?

• If $$f$$ is discontinuous on a set of positive Lebesgue measure, is $$f$$ discontinuous a.e.?

• I think with the result that a.e. irrationals have irrationality measure 2, we can get a pretty decently weak condition. – James Baxter Mar 4 at 3:46
• I think so, though I haven’t worked out the details. There may be some subtleties that trip me up haha. – James Baxter Mar 4 at 3:59
• So this question sounds like a homework question to me... – Anthony Quas Mar 5 at 1:38
• The homework problem that hasn’t been answered – James Baxter Mar 5 at 2:05

For question 2: If $$a_n \to 0$$ as $$n \to \infty$$, then $$f$$ is continuous at all irrationals, and thus a.e., as $$\lim_{t \to x} f(t) = 0$$ for every $$x$$.
If $$\limsup_{n \to \infty} a_n > \varepsilon > 0$$, then $$\{x: f(x) > \varepsilon\}$$ is dense, and $$f$$ is discontinuous everywhere.
For question $$2$$: if $$a_q \ge c q^{-2}$$ for some $$c > 0$$, $$f$$ is nondifferentiable everywhere, while if $$a_q = O(q^{-\eta})$$ for some $$\eta > 2$$, $$f$$ is differentiable a.e. But I don't think you can say it is differentiable a.e. if $$a_q = o(q^{-2})$$.
EDIT: In fact (see Khinchin's book, "Continued Fractions") for almost every $$x$$ there are infinitely many $$p/q$$ with $$|x-p/q| < 1/(q^2 \ln(q))$$, but for $$\varepsilon > 0$$, only finitely many with $$|x -p/q| < 1/(q^2 \ln(q)^{1+\varepsilon})$$. In particular, for $$a_q = q^{-2}/\ln(q)$$ which is $$o(q^{-2})$$, $$f$$ is nondifferentiable almost everywhere.