How do you evaluate an integral with an absolute value? For example, how would you evaluate something like $\int_{-\pi}^{\pi} |t|\cos(kt)dt$? When I use Wolfram on the indefinite integral it gives me a $sgn(t)$ function, and I'm not sure what this is. However, if I use the $-\pi$ and $\pi$ it gives me the answer $\frac{2(\pi k \sin(\pi k)+\cos(\pi k)-1)}{\pi k^2}$.
 A: As Jessica suggests, the easiest way to deal with absolute value bars (or any piecewise-defined function) inside an integral, is to split up the range of integration. Since
$$ |t| = \left\{ \begin{array}{} -t & t<0 \\ t & t\geq0 \end{array} \right., $$
this means splitting up the integral at zero:
$$ \int_{-\pi}^{\pi} |t|\cos(kt)dt = \int_{0}^{\pi} |t|\cos(kt)dt + \int_{-\pi}^{0} -t\cos(kt)dt.$$

[ For what it's worth: sgn$(t)$ is the sign function:
$$ \text{sgn}(t) = \left\{ \begin{array}{} -1 & t<0 \\ 0 & t=0 \\ 1 & t>0 \end{array} \right.. $$
It's worth convincing yourself that $\frac{d}{dt}\!|t|=\text{sgn}(t)$ for all $t\neq 0$. ]
A: Just so this gets an answer (for future reference by anyone with the same problem):
The integrand consists of the product of two functions, lets call them $f(t)=|t|$ and $g(t)=\cos(kt)$. Both $f$ and $g$ are even functions, meaning they take the same value if we flip the sign of the argument;
\begin{align}
f(-t)=|-t|=|t|, \ \ \ \text{and} \ \ \ g(-t)=\cos(-kt)=\cos(kt).
\end{align}
The product of two even functions is itself even, meaning the entire integrand is an even function. And since even functions take the same values whether we are evaluating them at $t$ or $-t$, the integral will remain unchanged if we change the limits from $[0,\pi]\rightarrow[-\pi,0]$. That is,
\begin{align}
\int_0^\pi f(t)g(t)\,\mathrm{d}t=\int_{-\pi}^0f(t)g(t)\,\mathrm{d}t.
\end{align}
But then we can rewrite our integral as 
\begin{align}
\int_{-\pi}^\pi |t|\cos(kt)\,\mathrm{d}t = 2\int_0^\pi |t|\cos(kt)\,\mathrm{d}t = 2\int_0^\pi t\cos(kt)\,\mathrm{d}t.
\end{align}
Note that since $t$ is always positive now, we might as well remove the abosulute value sign. Now, make a change of variables $kt\rightarrow x$, obtaining
\begin{align}
2\int_0^\pi t\cos(kt)\,\mathrm{d}t = 2\int_0^{\pi k} \frac{x}{k}\cos(x)\,\frac{\mathrm{d}x}{k} = \frac{2}{k^2}\int_0^{\pi k} x\cos x\,\mathrm{d}x.
\end{align}
Integrate by parts, and get
\begin{align}
\frac{2}{k^2}\int_0^{\pi k} x\cos x\,\mathrm{d}x = \left.\left(\frac{2\left[k\pi\sin(k\pi)+\cos(\pi k)\right]}{k^2}\right)\right|_0^{\pi k} = \frac{2\left(k\pi\sin(k\pi)+\cos(k\pi)-1\right)}{k^2}.
\end{align}
