1

This was a bonus question on a test I just took:

Write a function with a domain of all real numbers and a range of only $2$ numbers.

The closest I got to an answer was $f(x)=\frac{x}{|x|}$, which has a range of $\{-1,1\}$, but it fails the part about the domain, because 0 has to be excluded.

Any ideas for the solution to this? Is a solution even possible?

Felipe Jacob
  • 2,446
Annie
  • 13
  • Do you mean "write with a simple formula"? Otherwise, you don't you define $f(x)=0$ for $x\geq 0$ and $f(x)=1$ for $x<0$? – Luiz Cordeiro Feb 15 '14 at 03:21
  • I think it has to be a simple formula. Both of these are correct solutions, but I think the answer was supposed to be in the form of f(x)=_______. – Annie Feb 15 '14 at 03:52

3 Answers3

4

The Intermediate Value Theorem asserts that if $f$ is continuous and $a,b \in \mathrm{range}(f)$ then $[a,b] \subseteq \mathrm{range}(f)$. Hence, the function must be discontinuous.

This means we are forced to construct a function piecewise (although it might be disguised). An example is $$f(x)=\begin{cases} 0 & \text{if } x<0 \\ 1 & \text{if } x \geq 0. \end{cases}$$

In fact, every such function will have this form: $$f(x)=\begin{cases} a & \text{if } x \in I \\ b & \text{otherwise} \end{cases}$$ for some $I \subsetneq \mathbb{R}$ and $a,b \in \mathbb{R}$ with $a \neq b$.

We could disguise the piecewise structure, e.g., by taking $$f(x)=(-1)^{\lfloor x \rfloor}.$$

1

$f(x):=0^{|x|}$ is another solution.

Michael Hoppe
  • 18,103
  • 3
  • 32
  • 49
  • Provided you agree with the convention that $0^0=1$ (which I do). – egreg Feb 15 '14 at 12:16
  • @egreg Who dares to disagree? Atomic power plants would explode, the binomial theorem would not hold, Taylor approximations would be invalid, in total the world would be a worse place. The consequences of ‘$0^0$ was not $1$’ are much more dramatic than the conclusions which J. Hendrix draw in his famous song “If Six was Nine”. – Michael Hoppe Feb 15 '14 at 20:51
  • Look in the site; there's plenty of people maintaining that $0^0$ should be undefined. With usually very poor arguments related to limits. See http://math.stackexchange.com/questions/11150/zero-to-the-zero-power-is-00-1 – egreg Feb 15 '14 at 20:53
  • 1
    I particularly dislike the most upvoted answer, which basically says “$0^0$ is undefined, but defining it by $0^0=1$ would not give any contradiction”. – egreg Feb 15 '14 at 20:59
  • @egreg Of course I know about that annoying stuff. Let those people correct a plethora of mathematical libraries in which $0^0$ is defined in the canonical way. – Michael Hoppe Feb 15 '14 at 21:01
  • @egreg +1 for that dislikeness! – Michael Hoppe Feb 15 '14 at 21:03
1

Another nice example: $$ f(x)=\lim_{k\to\infty}\Bigl(\lim_{n\to\infty}\bigl(\cos(k!\,\pi x)\bigr)^{2n}\Bigr) $$ (sources: Nowhere continuous functions, on Wikipedia and Dirichlet function, on Wolfram MathWorld).

This can be written also $$ f(x)=\begin{cases} 1 & \text{if $x$ is rational},\\ 0 & \text{if $x$ is not rational}. \end{cases} $$

egreg
  • 238,574