The approximation is
$$
g(x) \approx c_{1} f_{1}(x) + c_{2} f_{2}(x)
$$
over the domain $a < x < b$. Choose the method of least squares. Minimize the sums of the squares of residuals:
$$
r^{2}(c) = \int_{a}^{b} \left(f(x) - c_{1} f_{1}(x) - c_{2} f_{2}(x) \right)^{2} dx.
$$
This creates the linear system
$$
\begin{align}
%
\mathbf{A} c &= G \\
%
\left[
\begin{array}{cc}
\int_{a}^{b} f_{1}(x) \times f_{1}(x) dx & \int_{a}^{b} f_{1}(x) \times f_{2}(x) dx \\
\int_{a}^{b} f_{2}(x) \times f_{1}(x) dx & \int_{a}^{b} f_{2}(x) \times f_{2}(x) dx
\end{array}
\right]
%
\left[
\begin{array}{c}
c_{1} \\ c_{2}
\end{array}
\right]
%
&=
%
\left[
\begin{array}{c}
\int_{a}^{b} f_{1}(x) \times g(x) dx \\
\int_{a}^{b} f_{2}(x) \times g(x) dx
\end{array}
\right]
\end{align}
$$
In this problem $g(x) = xe^{\frac{x}{2}}$, $f_{1}(x) = x$, and $f_{2}(x) = x^{2}.$
For the domain $a= 0$ and $b=2$, the linear system is
$$
\left[
\begin{array}{cc}
\frac{8}{3} & 4 \\
4 & \frac{32}{5} \\
\end{array}
\right]
%
\left[
\begin{array}{c}
c_{1} \\ c_{2}
\end{array}
\right]
%
=
%
\left[
\begin{array}{r}
8 (e-2) \\ -32 (e-3)
\end{array}
\right],
$$
which has the solution
$$
\left[
\begin{array}{c}
c_{1} \\ c_{2}
\end{array}
\right]
%
=
%
\left[
\begin{array}{c}
24 (-19 + 7 e) \\ 300 - 110 e
\end{array}
\right].
%
$$
The following plot shows the residual error function $g(x) - c_{1}x - c_{2}x^{2}.$
