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.
Nice problem, JLo.
I accept JLo's original solution (and vswitch's variation), and agree
that they work. They are not my favorite sort of function,
however. I have a preference for functions that can be
calculated. I like a lot that Ken's function has a known, exact,
readily calculated value for rationals. As for irrationals, I
intuitively feel that Ken's function can be calculated more
readily and converges more quickly.
But hey, it's just a preference. JLo and vswitch seem to have a
preference for functions where the size of the discontinuities are
known and interesting.
Pick your posion ...