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.?



Generalised raindrop function
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.


