Evaluate $\int_0^{\pi/2}x e^x \sin(x)dx$. $$I=\int_0^{\pi/2}x e^x \sin(x)dx$$
I gave a lot of efforts in this question and replaced x with $\pi/2 -x $ but to no avail, this even became more complicated.
Kindly give me an  idea on how  to proceed in this very question.
 A: Define $$S(x) = \int e^x \sin x \, dx, \quad C(x) = \int e^x \cos x \, dx.$$  Then with the choice $$u = \sin x, \quad du = \cos x \, dx, \\ dv = e^x \, dx, \quad v = e^x,$$ we find that $$S(x) = e^x \sin x - \int e^x \cos x \, dx = e^x \sin x - C(x).$$  Similarly, we find $$C(x) = e^x \cos x + \int e^x \sin x \, dx = e^x \cos x + S(x).$$  It follows that $$S(x) = \frac{e^x}{2}(\sin x - \cos x) + K, \\ C(x) = \frac{e^x}{2}(\sin x + \cos x) + K$$ for any constant of integration $K$; moreover, $$\int S(x) \, dx = \int \frac{e^x}{2}(\sin x - \cos x) \, dx = \frac{1}{2}(S(x) - C(x)) = -\frac{e^x}{2} \cos x + K.$$
Thus prepared, we now easily compute with the choice $$u = x, \quad du = dx, \\ dv = e^x \sin x \, dx, \quad v = S(x),$$
$$\begin{align*} \int x e^x \sin x \, dx &= x S(x) - \int S(x) \, dx \\
&= \frac{x e^x}{2} (\sin x - \cos x) + \frac{e^x}{2} \cos x + K \\
&= \frac{e^x}{2} (x \sin x + (1-x) \cos x) + K. \end{align*}$$  The value of the definite integral is straightforward.
A: $$I=\int_0^{\pi/2}Im(x e^x e^{ix})dx =Im\underbrace{\left(\int_0^{\pi/2}x  e^{ax}dx\right)}_{J}$$
with $a:=1+i$.
Integration by parts with $u=x$ and $v'=e^{ax}$ gives:
$$J=[x\tfrac{1}{a}e^{ax}|_{x=0}^{\pi/2}-\tfrac{1}{a}\int_0^{\pi/2}e^{ax}dx$$
$$J=\tfrac{\pi}{2}\tfrac{1}{a}e^{a\pi/2}-\tfrac{1}{a^2}e^{ax}|_{x=0}^{\pi/2}$$
$$J=\tfrac{\pi}{2}\tfrac{1}{a}e^{a\pi/2}-\tfrac{1}{a^2}(e^{a\pi/2}-1)$$
$$J=\tfrac{\pi a-2}{2a^2}e^{a\pi/2}+\tfrac{1}{a^2}.$$
It remains to replace $a$ by its expression and take the imaginary part of $J$.
A: What about the cheater approach? We may freely guess that a primitive of $x\sin(x)e^x$ is given by $(A+Bx)\sin(x)e^x+(C+Dx)\cos(x)e^x$. By differentiation we may notice that $A=0,B=C\frac{1}{2},D=-\frac{1}{2}$ really lead to a primitive, then the outcome is straightforward:
$$ \int_{0}^{\pi/2}x\sin(x) e^x\,dx=\frac{1}{2}\left[x\sin(x)e^x+(1-x)\cos(x)e^x\right]_0^{\pi/2}=\color{red}{\frac{\pi e^{\pi/2}-2}{4}}.$$
