It's known that some real functions map every nonempty open subset onto $\mathbb{R}$.
Is there any function from $\mathbb{R}$ to $\mathbb{R}$ that maps every nonempty perfect set onto $\mathbb{R}$?
It's known that some real functions map every nonempty open subset onto $\mathbb{R}$.
Is there any function from $\mathbb{R}$ to $\mathbb{R}$ that maps every nonempty perfect set onto $\mathbb{R}$?
Yes, there is such a function. Say $2^{\aleph_0} = \aleph_\alpha$. Then there are $\aleph_\alpha$ elements of $\mathbb{R}$, call them $a_\beta$ ($\beta < \aleph_\alpha$) and also $\aleph_\alpha$ nonempty perfect sets in $\mathbb{R}$, call them $C_\beta$ ($\beta < \aleph_\alpha$). Let $\phi: \aleph_\alpha \to \aleph_\alpha \times \aleph_\alpha$ be a bijection and write $\phi(\beta) = (\beta_1, \beta_2)$. Then inductively define $f: \mathbb{R} \to \mathbb{R}$ as follows. In the $\beta$th step, find the smallest index $\gamma$ such that $a_\gamma \in C_{\beta_2}$ and $f(a_\gamma)$ has not yet been defined, and the smallest index $\gamma'$ such that nothing in $C_{\beta_2}$ already maps to $a_{\gamma'}$. Then define $f(a_\gamma) = a_{\gamma'}$. This works because every nonempty perfect set has $2^{\aleph_0}$ elements.
This is mainly intended to complement Nik Weaver's answer by giving some first-published (?) references for this result and some ideas related to it. I originally formulated this more briefly as a two-part comment, but then decided maybe it’s worth having this be more permanently archived (and more google-findable) as an answer, which also allows me to be a bit more thorough in my comments and citations.
In [1] (1950), Halperin first constructs a function that takes every real number continuum many times in every nondegenerate interval. Then Halperin constructs a function that takes every real number continuum many times in every nonempty perfect set. Halperin’s 1st example makes use of transfinite induction to define a discontinuous additive function that has the desired properties. Halperin’s 2nd example involves a slight variation in the construction of his 1st example (a variation he credits as being used in Lusin/Sierpiński (1917)), the variation being that the transfinite construction involves the additional use of a well-ordering of all nonempty perfect sets into a transfinite sequence such that each nonempty perfect set appears continuum many times in the sequence.
Both constructions are repeated in Halperin [2] (1959), which is especially notable for its exposition of various results related to Darboux functions by Darboux, Volterra, Lebesgue — “This note reviews and comments on the examples given by Darboux, Volterra, Lebesgue and the writer.”
In [3] (1960), Marcus notes that any function that takes every real number in every nonempty perfect set automatically takes every real number continuum many times in every nonempty perfect set. Marcus explains that this result is an immediate consequence of the fact that each nonempty perfect set contains (as a subset) continuum many pairwise disjoint perfect sets. Incidentally, this result about perfect sets was (I think) first proved by Friedrich Paul Mahlo in 1917 (see also this 2 July 2001 sci.math post). Regarding the observation by Marcus, I’ve mentioned it in this 30 April 2012 MSE answer and in this 8 February 2009 sci.math post, one or both of which include related issues that might be of interest.
Finally, note that any function that takes every real number in every nondegenerate interval automatically takes every real number infinitely many times in every nondegenerate interval. However, the simple observation behind this, namely that every nondegenerate interval contains infinitely many pairwise disjoint nondegenerate intervals, does not allow us to deduce the existence of a function that the first example in Halperin (1950) [1] was designed for.
[1] Israel Halperin (1911−2007), Discontinuous functions with the Darboux property, American Mathematical Monthly 57 #8 (October 1950), pp. 539−540. JSTOR
[2] Israel Halperin (1911−2007), Discontinuous functions with the Darboux property, Canadian Mathematical Bulletin 2 #2 (May 1959), pp. 111−118.
[3] Solomon Marcus (1925−2016), Functions with the Darboux property and functions with connected graphs, Mathematische Annalen 141 #4 (August 1960), pp. 311−317.