# Cardinality of $A=\{f: \mathbb R \to \mathbb R , f \text{ is continuous and} f(\mathbb Q) \subset \mathbb Q\}$

Find the cardinality of the set $A=\{f: \mathbb R \to \mathbb R , f \text{ is continuous and} f(\mathbb Q) \subset \mathbb Q\}$.

My attempt at a solution:

First I've noticed that $A \subset B=\{f:\mathbb R \to \mathbb R, f \space \text{is continuous}\}$. Since a continuous functions is determined by which values it takes at all the rational points of the domain, it's easy to see that $|B|=c^{\aleph_0}=c$. Now, I am trying to find a subset $C$ of $A$ such that $|C|=c$ but I am having a hard time finding this subset. Could anyone give me suggestions/hints to find this subset?

For $C$, you can restrict to functions $f$ that are continuous and piecewise linear, each piece having rational slope and points with integer coordinates as endpoints, and such that $f(\mathbb Z)\subseteq\{0,1\}$. Do you see how to proceed?
• As $f$ is determined by which values takes at the integers, then it's clear that $|C|=2^{\aleph_0}=c$. I think I can prove that $f(\mathbb Q) \subset \mathbb Q$: pick a rational point $q$, and integers $z_1$, $z_2$: $z_1<q<z_2$. Then, $f$ is $f(x)=(x-z_1)\dfrac{f(z_2)-f(z_1)}{z_2-z_1}+f(z_2$) for all $x \in [z_1,z_2]$, $f(q)=(q-z_1))\dfrac{f(z_2)-f(z_1)}{z_2-z_1}+f(z_2)$, and by closure of addition and multiplication of $\mathbb Q$, $f(q) \in \mathbb Q$. I am not so sure how to formally prove $f$ is continuous (I know this is obvious if I draw the graph of the function). Thanks for the answer. Dec 6, 2013 at 2:25
• For continuity of piecewise defined functions: If $g,h$ are continuous functions, and we have that $f(x)=g(x)$ if $x\le a$, $f(x)=h(x)$ if $x>a$, and $h(a)=g(a)$, then $f$ is continuous. So you just have to apply this result around each integer. Dec 6, 2013 at 2:29
Hint: Let the values of $f$ at integers be a sequence of rationals converging to your favorite real number. Extend by line segments in between.
• Thanks for the answer but I don't quiet get how to define this function. You say that $f$ at the integers is a sequence of rationals converging to $r \in \mathbb R$. Sorry if I am asking something stupid, but what do you mean by this? For example, I pick $z \in \mathbb Z$ and what is $f(z)$? Dec 6, 2013 at 2:31
• Let's say you like the real number $\pi$. Then you could let $f(n) = 0$ for $n\leq 0$, $f(1) = 3$, $f(2) = 3.1$, $f(3) = 3.14$, $f(4) = 3.141$, and so on - the values are a sequence converging to $\pi$ (of course there are others, but we can just pick one such sequence). Dec 6, 2013 at 2:36
{"ft_lang_label":"__label__en","ft_lang_prob":0.9019761,"math_prob":0.99992216,"size":580,"snap":"2023-40-2023-50","text_gpt3_token_len":175,"char_repetition_ratio":0.1423611,"word_repetition_ratio":0.0,"special_character_ratio":0.2913793,"punctuation_ratio":0.09836066,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":1.0000077,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-11-29T06:25:57Z\",\"WARC-Record-ID\":\"<urn:uuid:c95e3c8c-44cf-4b2e-a712-5255d58a9ae6>\",\"Content-Length\":\"157281\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5ff64ad0-ee2a-46a1-aae6-ee2db0d3bd0e>\",\"WARC-Concurrent-To\":\"<urn:uuid:4266245c-7554-46e6-972d-290d330232d8>\",\"WARC-IP-Address\":\"104.18.43.226\",\"WARC-Target-URI\":\"https://math.stackexchange.com/questions/594915/cardinality-of-a-f-mathbb-r-to-mathbb-r-f-text-is-continuous-and-f\",\"WARC-Payload-Digest\":\"sha1:EOQOH2UAWGTO3O6K2O7QQVEC35YWI3OP\",\"WARC-Block-Digest\":\"sha1:ZUH7ARCLGL2LXDSG2XQX2CD6P6ILCDNE\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100056.38_warc_CC-MAIN-20231129041834-20231129071834-00477.warc.gz\"}"}