Prove regular languages are closed under f(n) = 2^n and f(n) = n^2
For $f(n)=2^n$:

Let $M=(Q,\Sigma,\delta,q_0,F)$ be the DFA recognizing $R$. Denote by $\mathcal{G}$ the set of functions from $Q$ to $\mathcal{P}(Q)$ (where $\mathcal{P}(Q)$ means the power set of $Q$), and for any $g,h\in\mathcal{G}$, denote by $gh$ the function defined as $$gh(\cdot)=\bigcup_{q\in h(\cdot)}g(q).$$ 

Construct a new DFA $M'$ of whose states each is labeled a pair $(q,g)\in Q\times\mathcal{G}$. The transition function $\delta'$ of $M'$ is defined as

$$\delta'((q,g),a)=\left(\delta(q,a),gg\right),$$

for all $q\in Q, g\in\mathcal{G}, a\in\Sigma$. The start state of $M'$ is $(q_0,g_0)$ where $g_0$ is defined as $g_0(\cdot)=\{\delta(\cdot,a)\mid a\in \Sigma\}$. The set of accept states of $M'$ is $\{(q,g)\in Q\times\mathcal{G}\mid g(q)\cap F \neq \emptyset\}$.

Now we claim that 


  After reading a word $w$, if $M$ reaches state $q$, then $M'$ reaches the state $(q,g)$, where $g(\cdot)$ represents the set of states $M$ can potentially reach when starting at state $\cdot$ then reading a word of length $f(|w|)$. 


This cliam can be proven by mathematical induction on $|w|$. With this claim, we can see $M'$ indeed recognizes $f(R)$.



For $f(n)=n^2$, the proof is similar. In this case, each state of $M'$ is labeled a tuple $(q,g_1,g_2)\in Q\times \mathcal{G}^2$, the transition function becomes

$$\delta'((q,g_1,g_2),a)=\left(\delta(q,a),g_1g_0,((g_2g_1)g_1)g_0\right),$$

where $g_0(\cdot)=\{\delta(\cdot,a)\mid a\in \Sigma\}$ as above, the start stae becomes $(q_0,I,I)$ where $I(\cdot)=\{\cdot\}$, and the set of accept states becomes $\{(q,g_1,g_2)\in Q\times\mathcal{G}\mid g_2(q)\cap F \neq \emptyset\}$.

Also, our claim becomes


  After reading a word $w$, if $M$ reaches state $q$, then $M'$ reaches the state $(q,g_1,g_2)$, where $g_1(\cdot),g_2(\cdot)$ respectively represent the set of states $M$ can potentially reach when starting at state $\cdot$ then reading a word of length $|w|,|w|^2$.