# Rigorous proof of univariate chain rule

Chain rule is one of the fundamental results in calculus, which is why it is not surprising that the proof of this theorem has been discussed on stackexchange many times (for instance here, here, here, here and here). While all of these proofs were good, I wanted to write a detailed proof of my own. I would gladly appreciate if someone could verify whether the proof is indeed rigorous enough and does not contain and mistakes

Let $$X, Y$$ be subsets of $$\mathbb{R}$$, let $$x_0\in X$$ be a limit point of $$X$$, and let $$y_0$$ be a limit point of $$Y$$. Let $$f:X\to Y$$ be a function such that $$f (x_0 ) = y_0$$ , and such that $$f$$ is differentiable at $$x_0$$ . Suppose that $$g : Y \to \mathbb{R}$$ is a function which is differentiable at $$y_0$$. Then the function $$g \circ f : X \to \mathbb{R}$$ is differentiable at $$x_0$$, and $$(g \circ f )'(x_0) = g'(f(x_0)) \cdot f'(x_0)$$

To prove the assertion above we use the defintion of sequential continuity, which is equivalent to normal continuity on metric spaces. For this means, pick an arbirtrary sequence $$(x_n)_{n\in\mathbb{N}}$$ such that $$(x_n)_{n\in\mathbb{N}}\to x_0$$.Since $$f$$ is differetiable, it is also continuous, and thus $$(f(x_n))_{n\in\mathbb{N}}\to f(x_0)$$. We therefore consider the sequence $$(f(x_n))_{n\in\mathbb{N}}$$. We have two mutually exclusive cases

1) $$f'(x_0) \neq 0$$. Then we cannot have infinitely many $$f(x_n)$$'s for which $$f(x_n) = f(x_0)$$ - otherwise the derivative $$\lim \frac{f(x_n) - f(x_0)}{x_n - x_0}$$ would converge to zero. Thus, sort out all the constant values, and cosider the pure'' sequence $$f(x_k)_{k=0}^{\infty}$$ with $$\lim f(x_k) = \lim f(x_n) = f(x_0)$$, where we used the fact that all the subsequences of a convergent sequence converge against the same limit. We then have \begin{align*} \lim_{n\to\infty} \dfrac{g(f(x_n)) - g(f(x_0))}{x_n - x_0} &= \lim_{k\to\infty} \dfrac{g(f(x_k)) - g(f(x_0))}{f(x_k) - f(x_0)} \dfrac{f(x_k) - f(x_0)}{x_k - x_0} \end{align*} Since $$g$$ and $$f$$ are assumed to be differetiable, both limits exist, and we have \begin{align*} &= \lim_{k\to\infty} \dfrac{g(f(x_k)) - f(x_0)}{f(x_k) - f(x_0)} \cdot \lim_{k\to\infty} \dfrac{f(x_k) - f(x_0)}{x_k - x_0}\\[10pt] &= \lim_{y\to f(x_0)} \dfrac{g(y) - f(x_0)}{y - f(x_0)} \cdot \lim_{x\to x_0} \dfrac{f(x) - f(x_0)}{x - x_0}\\[10pt] &= g'(f(x_0)) \cdot f'(x_0) \end{align*}

2) $$f'(x_0) = 0$$. Then the case where we have infinitely many elements of $$(f(x_n))_{n\in\mathbb{N}}$$ with $$f(x_n) = f(x_0)$$ is possible. Obviously, we then have $$f'(x_0) = 0$$, and thus the right hand side is $$g'(f(x_0)) \cdot f'(x_0) = 0$$. The left hand side is also $$(g\circ f)'(x_0) = 0$$ since we have infinitely many $$g(f(x_n)) = g(f(x_0))$$, and by sequential continuity $$\lim_{n\to\infty} \frac{g(f(x_n)) - g(f(x_0))}{x_n - x_0} = 0$$.