Proving conservation of mass for linear advection Reading through some course notes about conservation of mass in linear advection approximation schemes, given $\phi(x, t) \in \mathbb{R}$ and is defined for $0 \leq x < 1$ with periodic boundary conditions, and given mass $M = \int_0^1{\phi dx}$ the proof begins as follows:
$$\frac{dM}{dt} = \frac{d}{dt} \int_0^1 \phi dx = \int_0^1 {\frac{d\phi}{dt} dx} $$
A couple of questions:


*

*How can we justify moving $\frac{d}{dt}$ inside the integral?

*Shouldn't this now be a partial differential $\frac{\partial \phi}{\partial t}$ since $\phi$ is a function of space ($x$) and time ($t$)?


The proof continues:
$$-u \int_0^1\frac{d\phi}{dx}dx = -u \int_0^1 d \phi = -u \left[ \phi \right]_0^1 = 0$$
since $\phi(0, t) = \phi(1, t) \forall t$ due to the periodic boundary.
 A: If $\phi: [0,1]\times [a,b]\rightarrow \mathbb R$, $(x,t)\mapsto \varphi(x,t)$ is continuous on $[0,1]\times [a,b]$ with its partial derivative $\frac{\partial \phi}{\partial x}(x,t)$, then $M=M(t)$ is differentiable and
$$\frac{dM}{dt}(t)=\int_0^1\frac{\partial \phi}{\partial x}(x,t)dx. $$
The proof uses the  Mean value theorem and the fact that any continuous function on a compact subset of $\mathbb R^n$ is ivi uniformly continuous. Sketchy:
$$\frac{M(t+h)-M(t)}{h}=\int_0^1\frac{\phi(x,t+h)-\phi(x,t)}{h}dx=
\int_0^1\frac{\partial \phi}{\partial x}(x,t)dx+
\int_0^1\left[\frac{\partial \phi}{\partial x}(x,t+\theta h)-\frac{\partial \phi}{\partial x}(x,t)\right]dx,$$
with $0<\theta<1$. In the second equality  we added and subtracted the terms  $\int_0^1\frac{\partial \phi}{\partial x}(x,t)dx$ (which exist as the $\frac{\partial \phi}{\partial x}(x,t)$ is supposed to be continuous) and we used the Mean value theorem on the term with the ratio $\frac{\phi(x,t+h)-\phi(x,t)}{h}$. 
We go on; as $\frac{\partial \phi}{\partial x}(x,t)$ is  continuous on $[0,1]\times [a,b]$ which is compact in $\mathbb R^2$, it follows by the Heine-Cantor Theorem that it is uniformly continuous on $[0,1]\times [a,b]$, i.e.
$$\forall \epsilon>0~\exists\delta=\delta(\epsilon):~|(t+\theta h)-t|<\delta\Rightarrow |\frac{\partial \phi}{\partial x}(x,t+\theta h)-\frac{\partial \phi}{\partial x}(x,t)|<\epsilon.$$
Uniformly continuity implies that the above $\delta$ is a function of $\epsilon$ alone (this is not true in general for continuous functions). In summary we arrive at
$$\big|\frac{M(t+h)-M(t)}{h}-\int_0^1\frac{\partial \phi}{\partial x}(x,t)dx|\leq 
\int_0^1|\frac{\partial \phi}{\partial x}(x,t+\theta h)-\frac{\partial \phi}{\partial x}(x,t)|dx\leq \underbrace{\epsilon(1-0)}_{\text{here we used the unif. continuity}}=\epsilon,$$
for all $\epsilon>0$.
