I don't know whether your function is right or not, but the way I see it, you're overcomplicating things. Wouldn't the function f(x) = x for x irrational and 0 for x rational

work just as well? Near 0, it will behave almost exactly the same, and that's all you're looking for.

Actually, on second thought neither function works for this problem. Let's take your function. By the traditional epsilon-delta definition of the derivative, you would need that given any epsilon=e>0, find d>0 s.t. if |x|<d, then |(f(x)-x)/x|<e. But within the set {x| 0<|x|<d}, there is a rational x=1/b in lowest terms (let's say it's positive - negative case is similar), for which |f(x)-x)/x|=|(1/b)/(1/b)|=1 which is by no means less than epsilon. The function I suggested fails for a similar reason.

Now - if there was a way to constrain a sin curve so that it would bouce between x(x+1) and -x(x-1) (both of which have a derivative of 1 at 0), and give this sin curve the property of sin(1/x) s.t. it will oscillate more and more rapidly as it approaches 0 (thus making monotonicity impossible), it might be possible to tame the oscillation enough in order to make the derivative exist. Of course, I'm not sure, and i'll let you do the legwork to figure it out. Who would've guessed - ender wiggin telling mazer what to do . . .