Consider a real valued function g on an open interval $(a,b)$ which is the derivative of a function continuous on $[a,b]$ at each point of $(a,b)$. The function $g$ has the intermediate value property, so a monotone $g$ will have to be continuous, a general $g$ cannot have simple discontinuities, etc. With such constraints how badly can a derivative behave in terms of continuity, can it get much worse than the derivative of say, $x^2 \sin(1/x) $?

$\begingroup$ May be it is possible to find a relevant answer in a classical book: Bernard R. Gelbaum, John M. H. Olmsted: Counterexamples in Analysis. $\endgroup$ – Petya Aug 2 '10 at 14:54

$\begingroup$ The $x^2 \sin(1/x)$ example is taken from that book. If I recall correctly, they don't have many examples on discontinuous derivatives. $\endgroup$ – Arin Chaudhuri Aug 2 '10 at 15:07

1$\begingroup$ I don't know whether there will be examples that satisfy you there, but my favoured source for wacky real functions is van Rooij and Schikhof's A Second Course in Real Functions: books.google.co.uk/… . $\endgroup$ – Robin Chapman Aug 2 '10 at 15:13

$\begingroup$ Thanks a lot, the section on derivatives looks interesting. $\endgroup$ – Arin Chaudhuri Aug 2 '10 at 15:17

$\begingroup$ Are you asking about $g$ or $g'$? $\endgroup$ – Charles Staats Aug 2 '10 at 15:42
Talking about how bad may be the derivative of an everywhere derivable function on the interval [a,b], the natural example that occurs to my mind is: a Pompeiu derivative, that is, a derivative that vanishes in a dense set (these weird functions, however, constitue a closed linear space of $C^0[a,b]$, while it's not even obvious that they are closed wrto addition!). For an account on the subject you may refer e.g. to the above quoted book by Andrew M. Bruckner Differentiation of real functions: it's also in the CRM series now (here is a preview: http://books.google.it/books?id=fXfEGF2zJUC&printsec=frontcover&source=gbs_book_other_versions#v=onepage&q&f=false)
For a quick reference, you may also have a look to the wiki article http://en.wikipedia.org/wiki/Pompeiu_derivative (it's me who wrote it ;) )
Of course every continuous function is a derivative, so your question seems like it could be reinterpreted as the characterization problem for derivatives: that is, give "nice" necessary and sufficient conditions on a function $f: [a,b] \rightarrow \mathbb{R}$ for it to be the derivative of some other function (onesided, at the endpoints).
As others have pointed out, any derivative must be a Darboux function  i.e., satisfy the conclusion of the Intermediate Value Theorem  and also a Baire class one function  i.e., a pointwise limit of continuous functions. The latter implies that the set of discontinuities is meager. A lot of work has been done seeking to understand "how much bigger" the class of Darboux, Baire Class 1 functions is than the class of derivatives.
Here are some references:
Bruckner, A. M.; Leonard, J. L. Derivatives. Amer. Math. Monthly 73 1966 no. 4, part II, 2456.
http://math.uga.edu/~pete/BrucknerLeonard66.pdf or http://classicalrealanalysis.info/documents/andy1966.pdf
Bruckner, Andrew M. Differentiation of real functions. Lecture Notes in Mathematics, 659. Springer, Berlin, 1978. x+247 pp.
https://projecteuclid.org/euclid.bams/1183545222
Bruckner, Andrew M. The problem of characterizing derivatives revisited. Real Anal. Exchange 21 (1995/96), no. 1, 112133.

$\begingroup$ +1! Apart the very good quality of this answer, I need to pull it up since I referred to it as being "above" $\endgroup$ – Pietro Majer Aug 2 '10 at 17:09

$\begingroup$ This is a revelation, I didn't realize this was such a deep subject. $\endgroup$ – Arin Chaudhuri Aug 2 '10 at 17:17

$\begingroup$ Since neither math.uga.edu/~pete/BrucknerLeonard66.pdf nor math.uga.edu/~pete/BrucknerLeonard66.pdf work, I have added a link to the copy of that paper on the author's homepage, People who do not mind paywalls can also try jstor.org/stable/2313749 or doi.org/10.1080/00029890.1966.11970916 $\endgroup$ – Martin Sleziak Aug 21 '18 at 1:20

$\begingroup$ @Martin: I'm having some technical issues right now, but I should be able to fix the links tomorrow. $\endgroup$ – Pete L. Clark Aug 21 '18 at 2:42
Derivatives are like continuous functions in that both have the intermediate value property, but they need not have the extreme value property. Gelbaum and Olmstead, Counterexamples in Analysis, gives as example 3.7 the function $$ f(x) = \begin{cases} x^4 e^{\frac{1}{4}x^2}\sin\frac{8}{x^3}, & x \ne 0 \\ 0, & x=0 \end{cases} $$ for which $f'$ exists everywhere, but does not achieve its supremum on the compact interval $[1,1]$.
On the other hand, a derivative cannot have too many discontinuities. Lars Olsen at http://mathforum.org/kb/message.jspa?messageID=281579&tstart=0 points out that a derivative is a pointwise limit of the continuous functions and hence of Baire class at most 1, and therefore its set of discontinuities is meager (in particular, has dense complement).
I think it can. In particular, Wikipedia's antiderivative (current revision) page seems to imply that, for any meagre $F_\sigma$ subset of an open interval, one can construct a function whose derivative is discontinuous on that subset. It also gives some examples.
In Y. Katznelson and K. Stromberg’s paper “Everywhere differentiable, nowhere monotone, functions,” Amer. Math. Monthly 81 (1974), no. 4, 349–354 (doi: 10.1080/00029890.1974.11993558, JSTOR), there is a construction, based on somewhat similar ideas to those described in Majer’s above mentioned article, whereby for any two disjoint countable sets $A, B \subset \mathbb{R}$ there exists a differentiable function whose derivative equals $1$ on $A$ and is less than $1$ on $B$. So if $A$ and $B$ are both dense in $\mathbb{R}$ then this derivative must be discontinuous at every point of $B$.