Why is $\displaystyle\int_{x=-\infty}^{x=\infty} f(x) \delta(x) \, \mathrm{d}x = f(0)$? I understand that $\delta(x)=0$ whenever $x \ne 0$ and that $\displaystyle\int_{x=-a}^{x=b}  \delta(x) \, \mathrm{d}x = 1 \space$ $\forall\, a,b \gt 0$ and also that $\displaystyle\int_{x=-\infty}^{x=\infty}  \delta(x-a) \, \mathrm{d}x = 1$. 
But I see no justification that $\color{blue}{\displaystyle\int_{x=-\infty}^{x=\infty} f(x) \delta(x) \, \mathrm{d}x = f(0)}$ for any arbitrary function $f(x)$.
I'm asking this question because the formula marked blue was given to me in response to this previous related question asked by me. But every-time I search the internet for an explanation of its derivation all I get is the same formula stated without proof. Hence, could someone please prove and/or explain the origin of the formula marked blue?
Thank you.
 A: You can define the delta function, as folows: 
Define
$$
\delta_a(x) = 
\begin{cases}
1/a & |x|\leq a/2\\
0 & \text{otherwise.}
\end{cases}
$$
So we see that this function defines a box of width $a$ and height $1/a$, so that 
$$
\int_{\mathbb{R}} \delta_a(x)\;dx=1,\quad\forall a\in\mathbb{R}_{>0}.
$$
We can now think of taking the limit as $a\to0⁺$, whereas our box tends to something infinitely thin and infinitely tall but still with total area $1$. In that case we also have 
$$
\lim_{a\to\,0⁺}\delta_a(x) = 0, \quad\forall x\neq0.
$$
Let's take the condition
$$
\int_{\mathbb{R}} \delta(x)f(x)\;dx = f(0)
$$
as the definition of the delta function, and let's see whether $\lim_{a\to0⁺}\delta_a(x)=\delta(x)$. For any (integrable) $f$ we have
$$
\int_{-\infty}^\infty \delta_a(x)f(x)\;dx=\int_{-a/2}^{a/2} \delta_a(x)f(x)\;dx=\frac{1}{a}\int_{-a/2}^{a/2} f(x)\;dx,
$$
Where we have used that $\delta_a(x)=1/a$ on $[-a/2,a/2]$ and $0$ elsewhere.
Now by the mean-value theorem we have that there exists a number $\mu(a)\in[-a/2,a/2]$, such that $f(\mu(a))$ is the mean-value of $f$ on $[-a/2,a/2]$. The result is that we can write
$$
\int_{-a/2}^{a/2} f(x)\;dx=f\big(\mu(a)\big)\int_{-a/2}^{a/2}dx= af\big(\mu(a)\big),
$$
which in turn gives us
$$
\int_{-\infty}^\infty \delta_a(x)f(x)\;dx=f\big(\mu(a)\big).
$$
Taking the limit as $a\to0⁺$, we see that $\mu(a)$, being confined to the interval $[-a/2,a/2]$, which tends to the singleton $\{0\}$ as $a$ tends to $0⁺$, must also go to $0$, and hence, assuming continuity of $f$, we have
$$
\int_{-\infty}^\infty \lim_{a\to\,0⁺}\,\delta_a(x)f(x)\;dx=\lim_{a\to\,0⁺}\int_{-\infty}^\infty \delta_a(x)f(x)\;dx=\lim_{a\to0⁺}f\big(\mu(a)\big)=f(0).
$$
As desired.
A: Defining the Heaviside (step) function $H(x)$ as
$$H(x) = \begin{cases} 0 & \space \mathrm{for} \space x \lt 0 \\1&\ \mathrm{for} \space x \gt 0 \end{cases} $$ The derivative of the Heaviside function is zero for $x \ne 0$ and undefined for $x=0$ so the $\delta$ function can represent the derivative of the Heaviside function
$$\delta(x) = \begin{cases} 0 & \space \mathrm{for} \space x \ne 0 \\\infty&\ \mathrm{for} \space x = 0 \end{cases} $$ and $$\int_{x=-\infty}^{x=\infty}\delta(x)\mathrm{d}x=1$$ 
Let $f(x)$ be any continuous function that vanishes at $x=\pm\infty$ and integrating by parts
\begin{align}
& \int_{x=-\infty}^{x=\infty} f(x)\delta(x) \, \mathrm{d}x = \left.\vphantom{\frac 1 1} f(x)H(x) \right|_{x=-\infty}^{x=\infty} -
\int_{x=-\infty}^{x=\infty} f^\prime(x)H(x) \, \mathrm{d}x \\[10pt]
= {} &0-\int_{x=0}^{x=\infty} f^\prime(x)H(x) \, \mathrm{d}x= \left.\vphantom{\frac 1 1}-f(x) \right|_{x=0}^{x=\infty}=f(0)
\end{align}
QED
A: In most common definitions of the Dirac delta (generalized) function, the formula in your post is taken as a definition. But if, for example, you accept that $\delta(x)$ is the Fourier transform of $1$, then it can be proven as follows:
$$\int_{-\infty}^{\infty} f(x) \delta(x) dx = \int_{-\infty}^{\infty} f(x) \left( \int_{-\infty}^{\infty} e^{-2\pi i kx} dk \right) dx = $$
$$= \int_{-\infty}^{\infty} \left( \int_{-\infty}^{\infty} f(x)  e^{-2\pi i kx} dx \right) dk = \int_{-\infty}^{\infty} \tilde{f}(k) dk = \int_{-\infty}^{\infty} \tilde{f}(k) e^{2\pi i k\cdot 0} dk = f(0)$$
where $\tilde{f}(k)$ is the Fourier transform of $f(x)$, and we assume the function is nice enough that we can change the order of integration.
