Q:

Least Squares Method Confusion

I'm learning about the Least Squares method.
An exercise I am doing is "Find the constant c that makes the expression $$\int_{0}^{1} (e^x - cx)^2 dx$$ a minimum "
Though, i'm not sure how to approach this problem with the method. Why can't we evaluate the integral, and find the minimum of that?

A:

You can, but it is much easier to differentiate first, especially given that it's not always as easy to find the value of the integral as it is here.  So, you have
$$\int_0^1 e^x dx - 2c \int_0^1 x e^x dx + c^2 \int_0^1 x^2 dx.$$
Now minimize with respect to $c$.

