Least-squares when some coefficient is $0$? I'm trying to find least squares approximation $p(x)=c_1x+c_2x^2$ of $f(x)=xe^{x/2}$ in $[0,2]$.
Using the algorithm here, p.7.:
http://www.math.niu.edu/~dattab/MATH435.2013/APPROXIMATION.pdf
I'm able to come up with a $3 \times 3$ matrix $S$ and $3 \times 1$ vector $b$. However this gives me as a solution three coefficients, even though I only have two. What do I need to do to get only two (i.e. no $c_0$)?
 A: 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}.$

