# Evaluating $\int_0^1 \max (x, 1-x) dx$

I have a question related to definite integrals and series from this site here.

It is written that the definite integral of $\max(x,1-x)dx$ from $0$ to $1$ is equal to $\frac34$:

$$\int_0^1 \max (x, 1-x) dx = \frac34$$

but I have question, there are two different cases (I don't consider when $x$ is between $0$ and $1$, because in this case it is undefined which one is maximum), but in the second case, if $x<0$, then it is clear that $1-x$ is greater than $x$, so its integral is $x-x^2/2$, and after plugging values,we get $1/2$, and on the other hand, if $x>1$, then $x$ is maximum, its antiderivative is $x^2$ so we get $1/2$, so when is it equal to $3/4$? Please help me to understand this problem.

-
>>*i don't consider when x is between 0 and 1,because in this case it is undefined which one is maximum*-No, it is surely defined. $\max\{x,1-x\}=x\forall x\in[\frac{1}{2},1]$, else otherwise. So you have to split the range of integration into two halves $\int_0^\frac{1}{2}(1-x)dx+\int_\frac{1}{2}^1xdx=...$ – Tapu Dec 26 '11 at 9:26
@dato Look here is what it looks like: graph. – Rudy the Reindeer Dec 26 '11 at 9:30
When you have "∫" with a number below and above it, you can say that you integrate from the lower number to the upper number with respect to the variable after the "d". So, you can read this as saying "the integral from 0 to 1 of the maximum of x and 1-x with respect to x." Thus, you x cannot equal anything less than 0 for this problem nor anything greater than 1, x can only take on values between, and including, 0 and 1. – Doug Spoonwood Aug 16 '12 at 4:04

Since $1-x\geq x$ when $x\leq1/2$ and $x\geq 1-x$ when $x>1/2$, we have $$\max (x, 1-x)=\left\{ \begin{array}{ll} 1-x, & \hbox{if }x\leq1/2; \\ x, & \hbox{if }x>1/2. \end{array} \right.$$ Hence, $$\int_0^1 \max (x, 1-x) dx =\int_0^{1/2} \max (x, 1-x) dx +\int_{1/2}^1 \max (x, 1-x) dx$$ $$=\int_0^{1/2} (1-x)dx +\int_{1/2}^1 x dx=(x-\frac{x^2}{2})\Big|_0^{1/2}+\frac{x^2}{2}\Big|_{1/2}^1=\frac{3}{4}.$$

-
i see @Paul thanks a lot of,my problem was that,i didn't take care about range of x and did not consider what happens at two different case,just only took one case and even more then range,so thanks a lot,i understood everything – dato datuashvili Dec 26 '11 at 9:47
@dato: You are welcome. It's good that it helps. Merry Christmas! – Paul Dec 26 '11 at 9:55
you too @Paul Merry Christmas – dato datuashvili Dec 26 '11 at 10:03
Good analysis!! – NoChance Dec 26 '11 at 10:10
In a sense, this is the hard way. The integral is just the area of a square minus the area of a triangle. You don't need antiderivatives. – Michael Hardy Dec 26 '11 at 17:47

This integral, viewed as the area under the graph of a function, is just the area of a square minus the area of a triangle---that's what the graph of the function looks like. So $$(\text{base}\times\text{height}) - \left(\frac12\times\text{base}\times\text{height}\right) = (1\times1)-\left(\frac12\times 1\times\frac12\right)=1-\frac14=\frac34.$$

-

This isn't that different from Paul's answer, but I wanted an excuse to use Iverson brackets. Recall that the Iverson bracket $[p]$ is equal to $1$ if condition $p$ is true, and $0$ if $p$ is false. We also have the relation $[\lnot p]=1-[p]$.

We then have

\begin{align*} \max(x,1-x)&=x[x\geq 1-x]+(1-x)(1-[x\geq1-x])\\ &=1-x+(2x-1)\left[x\geq\frac12\right] \end{align*}

Thus,

\begin{align*} \int_0^1 \max(x, 1-x)\mathrm dx&=\int_0^1 \left(1-x+(2x-1)\left[x\geq\frac12\right]\right)\mathrm dx\\ &=\int_0^1 (1-x) \mathrm dx+\int_0^1 (2x-1)\left[x\geq\frac12\right]\mathrm dx\\ &=\int_0^1 (1-x) \mathrm dx+\int_{\frac12}^1 (2x-1)\mathrm dx\\ &=\left.\left(x-\frac{x^2}{2}\right)\right|_0^1+\left.\left(x^2-x\right)\right|_{\frac12}^1=\frac12+\frac14=\frac34 \end{align*}

-