Definite Integrals – How to Evaluate $\displaystyle\int_0^1\frac{xe^x-e^x}{x^2-2xe^x+e^{2x}}dx$

calculusdefinite integralsexponentiationintegration

So my younger friend who loves math (whom I have mentioned before), came up with an integral for me to evaluate, this time being$$\int_0^1\dfrac{xe^x-e^x}{x^2-2xe^x+e^{2x}}dx$$which I thought that I might be able to do. Here is my attempt at evaluating the integral:

So right away we can put the integral as$$\int_0^1\dfrac{(x-1)e^x}{(x-e^x)^2}dx$$and then doing polynomial long division gets us$$\int_0^1\dfrac{e^xdx}{x-2e^x+1+\dfrac{(e^x-1)^2-2}{x-1}}$$but just kidding, I would never do that. But the form that I got the integral into before making the joke about doing polynomial long division looks like a potential contender for being in the form$$\dfrac d{dx}\dfrac fg=\dfrac{f'g-fg'}{g^2}$$where $f$ and $g$ are functions of our dummy variable $x$. So how do we get it into that form? Here's how. We know that we need $x-e^x$ to be our function $g$, and $e^x$ to be our function $f$. So we have this table which lists the first derivative of each:

$f(x):=x-e^x$ $g(x):=e^x$
First div. $1-e^x$ $e^x$

I was actually confused on what to do next, since we only have an $xe^x$ and $-e^x$ in the numerator, but then I realized that I could just (in a realistic way) expand the numerator to meet my needs for finding a function $h(x)=\frac d{dx}\frac fg=\frac{f'g-fg'}{g^2}$:$$\begin{align}\int_0^1\dfrac{xe^x\color{red}{-e^{2x}+e^{2x}}-e^x}{(x-e^x)^2}dx=&\,\int_0^1\dfrac{e^x(x-e^x)-e^x(1-e^x)}{(x-e^x)^2}dx\\\implies&\,\int_0^1\dfrac d{dx}\left(\dfrac{e^x}{x-e^x}\right)dx\\\implies&\,\left.\dfrac{e^x}{x-e^x}\right]_0^1\\=&\,\dfrac e{1-e}-1=\dfrac{2e-1}{1-e}\\\approx&\,-2.5819767068693\end{align}$$


My question


Did I evaluate the integral correctly, or what could I do to evaluate this seemingly difficult integral?

Best Answer

$$\int_0^1\dfrac{(x-1)e^x}{(x-e^x)^2}dx\\=\int_0^1-\frac{\frac{e^x-xe^x}{e^{2x}}dx}{(\frac{x}{e^x}-1)^2}\\\stackrel{u=\frac{x}{e^x}-1}{=}\int_{-1}^{\frac{1-e}{e}}-\frac{du}{u^2}\\=\left(\frac{e}{1-e}\right)+1=\frac{1}{e-1}$$