TITLE: Can formally differentiating give a derivative of a discrete function?
QUESTION [11 upvotes]: When I teach calculus, I really try to stress the importance of knowing the domain of a function. 
One example that I sometimes like to use to show students the importance of inspecting the domain is the following:  $f(x) = \sqrt{\sin(x)-1}$.  I ask the student to differentiate this function, and they happily apply their formal rules to obtain $f'(x) = \frac{\cos(x)}{2\sqrt{sin(x) - 1}}$.  Then I ask them to graph the original function.  Hey, it is just a discrete set of points!  I think at this point they realize that the differentiation they did was totally meaningless, and that paying attention to the domain might be a good idea.
One defect with this example is that the derivative really does fail to exist everywhere - it has no domain.  I would like an example of a rule for a function whose "largest domain" (the domain where the rule can be evaluated) is a discrete set of points, but where formally differentiating the rule yields a derivative which has a nonempty "largest domain".  I have thought off and on about this for a while now, and was hoping the collective MO community might be able to come up with something.  Or perhaps someone might be able to prove that the standard "formal rules of differentiation"  (say from Stewart's calc book), and the standard list of "common functions" are incapable of producing such an example.  I would be happy either way.

REPLY [9 votes]: I will show that Gerry's answer is typical, in some sense.
If $g(x)$ is analytic in a neighborhood of a point, say $x=0$, then its Taylor expansion is of the form $g(z) = \sum_{n=0}^{\infty} c_n z^n$ where $c_n = g^{(n)}(0)/n!$.  Thus if $g$ is real-valued for real $x$ then all the $c_n$ are real.  Apply this to $g(x) = f'(x)$ with $f$ as in the question.  Then by integrating term by term we have $f(x) = C + \sum_{n=0}^{\infty} c_n x^{n+1}/(n+1)$, where $C$ is constant.  The only way $f$ is not real is if $C$ is a non-real complex number.  This is actually the case in Gerry's example of $f(x) = \log(-x^2) = \log(|x|^2) + i \arg(-1)$ (however you want to define the argument of $-1$).  The trick to generating further examples is then to find disguised ways to write such a function $f$.