Real Analysis(continuity) Prove or give a counterexample. let $f \colon R \to R$ such that $f$ is continuous on $D \subseteq R$ and $f$ is continuous on $S \subseteq R$. Then f is continuous on $D \cup S$.
I am kind of puzzled with notation ($f$ is continuous on $D \subseteq R$ and $f$ is continuous on $S \subseteq R$. Then $f$ is continuous on $D \cup S$)
Can you give me an example?
What if I consider this example: f(x) = x if x is rational and f(x) = 0 if x is irrational. Then I will have that f is continuous only at 0.( a counterexample)?
 A: The question could be understood in the following way: A function $f:\mathbb R\to\mathbb R$ is continuous on a set $A\subseteq\mathbb R$ iff it is continuous at each point $x\in A$.
If $f$ is continuous on $D$, that means that each $x\in D$ is a continuity point of $f$. Similarly, if $f$ is continuous on $C$, this means that each $x\in C$ is a continuity point. This obviously implies that $f$ is continuous at each point $x\in C\cup D$.
So if this is what OP has in mind when he speaks about a function continuous on a given subset of the domain, then the claim is true.
This is different from the answers which discuss continuity of the restrictions $f|_C$ and $f|_D$.
A: The result holds for closed sets.
Take $x_n\rightarrow a\in D\cup S$ then we have that part of this sequence pertains to $D$ and part pertain to $S$.
Let $(x_{n_j})\subset D$ then $f(x_{n_j})\rightarrow f(a)$ for the part that pertain to $D$, because $D$ is closed, for the part that pertains  to $S$ we get $(x_{n_k})\subset S$ since $S$ is closed we have $f(x_{n_k})\rightarrow f(a)$ that implies $f(x_n)\rightarrow f(a)$, if one of the sequence is finite the result is achieved because for $n$ large enough $(x_{n})\subset D$ or $(x_{n})\subset S$ any way we will have
$f(x_n)\rightarrow f(a)$ since the sequence was arbitrary we have $f$ is continuous.
The result  is false for sets in general sets for a counter example take $f=1$ in $(0,1)$ and $f=0$ in $[1,2)$. 
A: Here’s a simple example of the situation that’s being described. Let $D=[0,1]$ and $S=[1,2]$, and define $$f(x)=\begin{cases}x,&\text{if }x\in[0,1]\\2-x,&\text{if }x\in[1,2]\;.\end{cases}$$ You can easily check that $f:[0,1]\to\Bbb{R}$ and $f:[1,2]\to\Bbb{R}$ are both continuous, as is $f:[0,2]\to\Bbb{R}$.
However, what happens if, for example, you take $D=\Bbb{Q}$, the set of rational numbers, and $S=\Bbb{R}\setminus\Bbb{Q}$? Can you define a function $f:\Bbb{R}\to\Bbb{R}$ such that $f$ is not continuous at any point, but $f\upharpoonright D$ and $f\upharpoonright S$ are both continuous?
For that matter, what if you take $D=[0,1)$ and $S=[1,2]$? Can you find a rather simple function that is continuous on $D$ and on $S$ but not on $[0,2]$?
