The order of taking derivative and integration Let $x$ be a variable:
Observation 1: $$\frac{d}{dx}\int_{0}^{x}1~dt = 1|_x = 1$$ by the Fundamental Theorem of Calculus.
Observation 2: $$\int_{0}^{x}(\frac{d}{dt}1)~dt = 1|_x-1|_0 = 0$$ by the Fundamental Theorem of Calculus.
My question is, why taking derivative followed by integration "cancels off" to recover the function $1$ but integration followed by taking derivative "do not cancel off" to recover the function $1$?
 A: Let $X = C^1(A)$ be the set of continuously differentiable functions on some open interval $A \subseteq \Bbb{R}$ containing $0$ and let $Y = C^0(A)$ be the set of continuous functions on $A$. Then we can consider the derivative function as a map $D : X \to Y$.
It's easy to see that $D$ is not injective. Indeed, it maps both the constant functions $1$ and $0$ to the constant function $0$. This stops there being a (single-valued) inverse of $D$, from $Y$ to $X$ (the multivalued indefinite integral is a good consolation prize though). However, the fundamental theorem of Calculus shows that $D$ is surjective. If we let, for $f \in Y$ (i.e. $f$ is continuous on $A$),
$$I(f) = x \mapsto \int_0^x f(t) \, \mathrm{d}t,$$
then $D(I(f)) = f$, showing that, for all $f \in Y$, there exists some $g \in X$ such that $D(g) = f$. That is, we have surjectivity.
Indeed, $I$ is what we call a "right-inverse" of $D$, meaning that $D \circ I = \operatorname{Id}_Y$. Right inverses exist if and only if the function is surjective. On the other hand, left-inverses, i.e. functions $L : Y \to X$ such that $L \circ D = \operatorname{Id}_X$, exist if and only if $D$ is injective, which it isn't. For our purposes, if such an $L$ existed, then we would have
\begin{align*}
0 = 0 &\implies D(1) = D(0) \\
&\implies (L \circ D)(1) = (L \circ D)(0) \\
&\implies \operatorname{Id}_X(1) = \operatorname{Id}_X(0) \\
&\implies 1 = 0,
\end{align*}
a contradiction. (Beware: every number in the above argument is refers to a constant function, not just a real number.)
Because no such $L$ exists, we certainly can't have $I$ fit the bill. This means that we definitely cannot have $(I \circ D)(f) = f$ for all $f \in X$. With that in mind, it is no surprise that you have found an example where $(I \circ D)(f) \neq f$.
