Is $\int_0^2 f(x) dx$ defined for $f(x)=x,x \ne 1$?

Technically speaking, no, it isn't, since the function needs to be defined on the entire interval $[0,2]$ for the integral over $[0,2]$ to be well-defined. That said, you can define $f(1)$ however you want so that you have a function defined on $[0,2]$; if you do this, the integral is defined and its value is $2$.


To integrate a function over a region, say $[a,b]$, $f(x)$ must be well-defined on that region. Here $f(x)$ is not defined at $x=1$. So you can not integrate. Given the question you ask, this is enough to answer your question. But if you want to know more, note that you can assign any real value at $x=1$ to make the function well-defined, and then you can do the following:

$f(x)=x$, $x\neq 1$. Then $f(x)$ may not be continuous at $x=1$.

Then take $f(1)=a$, here $a$ may not be $1$.

But note this: For any $\epsilon>0$,

$$\int_{0}^{2}f(x)dx=\int_{0}^{1-\epsilon}f(x)dx+\int_{1-\epsilon}^{1+\epsilon}f(x)dx+\int_{1+\epsilon}^{2}f(x)dx$$

So what is going on here?

(1) You know that $\int_{c}^{c}g(x)=0$, for any function $g(x)$, since integration over a single point is $0$, and it does not depends on continuity.

Now $$\int_{0}^{1-\epsilon}f(x)dx=\Big[\dfrac{x^2}{2}\Big]_{0}^{1-\epsilon}=\dfrac{(1-\epsilon)^2}{2}\space\text{and}\space\int_{1+\epsilon}^{2}f(x)dx=\Big[\dfrac{x^2}{2}\Big]_{1+\epsilon}^{2}=\dfrac{4-(1+\epsilon)^2}{2}$$

But using (1), $$\lim_{\epsilon\to 0}\int_{1-\epsilon}^{1+\epsilon}f(x)dx=\int_{1}^{1}adx=0$$

Hence the answer is $$\int_{0}^{2}f(x)dx=\lim_{\epsilon\to 0}\Big(\dfrac{(1-\epsilon)^2}{2}+\dfrac{4-(1+\epsilon)^2}{2}\Big)=2$$


To integrate a function over an interval $A=[a,b]$, the function must be defined on all $A$.

If $f$ is not defined on a finite number of points $x_1, \dots, x_n \in A$, you can still try to give the integral a well-defined value using the Cauchy principal value, which simply means we integrate around all the discontinuities:

If $x_1 < x_2 < \dots < x_n$, we define

$$I=P.V.\int_a^b f(x)\,dx := \\ \lim_{\epsilon\to0} \left(\int_a^{x_1-\epsilon}f(x)\,dx+\int_{x_1+\epsilon}^{x_2-\epsilon}f(x)\,dx+\cdots+\int_{x_n+\epsilon}^{b}f(x)\,dx\right)$$

In this case, we have

$$P.V. \int_0^2 f(x)\,dx = \\ \lim_{\epsilon\to0} \left(\int_0^{1-\epsilon} x\,dx+\int_{1+\epsilon}^{2} x\,dx\right) =\\ \lim_{\epsilon\to0}\left(\frac{(1-\epsilon)^2}{2}+\frac{2^2}{2}-\frac{(1+\epsilon)^2}{2}\right) = 2$$


Incidentally, you can alternatively define $f(1)=c$ to be any value so that the integral is then well-defined. Then the integral would equal

$$\int_a^bf(x)\,dx = \int_0^1 x\,dx + \int_1^1 c\,dx + \int_1^2 x\,dx = 2$$

which is the same value as before. You can further generalize this principle, and say that if

$$f(x) = \begin{cases} x & \quad \text{if } x \neq x_i \text{ for all }i=1\dots n\\ c_i & \quad \text{if } x = x_i\text{ for some }i=1\dots n\\ \end{cases}$$

the value of the integral remains unchanged:

$$\int_0^2 f(x)\,dx=2$$