Definite Integral involving Max function. Here is an integral I was attempting to solve $\int\limits_{0}^{\ln t}{\max{\left(1,x\right)dx}}$ but my answer is not coming to be correct. What is wrong in my attempt?
Attempt 1. Let's call the integral $I$
Case 1. Let $0<t<e$  $\implies$ $\ln t < 1$
This means the given integral becomes $\int\limits_{0}^{\ln t}{1 dx}$ because from $(0,1)$ the maximum between $1$ and $x$, is $1$  $$\implies I=\ln t \tag{1}$$
Case 2. Let $e<t< \infty$ $\implies$ $\ln t >1$
This means the given integral becomes $I= \int\limits_{1}^{\ln t}{\max{\left(1,x\right)dx}} = \int\limits_{1}^{\ln t}x dx$ because from $(0,\infty)$ the maximum between $1$ and $x$, is $x$  $$\implies I=\left[\frac{x^2}{2}\right]_{1}^{\ln t}= \frac{(\ln t)^2-1}{2} \tag{2}$$
Adding $(1)$ and $(2)$ we get $$I = \ln t + \frac{(\ln t)^2-1}{2}$$ 
But this is not the correct answer.
Attempt 2. We know that $\max{\left(f(x),g(x)\right)} = \frac{f(x)+g(x)}{2}+\frac{|f(x)-g(x)|}{2}$
Hence $I=\int\limits_{0}^{\ln t}{\max{\left(1,x\right)dx}}=\int\limits_{0}^{\ln t}{(\frac{1+x}{2}+\frac{|1-x|}{2})dx}$
$$\implies \int\limits_{0}^{\ln t}{\frac{1}{2}dx}+\int\limits_{0}^{\ln t}{\frac{x}{2}dx}+\int\limits_{0}^{\ln t}{\frac{|1-x|}{2}dx}$$
The first two integrals will give us $\frac{\ln t}{2} + \frac{(\ln t)^2}{4} \tag{1}$
Let's calculate the third integral $I_3 = \int\limits_{0}^{\ln t}{\frac{|1-x|}{2}dx}$
Case 1. Let $0<t<e$  $\implies$ $\ln t < 1$
$I_3 = \int\limits_{0}^{1}{\frac{x-1}{2}dx}=\left[\frac{x^2}{4}-\frac{x}{2}\right]_{0}^{1}=\frac{1}{4}-\frac{1}{2}=-\frac{1}{4} \tag{2}$
Case 2. Let $e<t< \infty$ $\implies$ $\ln t >1$
$I_3 = \int\limits_{1}^{\ln t}{\frac{1-x}{2}dx} = \left[\frac{x}{2}-\frac{x^2}{4}\right]_{1}^{\ln t} = \frac{\ln t}{2} - \frac{(\ln t)^2}{4} - \frac{1}{4} \tag{3}$
Adding $(1)$,$(2)$ and $(3)$, we get $$I=\ln t -\frac{1}{2}$$
But this also is not the correct answer. 
Please tell me where am I doing wrong?
 A: Correct Attempt 1. Let's call the integral $I$
Case 1. Let $0<t\le e$  $\implies$ $\ln t \le 1$
This means the given integral becomes $\int\limits_{0}^{\ln t}{1 dx}$ because from $(0,1)$ the maximum between $1$ and $x$, is $1$  $$\implies I=\ln t \tag{1}$$
Case 2. Let $e\le t< \infty$ $\implies$ $\ln t \ge 1$
This means the given integral becomes $\color{red}{I= \int\limits_{0}^{\ln t}{\max{\left(1,x\right)dx}} = \int\limits_{0}^{1}{1 dx} + \int\limits_{1}^{\ln t}x dx}$ because from $(1,\infty)$ the maximum between $1$ and $x$, is $x$  $$\implies I=1 + \left[\frac{x^2}{2}\right]_{1}^{\ln t}= 1 + \frac{(\ln t)^2-1}{2}=\frac{(\ln t)^2+1}{2} \tag{2}$$
We get combining $(1)$ and $(2)$ $$I = \begin{cases} \ln t & \text{if } 0<t \le e, \\ \frac{(\ln t)^2+1}{2} & \text{if } e\le t<\infty. \end{cases}$$
Correct Attempt 2. We know that $\max{\left(f(x),g(x)\right)} = \frac{f(x)+g(x)}{2}+\frac{|f(x)-g(x)|}{2}$
Hence $I=\int\limits_{0}^{\ln t}{\max{\left(1,x\right)dx}}=\int\limits_{0}^{\ln t}{(\frac{1+x}{2}+\frac{|1-x|}{2})dx}$
$$\implies \int\limits_{0}^{\ln t}{\frac{1}{2}dx}+\int\limits_{0}^{\ln t}{\frac{x}{2}dx}+\int\limits_{0}^{\ln t}{\frac{|1-x|}{2}dx}$$
The first two integrals will give us $$\frac{\ln t}{2} + \frac{(\ln t)^2}{4} \tag{1}$$
Let's calculate the third integral $I_3 = \int\limits_{0}^{\ln t}{\frac{|1-x|}{2}dx}$
Case 1. Let $0<t\le e$  $\implies$ $\ln t \le 1$
$\color{red}{I_3 = \int\limits_{0}^{\ln t}{\frac{1-x}{2}dx}=\left[\frac{x}{2}-\frac{x^2}{4}\right]_{0}^{\ln t}=\frac{\ln t}{2} - \frac{(\ln t)^2}{4}} \tag{2}$
Case 2. Let $e\le t< \infty$ $\implies$ $\ln t \ge 1$
$$\color{red}{I_3 = \int\limits_{0}^{1}{\frac{1-x}{2}dx} + \int\limits_{1}^{\ln t}{\frac{x-1}{2}dx} = \left[\frac{x}{2}-\frac{x^2}{4}\right]_{0}^{1} + \left[\frac{x^2}{4}-\frac{x}{2}\right]_{1}^{\ln t}}$$ $$\implies I_3 = \left[\frac{1}{4}\right] + \left[\frac{(\ln t)^2}{4} - \frac{\ln t}{2} + \frac{1}{4}\right] = \frac{(\ln t)^2}{4} - \frac{\ln t}{2} + \frac{1}{2} \tag{3}$$
Combining $(1)$and$(2)$, and $(1)$and$(3)$ separately, we get $$I = \begin{cases} \ln t & \text{if } 0<t\le e, \\ \frac{(\ln t)^2+1}{2} & \text{if } e\le t<\infty. \end{cases}$$
Both attempts give us the same solution.
$\color{red}{\text{The corrections have been pointed out in red.}}$
A: The given function equals $1$, then $x$ for increasing $x$. The corresponding antiderivatives must be $x+C$ and $\dfrac{x^2}2+C'$. To ensure continuity at $x=1$, $C'=C+\dfrac12$.
Hence
$$\int\max(1,x)\,dx=\begin{cases}x\le1\to x+C,\\x\ge1\to\dfrac{x^2+1}2+C.\end{cases}$$
The definite integral follows.
A: Your reasoning is correct, but you made a small mistake in your first attempt for case 2:
$$ I=\int_0^{\ln t}\max(1,x)dx = \int_0^1\max(1,x)dx + \int_1^{\ln t}\max(1,x)dx = \int_0^11dx + \int_1^{\ln t}xdx$$
I think you understood that completely because you changed the boundaries but you got confused when dealing with case 2. You mustn't add $\ln t$ to $\int_1^{\ln t}xdx$ but 1.
Again, for your second attempt, your reasoning is fine but you got confused because adding (2) and (3) makes no sense since it deals with distinct cases.
A: *

*$x\le 1\implies \max(1,x)=1$, then $\ln t\le1\implies I=\left.x\right|_{x=0}^{\ln t}=\ln t.$

*$x\ge 1\implies \max(1,x)=x$ then $\ln t\ge1\implies I=\left.x\right|_{x=0}^1+\left.\dfrac{x^2}2\right|_{x=1}^{\ln t}=\dfrac{\ln^2t+1}2$.
