Find a function f:R->R (R the set of real numbers), such that

1. f has a discontinuity in every rational number, but is continous everywhere else, and

2. f is monotonic: x<y → f(x)<f(y)

Note: Textbooks frequently present examples of functions that meet only the first condition; requiring monotonicity makes for a slightly more challenging problem.

Uh oh.. I see a problem that I don't know how to fix...

Function w(x) looks like it's continuous at more rational points than just 0. Not every rational number has a binary expansion ending in all zeros (or, equivalently, all 1's). Consider .10101010...(repeating indefinitely), which, if I'm not mistaken, evaluates to 2/3--clearly a rational number. Since there's no ambiguous binary representation of this value, it must be continuous at this point for the same reason that it's continuous for any irrational. How do we fix this? I've thought about it some, but I don't see an answer.

-----------------------------------------------------------

By the way, I agree with Charlie in the sense that this violates any intuitive notion of continuity. How can a function possibly be continuous at a given point if there are an infinite number of discontinuities in the function within any epsilon-neighborhood of that point?? But, it does satisfy the rigorous definition of continuous, so... it must be true. Here's a simpler function that would be continous at x=0 but discontinuous everywhere else.

If x is rational f(x) = -x, otherwise, f(x) = x.

Before seeing this puzzle (without thinking about the rigorous definition of continuous functions) I would have said this function is discontinuous everywhere.