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?
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.}}$