TITLE: Composition of almost everywhere differentiable functions
QUESTION [5 upvotes]: Let $ f: \mathbb R^n \rightarrow \mathbb R^m $ and $ g: \mathbb R^m \rightarrow  \mathbb R^k $ be almost everywhere differentiable functions (with respect to Lebesgue measure). Is it true that $ g \circ f $ is differentiable almost everywhere?
In the special case $ m=n=k $ is it true?

REPLY [11 votes]: No, $g \circ f$ need not even be continuous anywhere.  The trouble is that 
the image of $f$ could be concentrated on a "small" set where $g$ is bad.
For example, let $f: {\mathbb R} \mapsto {\mathbb R}^2$ and $g: {\mathbb R}^2 \mapsto {\mathbb R}$ with $$\eqalign{f(x) &= (x,0)\cr g(x,y) &= \cases{0 & if $y \ne 0$\cr
\chi_{\mathbb Q}(x) & if $y = 0$\cr}}$$
where $\chi_{\mathbb Q}$ is the indicator function of the rationals.  Then $g \circ f = \chi_{\mathbb Q}$ is nowhere continuous.