Composite functions, continuity, and limits I am looking at a scenario where we take the limit of a composite/nested function
$$\lim _{x \rightarrow c} f(g(x))$$
However apparently there are two jumps being made here that I don't quite understand:


*

*We can rephrase the problem as solving for $f( \lim _{x \rightarrow c} g(x))$. I am sure it's correct and fine but I see this statement being thrown around everywhere with no proof or intuition. Why are we allowed to do this?

*Assume the answer to the limit of $g(x)$ is a constant $d$. Then supposedly $f(d)$ has to be continuous at $x=d$. I think this means $f(d)$ is defined and the two-sided limit $L$ at $x=d$ actually equals $f(d)$ as well. Is this right? Why does it have to be continuous at $d$?
What about the inner function $g(x)$? Does this mean endpoints of a domain are not continuous (I assume they are not)? What if they are defined? For instance a function with domain $(-4, 4)$ versus one with domain $[-4, 4]$? 
 A: It may be the case that $f(x)$ and $g(x)$ are discontinuous functions, but their composition $f\circ g(x)$ is continuous.  
i.e. lets pick two of the craziest (and most famous) discontinuous functions.
Let $g(x)$ be Thome function
$g(x) = \begin{cases} \frac {1}{q} & x \text{ is rational with } x = \frac pq \text{ in lowest terms}\\0& x\text{ is irrational}\end{cases}$
let $f(x)$ be the Dirichlet function
$g(x) = \begin{cases} 0 & x \text{ is rational with }\\1& x\text{ is irrational}\end{cases}$
$f\circ g(x)$ is continous.  But this is pretty unusual.
However if $g(x)$ is continuous at $c$ (as you say above, left hand limit at $c$ equals the right hand limit at $c$ equals $g(c)$) and $f(x)$ is continuous in the neighborhood of $g(c)$ then $f\circ g(x)$ is continuous at $c$ and $\lim_\limits{x\to c} f\circ g(x)$ exists (both left hand and right hand) and equals $f\circ g(c)$
What matters is continuity around $c$ (for $g$) and around $g(c)$ (for $f$).  $f(x)$ and $g(x)$ might do crazy stuff outside of those neighborhoods.
Why are we allowed to do this.
We need to go to the $\epsilon-\delta$ definition of limits.
$g$ is continuous at $c$
$\lim_\limits{x\to c} g(x) = L$
$\forall \epsilon_1>0, \exists \delta_1>0: |x-c|<\delta_1\implies |g(x) - L|<\epsilon_1\tag{1}$
And $f$ is continuous at $L$
$$\forall \epsilon_2>0, \exists \delta_2>0: |x-L|<\delta_2\implies |f(x) - f(L)|<\epsilon_2$$
Setting $\epsilon_1 < \delta_2$ then $|f\circ g(x) - f\circ g(c)|<\epsilon_2$
We can do this because 1) is true for any $\epsilon.$
