3. In the coordinate plane, there are two regions $M$ and $N$. $M$ is defined by 
\[
\left\{\begin{array}{l}
y \geqslant 0, \\
y \leqslant x, \\
y \leqslant 2-x,
\end{array} \quad N\right.
\]
is a region that varies with $t$, determined by the inequality $t \leqslant x \leqslant t+1$, where the range of $t$ is $0 \leqslant t \leqslant 1$. Then the area of the common part of $M$ and $N$ is a function $f(x)=$ $\qquad$
3. $-t^{2}+t+\frac{1}{2}$.

As shown in Figure 2, according to the problem, we have
$$
\begin{array}{l}
=1-\frac{1}{2} t^{2}- \\
\frac{1}{2}(1-t)^{2} \\
=-t^{2}+t+\frac{1}{2} \text {. } \\
\end{array}
$$