When are definite integrals undefined? We have $$\int_{-1}^{1} \dfrac{1}{x} \, dx$$ as undefined and then we have $$\int^1_{-1} f(x)\delta(x) = f(0)$$ 
assuming $f(x)$ is continuous everywhere and $$\delta(x) = \begin{cases} 0 & x\ne 0,
 \\ \infty & x = 0. \end{cases}$$
In both cases the integrand is infinite for $x = 0$, then why second integral is not undefined?
 A: In the physics-y spirit of the question: The "$\delta$-function" (which, as Zachary comments, is not a real-valued function) has finite integral even if "the value at one point is infinite".
By contrast, the integral $\int_{-1}^{1} \frac{1}{x}\, dx$ is undefined (as an improper Riemann integral) because the limits
$$
\lim_{a \to 0^{-}} \int_{-1}^{a} \frac{1}{x}\, dx = \lim_{a \to 0^{-}} \ln(-a),\qquad
\lim_{b \to 0^{+}} \int_{b}^{1} \frac{1}{x}\, dx = -\lim_{b \to 0^{+}} \ln b
$$
formally give the indeterminate expression
$$
\int_{-1}^{1} \frac{1}{x}\, dx = \infty - \infty.
$$
Geometrically, the region under the graph $y = \frac{1}{x}$ for $0 \leq x \leq 1$ has infinite area, and the region above the graph $y = \frac{1}{x}$ for $-1 \leq x \leq 0$ has infinite area.
Though "the reciprocal function and the $\delta$-function are both infinite at one point", their respective behaviors differ with respect to integration over an arbitrarily small neighborhood of $0$.
A: Don't believe everyone telling you that you need to know functional analysis or measure theory... 
you just need to use the appropriate definition for $\delta$:
\begin{align*}
\delta(x) &= \frac{1}{2}\,\operatorname{sgn}'(x)  \\
\int_{-1}^{1} f(x)\,\delta(x)\,dx
&= \int_{-1}^{1} f(x)\,\frac{\operatorname{sgn}'(x)}{2}\,dx  \\
&= \left.f(x)\operatorname{sgn}(x)\right|_{-1}^{+1} - \int_{-1}^{1} \frac{\operatorname{sgn}(x)}{2}\,f'(x)\,dx  \\
&= \frac{f(1)+f(-1)}{2} + \int_{-1}^{0} \frac{f'(x)}{2}\,dx - \int_{0}^{1} \frac{f'(x)}{2}\,dx  \\
&= \frac{f(1)+f(-1)}{2} + f(0) - \frac{f(-1)+f(1)}{2}  \\
&= f(0)
\end{align*}
Note the following:


*

*You don't actually need $f$ to be differentiable. If it can be approximated arbitrarily well by a differentiable function, the same arguments here work.

*You don't need $\operatorname{sgn}$ to be the sign function. Just pretend it's a smooth approximation whose behavior only changes very close to the zero. Again, the proof holds just fine in that case, and as the approximation gets better, the error vanishes.
You don't need to know measure theory or functional analysis to understand any of this intuitively.
A: \begin{align}
& \int_{-1}^0  \frac{dx} x = -\infty, \\[10pt]
& \int_0^1 \frac{dx} x = +\infty, \\[10pt]
& \lim_{\varepsilon \, \downarrow \, 0} \left( \int_{-1}^{-\varepsilon} \frac{dx} x + \int_\varepsilon^1 \frac{dx} x \right) = \lim_{\varepsilon\,\downarrow\,0} \left( \log_e \varepsilon -\log_e \varepsilon \right) = 0, \tag 1 \\[10pt]
& \lim_{\varepsilon\,\downarrow\,0} \left( \int_{-1}^{-\varepsilon} \frac{dx} x - \int_{2\varepsilon}^1 \frac{dx} x \right) = \lim_{\varepsilon\,\downarrow\,0} (\log_e \varepsilon - {}\log_e (2\varepsilon)) = \log_e \frac 1 2  \ne 0. \tag 2
\end{align}
When the positive and negative parts are both infinite, then "rearrangements" of this sort can alter tha value of the integral. The result in $(1)$ is the "Cauchy principal value" of the integral from $-1$ to $1.$
$$
\int_{-\infty}^\infty \delta(x)\,dx = 1.
$$
With the delta function, the positive part of the value of the integral is finite and the negative part is zero -- hence finite.
But notice that
$$
\int_{-\infty}^\infty \Big( 3\delta(x) \Big) \, dx = 3,
$$
so if one says that $\delta(0) = \infty,$ then one would have $\delta(0) = 3\cdot\infty = \text{what?}$ And here the answer is that the delta function is not a "function" in the sense of something that returns an output for each input; rather it is characterized by the values of the integrals of products $f(x)\delta(x)$ where $f$ actually is a function in that sense.
A: As mentioned in the comments, $\delta$ is not a function in the classical sense, but a distribution. For simplification you can think of it as a definition that $\int f(x)\delta(x)\,dx = f(0)$. 
But be careful because in the if you define a classical function 
 $$\hat \delta(x) = \begin{cases} 0 & x\ne 0
 \\ \infty & x = 0{}\end{cases}$$ as a classical function then for all integrable functions $f$ we get: $\int f(x)\hat\delta(x)\,dx = 0$ since $\hat\delta$ is zero almost everywhere and therefore $f\cdot\hat\delta$ is zero almost everywhere.
To further understand why you could say that this equation is kind of valid for the dirac distribution, you need a fundamental understanding of measure theory and functional analysis.
If you have a basic background in measure theory, you can understand the delta distribution as the extended radon-nikodym-derivative of the dirac measure and the lebesgue measure.
