22
$\begingroup$

Ok. This question may sound very easy, but actually i am in great need of it. I have been facing trouble in constructing functions, which are only continuous at some particular sets.

For e.g, the standard example of a function which is only continuous at one point, is the function, $f(x) = x, \ x \in \mathbb{Q}$ and $f(x) = -x, x \in \mathbb{R} \setminus \mathbb{Q}$. Similarly, i would like to know as to how to construct a function which is

  • Continuous at exactly $2,3,4$ points.

  • Continuous exactly at integers

  • Continuous exactly at Natural numbers

  • Continuous exactly at Rationals.

I would like to see many examples (with proof!), so that i can don't struggle when somebody asks me to construct such functions.

  • 3
    The variety of questions you ask (and the little work you show in them) makes me think you are a whole group of people hiding behind a name, à la Bourbaki...2010-10-25
  • 0
    @Mariano: Well, not really. I am the only one!2010-10-25
  • 0
    @Mariano: Perhaps, you should not be talking in that manner!2010-10-25
  • 1
    see also: http://math.stackexchange.com/questions/740/useful-examples-of-pathological-functions2010-10-25
  • 0
    @ISaac: thanks Isaac!2010-10-25
  • 10
    @Mariano: This reminds me of a joke I read somewhere: "Why did Bourbaki stop writing books? They discovered that Serge Lang was a single person."2010-10-25
  • 1
    @Hans: You made my day, thanks for the joke! :) @Chandru: showing people what you've *tried* in solving your problems would certainly dispel any doubts.2010-10-25
  • 0
    @J.M: Yes, but answers to these questions are readily available on the net. I thought of understanding the methodology behind the constructions, which is why i posted here!2010-10-26
  • 0
    ...you missed my point. You're actually supposed to show how you "struggle", to use your words.2010-10-26
  • 0
    @J.M: Sorry i didn't get what you meant by saying that!2010-10-26
  • 0
    "I tried to xxx, but it didn't work because I saw yyy when it should have been zzz." or words to that effect. You're smart, you should be able to explain the mathematics you've tried.2010-10-26

2 Answers 2

26
  1. One simple way of constructing a function which is continuous only at a finite number of points, $x=a_1,\ldots,a_n$, is to do a slight modification to the function you give: take a polynomial $p(x)$ that has roots exactly at $x=a_1,\ldots,a_n$ (e.g., $p(x) = (x-a_1)\cdots(x-a_n)$) , and then define $$ g(x) = \left\{\begin{array}{ll} p(x) & \text{if $x\in\mathbb{Q}$;}\\ 0 & \text{if $x\notin\mathbb{Q}$.} \end{array}\right.$$ The function is continuous at $a_1,\ldots,a_n$, and since $p(x)\neq 0$ for any $x\notin\{a_1,\ldots,a_n\}$ then $g(x)$ is not continuous at any point other than $a_1,\ldots,a_n$. Other possibilities should suggest themselves easily enough.

  2. A function that is continuous exactly at the integers: a similar idea will work: find a function that has zeros exactly at the integers, for example $f(x)=\sin(\pi x)$, and then take $$g(x) = \left\{\begin{array}{ll} \sin(\pi x) & \text{if $x\in\mathbb{Q}$;}\\ 0 & \text{if $x\notin\mathbb{Q}$.} \end{array}\right.$$

  3. A function continuous exactly in the natural numbers: take a function that is continuous at the integers, and redefine it as the characteristic function of the rationals in appropriate places(what happens at $0$ depends on whether you believe $0$ is in the natural numbers or not). Assuming that $0\in\mathbb{N}$, one possibility is: $$g(x) = \left\{\begin{array}{ll} \sin(\pi x)&\text{if $x\in\mathbb{Q}$ and $x\geq 0$;}\\ x & \text{if $x\in\mathbb{Q}$ and $-\frac{1}{2}\lt x\leq 0$;}\\ 1 & \text{if $x\in\mathbb{Q}$ and $x\leq -\frac{1}{2}$;}\\ 0 & \text{if $x\notin\mathbb{Q}$.} \end{array}\right.$$

  4. A function continuous exactly on the rationals. This one is a bit trickier. There is no such function. This follows because the set of discontinuities of a real valued function must be a countable union of closed sets.

    Perhaps then, we might anticipate the next question:

  5. A function that is continuous exactly on the irrationals. An example is the following: let $s\colon\mathbb{N}\to\mathbb{Q}$ be an enumeration of the rationals (that is, a bijection from $\mathbb{N}$ to $\mathbb{Q}$. Define $f(x)$ as follows: $$f(x) = \sum_{\stackrel{n\in\mathbb{N}}{s_n\leq x}} \frac{1}{2^n}.$$ The function has a jump at every rational, so it is not continuous at any rational. However, if $x$ is irrational, let $\epsilon\gt 0$. Then there exists $N$ such that $\sum_{k\geq N}\frac{1}{2^k}\lt \epsilon$. Find a neighborhood of $x$ which excludes every $q_m$ with $m\leq N$, and conclude that the difference between the value of $f$ at $x$ and at any point in the neighborhood is at most $\sum_{k\geq N}\frac{1}{2^k}$.

    Edit: As I was reminded in the comments by jake, in fact the "standard example" of a function that is continuous at every rational and discontinuous at every rational is Thomae's function. The example I give is a monotone function, and although it is discontinuous at every rational, it is continuous from the right at every number.

  • 0
    @Arturo Magidin: Super Work! Really appreciate it, although the function which is continuous exactly at irrationals appears intricate!2010-10-25
  • 0
    Isn't expecting a function which is continuous only at irrational numbers not to be intricate slightly weird? :)2010-10-25
  • 1
    @Mariano: intricate, yes; the reason I say it is "tricky" is that the answer in *that* case is "there is no such function!". So if you go around trying to find one, you keep running into walls.2010-10-25
  • 0
    @Mariano: First my point of asking this question was, (i) I didn't know the answer (ii) It may help lot of undergrad people who look into this site. Now if you don't like to answer a question, then please don't do it, but please do not make some irrelevant comments on the OP!2010-10-25
  • 0
    @ALL: Does anyone have a problem of answering such questions?2010-10-25
  • 2
    @Chandru1: Speaking of irrelevant comments... Mariano is not the only one who has wondered in the past about your question-asking habits... e.g., http://meta.math.stackexchange.com/questions/548/dealing-with-many-poorly-motivated-questions-from-a-single-user So it seems hardly fair to start picking on *him* for something a lot of us wonder about.2010-10-25
  • 0
    @Arturo Magidin: So what do you want me to do!2010-10-25
  • 0
    @Arturo Magidin: So you mean to say, i should not say anything even they throw some stupid comments on me. Next exclamation mark and a question mark, doesn't seem to be a big issue.2010-10-25
  • 0
    @Arturo Magidin: If i feel i should ask something here, i shall proceed, and if you people find it disturbing then you are free to take actions on me.2010-10-25
  • 0
    @Chandru1: And since you say that "you are free to take actions on me", and you think that people complaining about your actions is "stupid", then perhaps you might want to lead by example and not complain about people proceeding they way *they* feel they should.2010-10-25
  • 0
    @Mariano: See also http://meta.math.stackexchange.com/questions/610/user-flooding-the-site-with-questions-more-than-6-day.2010-10-25
  • 0
    @Arturo: I accept!2010-10-25
  • 2
    @Arturo Magidin: In my analysis class, we were given Thomae's function as the classic example of a function continuous exactly at all irrationals. See http://en.wikipedia.org/wiki/Thomae's_function . Is there a reason you didn't use that one? It seems much simpler. Unless it's somehow the same thing...2010-10-25
  • 1
    @Jake: Ah; mine is the classic example of a *monotonoe* function that is continuous exactly at all rationals. Slightly different "class"... I did know Thomae's function, but the one I always remember is this one.2010-10-25
  • 0
    @ArturoMagidin Great work can we define a function continuous at all rational but discontinuous at all irrational2015-02-06
  • 0
    @ArturoMagidin More generally given a set A and subset C of A(not containing isolated points) can we define a function which is discontinuous at C but continuous in A(all subset of R)2015-02-06
  • 0
    @ArturoMagidin not specifying function just argument will also be useful but must not dependent on Axiom of choice or countable choice if possible2015-02-06
  • 0
    @Arturo Magidin) I have one question more for 1. If $a_k$ is **irrational** then how $g$ is continuous at $a_k$ ?2016-05-29
  • 0
    @Arturo:: Please response sir..2016-05-31
11

Continuous at 2, 3, 4: $f(x)=(x-2)(x-3)(x-4)$ if $x$ is rational, $f(x)=0$ if $x$ is irrational.

Continuous at the integers: $f(x)=\sin(\pi x)$ if $x$ is rational, 0 if $x$ is irrational.

Continuous at the natural numbers: $f(x)=\sin(\pi x)$ if $x$ is rational and not a nonpositive integer, 0 if $x$ is irrational, 1 if $x$ is a nonpositive integer.

Continuous exactly at the rationals: Impossible, because the set of rational numbers is not a $G_\delta$.

  • 0
    @Jonas: Thanks a lot Jonas: By the way can you prove the continuity of $\sin{\pi x}$ at integers!2010-10-25
  • 0
    @Jonas: I think we can have a function which is discontinuous only at rationals!2010-10-25
  • 0
    @Jonas. Heh; great minds and all that...2010-10-25
  • 1
    @Chandru: if $x$ is not an integer, then $\sin(\pi x)\neq 0$; take $\epsilon \lt \frac{1}{2}|\sin(\pi x)|$ and in any $\delta$ nbd of $x$ you have irrationals where the value of $f$ is more than $\epsilon$ away from $f(x)$; exactly the same as in the first case of the polynomial example for the first question.2010-10-25
  • 0
    @Chandru1: The limit along the irrationals is always zero, so the function is continuous precisely where the (continuous) function $\sin(\pi x)$ is zero. You can fill in the details.2010-10-25
  • 0
    @Arturo Magidin: Thanks a ton!2010-10-25
  • 0
    @Chandru1: Yes, you're right about having a function discontinuous at rationals. This is seen in Arturo's answer, but more generally it is true that each $G_\delta$ is the set of points where some function is continuous. See for example http://mathoverflow.net/questions/165/does-the-continuous-locus-of-a-function-have-any-nice-properties/174#174.2010-10-25
  • 0
    @Chandru1: I now realize that I probably misread the first question. You weren't asking about continuity at the points 2, 3, and 4, but for continuity at 2, 3, or 4 points. But the same basic idea works for any finite number of points, as elaborated on in Arturo's answer.2010-10-25
  • 0
    @jonas: yes correct2010-10-25
  • 0
    @Chandru1: I just noticed that you asked a question in August whose answer shows you that there are continuous functions discontinuous only at the rationals by showing the more general fact that every $F_\sigma$ is the set of discontinuities of some function: http://math.stackexchange.com/questions/3499/f-sigma-subsets-of-mathbbr/3524#35242010-10-31