Calculating the $M_X(t)$ of the pdf $f_X(x) = \frac{\sin(x)}{2}$ I am working on calculating the moment generating function for the  pdf $f_X(x) = \frac{\sin(x)}{2}$ with the bounds $[0, \pi]$, and here is my attempt although I would like to know whether I have approached this correctly.
Using the moment generating function for a continuous pdf:
$\int e^{tx}f_X(x)dx$
Then I have:
$$\frac{1}{2}\int_0^\pi e^{tx}\sin(x)dx$$
Then using integration by parts via substitituion:
$u = \sin(x)$ and $du = \cos(x)$, where $v = e^{tx}$ and $\frac{1}{t}dv = e^{tx}$
Putting this altogether:
$1. \frac{1}{2}\left[\frac{1}{t}\sin(x)e^{tx} |_0^\pi-\frac{1}{t}\int_0^\pi\cos(x)e^{tx} dx\right]$
The LHS becomes 0 when $x = 0$, and when $x = \pi$ it becomes 0 again as $\sin(\pi) = 0; \sin(0) = 0$
Then calculating the RHS:
$$\frac{1}{2}\left[-\frac{1}{t^2}\cos(x)e^{tx}|_0^\pi-\frac{1}{t^2}\int_0^\pi\sin(x)e^{tx}dx \right]$$
Whenever we get $\sin(x)$ it's always going to be 0 relative to the bounds $[0, \pi]$ although, when we get cos, then we will get something like this:
$$\frac{1}{2}\left[\frac{e^{t\pi}+1}{t^2} \right]$$
Because $\cos(\pi)=-1;\cos(0)=1$
From:
$\frac{1}{2}\left[-\frac{(-1)e^{t\pi}}{t^2}-(- \frac{(1)e^{t(0)}}{t^2}) \right]$
 A: First,
$$M_X(t)=\int_{-\infty}^{\infty}{e^{tx}\frac{sin(x)}{2}dx}=\int_{0}^{\pi}{e^{tx}\frac{sin(x)}{2}dx}$$
Using integration by parts with $u'=e^{tx}, v=sin(x)$:
$$M_X(t)=\frac{1}{2}\left[ \frac{1}{t}e^{tx}sin(x)-\int{\frac{1}{t}e^{tx}cos(x)} \right]_0^\pi$$
The left term does fall as you mentioned so:
$$M_X(t)=-\frac{1}{2t}\left[ \int{e^{tx}cos(x)} \right]_0^\pi$$
Again we integrate by parts, this time with $u'=e^{tx}, v=cos(x)$, recall that ${cos(x)}'=-sin(x)$:
$$M_X(t)=
-\frac{1}{2t}\left[ \frac{1}{t}e^{tx}cos(x)-\int{\frac{1}{t}e^{tx}\left(-sin(x)\right)} \right]_0^\pi=-\frac{1}{2t}\left[ \frac{1}{t}e^{tx}cos(x)+\int{\frac{1}{t}e^{tx}sin(x)} \right]_0^\pi
=
-\frac{1}{2t^2}\left[ e^{tx}cos(x) \right]_0^\pi-\frac{1}{2t^2}\left[ \int {e^{tx}sin(x)} \right]_0^\pi=
-\frac{1}{2t^2}\left[ e^{tx}cos(x) \right]_0^\pi-\frac{1}{t^2}\left[ \int {e^{tx}\frac{sin(x)}{2}} \right]_0^\pi=
-\frac{1}{2t^2}\left[ e^{tx}cos(x) \right]_0^\pi-\frac{1}{t^2}M_X(t)$$
So when solving for $M_X(t)$ (idea taken from here):
$$M_X(t)=-\frac{1}{2t^2}\left[ e^{tx}cos(x) \right]_0^\pi-\frac{1}{t^2}M_X(t)$$
$$M_X(t)\cdot(1+\frac{1}{t^2})=M_X(t)\cdot(\frac{t^2+1}{t^2})=\frac{-1}{2t^2}(e^{\pi t}cos(\pi)-e^{0t}cos(0))=\frac{-1}{2t^2}(-e^{\pi t}-1)=\frac{1}{2t^2}(e^{\pi t}+1)$$
And finally:
$$M_X(t)=\frac{t^2}{t^2+1}\cdot\frac{1}{2t^2}(e^{\pi t}+1)=\frac{e^{\pi t}+1}{2(t^2+1)}$$
