🧮 Brain Teaser

Exactly Twice Is Impossible

Prove that there is no continuous function f:R→Rf:\mathbb{R}\to\mathbb{R} that takes every real value exactly twice. That is, there is no continuous ff with

#{x∈R:f(x)=y}=2for every y∈R.\#\{x\in\mathbb{R} : f(x)=y\} = 2 \quad\text{for every } y\in\mathbb{R}.

Bonus (think, don't prove): Is there a continuous f:R→Rf:\mathbb{R}\to\mathbb{R} taking every value exactly three times? What about exactly nn times?


Field: Topology / Real analysis (connectedness, Intermediate Value Theorem)

Why it's interesting: This is a folklore classic. "Every value exactly twice" sounds harmless, since a parabola nearly does it. But the condition cannot hold everywhere, and the obstruction is purely about the order and connectedness of R\mathbb{R}. The answer also has a surprising parity twist: exactly nn times is possible if and only if nn is odd.

Key technique: Look at the maximum of ff between two points with the same value, then count preimages of values just below that maximum using the IVT.

Difficulty: 3/5

connectednessintermediate value theoremcompactnesscounting preimagesfolklore

Answer: Exactly Twice Is Impossible

Key Idea / Intuition

If f(a)=f(b)f(a)=f(b), then on [a,b][a,b] the graph is a "hill" (or a "valley"). The top of the hill, at height MM, must be hit exactly twice. Values just below MM are then hit too often:

  • Each side of the hill crosses those values once.
  • The second preimage of MM forces at least one more crossing.

So you get at least 33 preimages. That breaks "exactly twice."


Formal Proof / Solution

Suppose, for contradiction, that ff is continuous and every value has exactly two preimages.

Step 1: Set up a hill. Pick any cc and let a<ba<b be its two preimages, so f(a)=f(b)=cf(a)=f(b)=c. On (a,b)(a,b), f≠cf\neq c. Since (a,b)(a,b) is connected, by the IVT either f>cf>c throughout (a,b)(a,b) or f<cf<c throughout. Replacing ff by −f-f if necessary (which preserves the hypothesis), assume

f(x)>cfor all x∈(a,b).f(x)>c \quad\text{for all } x\in(a,b).

Step 2: Take the top of the hill. By compactness, ff attains its maximum MM on [a,b][a,b] at some point pp. Since f>cf>c inside, we have M>cM>c and p∈(a,b)p\in(a,b). The value MM has exactly one other preimage q≠pq\neq p. There are two cases.

Case A: q∈[a,b]q\in[a,b]. Then q∈(a,b)q\in(a,b), because f(a)=f(b)=c<Mf(a)=f(b)=c<M. Say p<qp<q; the case q<pq<p is symmetric.

  • ff is not constant on [p,q][p,q], since otherwise MM would have infinitely many preimages.
  • So m:=min⁡[p,q]f<Mm:=\min_{[p,q]}f<M, attained at some s∈(p,q)s\in(p,q).

Choose any yy with max⁡(c,m)<y<M\max(c,m)<y<M. By the IVT, yy is attained:

  • on (a,p)(a,p), since f(a)=c<y<M=f(p)f(a)=c<y<M=f(p);
  • on (p,s)(p,s), since f(p)=M>y>m=f(s)f(p)=M>y>m=f(s);
  • on (s,q)(s,q), since f(s)=m<y<M=f(q)f(s)=m<y<M=f(q);
  • on (q,b)(q,b), since f(q)=M>y>c=f(b)f(q)=M>y>c=f(b).

These intervals are disjoint, so yy has at least 44 preimages. Contradiction.

Case B: q∉[a,b]q\notin[a,b]. Say q>bq>b; the case q<aq<a is symmetric. Take any y∈(c,M)y\in(c,M). By the IVT, yy is attained:

  • on (a,p)(a,p), since f(a)=c<y<M=f(p)f(a)=c<y<M=f(p);
  • on (p,b)(p,b), since f(p)=M>y>c=f(b)f(p)=M>y>c=f(b);
  • on (b,q)(b,q), since f(b)=c<y<M=f(q)f(b)=c<y<M=f(q).

That gives at least 33 preimages. Contradiction.

Both cases are impossible, so no such ff exists. ■\blacksquare


Remarks on the Bonus

Exactly three times is possible. Take a "rising zigzag" built from piecewise-linear pieces:

  • On [0,1][0,1], go from 00 up to 22.
  • On [1,2][1,2], go from 22 down to 11.
  • On [2,3][2,3], go from 11 up to 33.

Then extend so that f(x+3)=f(x)+3f(x+3)=f(x)+3. Each unit band of values is crossed by three consecutive monotone pieces. With care at the corner points (the "turning" values), every yy is hit exactly three times.

General parity theorem. A continuous f:R→Rf:\mathbb{R}\to\mathbb{R} taking each value exactly nn times exists if and only if nn is odd. Here is the idea for even nn:

  • For large ∣x∣|x|, ff must tend to ±∞\pm\infty in a consistent way.
  • If both ends go to the same infinity, a large value yy is crossed an even number of times. If the ends go to opposite infinities, it is crossed an odd number of times.
  • A local-extremum counting argument, generalizing the hill argument above, then rules out the even case.

The proof above is the cleanest instance of this: local extrema create excess preimages.

Type: topologyEdit on GitHub ↗