Defining a topology such that a function is continuous In a Ph.D entrance interview, I was asked the following question : $f$ is a function from $\Bbb R$ to $\Bbb R$ such that $f(x)=1$ when $x \geq 1$ and $f(x)=-1$ otherwise. The codomain has the usual topology. Find the coarsest topology on the domain such that $f$ is continuous.
I answered that since $f^{-1}\{1\}= [1,\infty)$ and $f^{-1}\{-1\} = (-\infty,1)$, we have $[1,\infty)$ and $(-\infty,1)$ as the open sets. This is because preimage of any open interval in $\Bbb R$ not containing $1$ and $-1$ will be $\varnothing$, preimage of any open interval containing both points will be $\Bbb R$, preimage of an open interval containing $1$ will be $[1,\infty)$ and preimage of an open interval containing $-1$ will be $(-\infty,1)$. Since union of these two sets is $\Bbb R$ and intersection of these two sets is $\varnothing$, both of which are open sets, we have a topology. But it seemed that the interviewers were not satisfied with the answer and indicated that there may be more open sets. I would like to know where I have gone wrong.
 A: The coarsest topology on $\mathbb R$ is in fact that you described (with the two non-trivial open sets $(-\infty,1)$ and $[1,\infty)$).
This can be seen most easily by considering the subspace $f(\mathbb R) =\{1,-1\}$ of the codomain of $\mathbb R$ which has the discrete topology. Let $\mathbb R'$ denote the set $\mathbb R$ with any topology. Clearly $f : \mathbb R '\to   \mathbb R$ is continuous iff $f : \mathbb R' \to  f(\mathbb R)$ is continuous. This shows $\{\emptyset, X, f^{-1}(1), f^{-1}(-1) \}$ is the coarsest topology.
If your interviewers claimed that there are more open sets, they were wrong. But perhaps they were not satisfied with your argumentation  and asked you "May there be more open sets?"
A: First, the codomain being $\mathbb R$ with the usual topology, the subsets of the domain that have to be open have the form $f^{-1}(U)$ where $U$ is an open subset of the codomain $\mathbb R$ with the usual topology.
So I have to wonder: Why bother working out $f^{-1}\{1\}$ and $f^{-1}\{-1\}$ when $\{-1\}$ and $\{1\}$ are not open subsets of $\mathbb R$ with the usual topology?
You would do much better to exploit the fact that the open intervals $(a,b)$ of the codomain $\mathbb R$ are a basis for the topology, and therefore subsets of the form $f^{-1}(a,b)$ are a basis for the desired topology on the domain.
And that gives you a big clue: letting $(a,b)$ vary over open intervals, work out all the possibilities for the sets $f^{-1}(a,b)$. Knowing exactly what all of those are will give you a firm foundation for proving that you have the right topology.
