Why is substituting a different variable valid in taking limits? I went looking for a proof that: $$e^x=\lim_{n\rightarrow\infty}\left(1+\frac xn\right)^n$$
I found this answer by Faiq Irfan in response to this question: Prove $ e^x = \exp(x) $ starting with their limits-based definitions
Everything makes sense to me about this answer except the first step, when Irfan changes variables from $$\lim_{n\rightarrow\infty}$$ to $$\lim_{n/x\rightarrow\infty}$$  Why is this logically valid?  It would make sense to me if this was some kind of u-substitution (for example u=nx) but it's not, n/x is simply substituted for n everywhere.  Granted both $$\lim_{n\rightarrow\infty}$$ and $$\lim_{n/x\rightarrow\infty}$$ tend to infinity as n tends to infinity but even so, I'm still not convinced this substitution must be true.
Just to be clear, I'm not suggesting Irfan is wrong, rather there must be something very basic about infinite limits I don't understand.
Thanks
 A: Let me make Faiq Irfan's answer easier to understand using "proof by example".

We know that
$$e = \lim_{n\rightarrow\infty}\left(1+\frac 1n\right)^n$$
where $n$ goes to infinity as a real number (not as a natural number).
Let $m=2023n$, i.e., $n=\frac m{2023}$.
$$e = \lim_{\frac m{2023}\to\infty}\left(1+\frac 1{\frac m{2023}}\right)^{\frac m{2023}}$$
Since $\frac m{2023}\to\infty$ if and only $m\to\infty$ (thanks to $2023>0$), we have
$$e = \lim_{m\rightarrow\infty}\left(1+\frac 1{\frac m{2023}}\right)^{\frac m{2023}}$$
Now raising both side to the power of $2023$, we get
$$\begin{aligned}e^{2023} 
&= \left(\lim_{m\rightarrow\infty}\left(1+\frac 1{\frac m{2023}}\right)^{\frac m{2023}}\right)^{2023}\\
&= \lim_{m\rightarrow\infty}\left(\left(1+\frac 1{\frac m{2023}}\right)^{\frac m{2023}}\right)^{2023}\\
&= \lim_{m\rightarrow\infty}\left(1+\frac {2023}{m}\right)^m
\end{aligned}$$
Well, there is nothing particular about $2023$ except that $2023>0$. Hence, we can replace $2023$ by any $x>0$.
$$e^{x} = \lim_{m\rightarrow\infty}\left(1+\frac {x}{m}\right)^m$$
In case the symbol $n$ is preferred, we can replace $m$ by $n$ to get
$$e^{x} = \lim_{n\rightarrow\infty}\left(1+\frac {x}{n}\right)^n$$

Once you have verified the proof above, you can see that instead of replacing $n$ by $\frac m{2023}$ in the first step, we can replace $n$ by $\frac n{x}$, where $n$ in $\frac nx$ means the $m$ in $\frac m{2023}$ and $x$ in $\frac nx$ means 2023 in $\frac m{2023}$, treating $x$ as a constant $>0$. We will recover Faiq Irfan's answer.
So the change of variable in Fraq Irfan's answer is pretty natural. It is just a linear change of one variable.

By the way, Faiq Irfan's answer misses the case when $x\le0$.
For the case when $x<0$, we can prove first
$$e^{-1} = \lim_{n\rightarrow\infty}\left(1-\frac 1n\right)^n$$
and then proceed similarly to the case above for $x>0$.
The case when $x=0$ is trivial.

In case you believe
$$e = \lim_{n\rightarrow\infty}\left(1+\frac 1n\right)^n$$
should be understood as
$$e = \lim_{n\rightarrow\infty,\ n\in \Bbb N}\left(1+\frac 1n\right)^n\tag{*}\label{*}$$
let me prove that $\eqref{*}$ implies
$$e = \lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1n\right)^n\tag{***}\label{***}$$
$$\begin{aligned}
\lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1n\right)^n
&\le\lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1{\lfloor n\rfloor}\right)^{\lceil n\rceil}\le\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^{m+1}\\
&=\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^m\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^1=e\cdot1=e\\
\lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1n\right)^n
&\ge\lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1{\lceil n\rceil}\right)^{\lfloor n\rfloor}\ge\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^{m-1}\\
&=\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^m\lim_{m\rightarrow\infty,\ m\in \Bbb N}\left(1+\frac 1m\right)^{-1}=e\cdot1=e
\end{aligned}$$
Hence,
$$\lim_{n\rightarrow\infty,\ n\in \Bbb R}\left(1+\frac 1n\right)^n=e$$.
A: $$
\lim_{n\rightarrow\infty}f(n)=L \\
 \forall \epsilon>0, \exists N s.t. \forall n>N, |f(n)-L| < \epsilon \tag{1}
$$
I'm going to write this as $f((N, \infty)) \subseteq(L-\epsilon, L+ \epsilon)$
The negation of (1) is:
$$\exists \epsilon>0, \: s.t. \forall N, \exists n>N: |f(n)-L| \ge \epsilon \tag{2}$$
In other words, there's unbounded $n$ where $f(n)$ is further than $\epsilon$ from $L$, or, $\forall N, f((N, \infty)) \nsubseteq(L-\epsilon, L+ \epsilon)$
One important thing to note straightaway is that the domain matters here: if we consider $f(n)$ on integers only, that doesn't say as much as all reals. See the comment about $\sin(n\pi)$, above.
Your question is, in what cases is (1) implied by or (2) contradicted by $$\lim_{m\rightarrow\infty}f(g(m))=L \\
\lim_{m\rightarrow\infty}g(m)=\infty$$
Again, by definition: $$ \forall \epsilon>0, \exists M_\epsilon\: s.t. f(g((M_\epsilon, \infty))) \subseteq(L-\epsilon, L+ \epsilon) \\
 \forall B, \exists G\: s.t. \forall m>G, g(m)>B$$
If we specify $\epsilon$ and find $M_\epsilon$, the second limit lets us choose $G_\epsilon$ such that $G_\epsilon>M_\epsilon$ and $g(m)>g(M_\epsilon) \forall m>G_\epsilon$. So $f(g((G_\epsilon, \infty))) \subseteq(L-\epsilon, L+ \epsilon)$
Taking $g(M_\epsilon)$ as $N$ in (2), $\exists n>g(M_\epsilon): f(n) \notin (L-\epsilon, L+\epsilon)$. This means $n \notin g((M_\epsilon, \infty))$.
This can only happen if the image $g((M_\epsilon, \infty))$ has "gaps". If the gaps were bounded -- if $(a, \infty) \subseteq g((M_\epsilon, \infty))$ for some $a$ -- then we could plug $a$ into (2) again, and find another bad $n$.
Thus, the image of $g$ must have an unbounded set of gaps. Then, the limit of $f$ may not exist because of its values in those gaps.
