Suppose we want to approximate a function $f(x)$ on a interval $[c,d]$ by, say, a linear polynomial $p(x) = a_0 + a_1x$ using the scalar product $$\langle f,g\rangle = \int_a^bw(x)f(x)g(x)\,dx,$$ where $w(x)$ is some weight function.
My question is: If the interval $[c,d]$, on which I want to approximate $f$ by $p$, is different than the limits of the integration of $\langle f,g\rangle$, I must change those limits to the same of the interval or do some different change (or no change at all), in order to have the proper approximation in that interval?
It may seem unusual but $[a,b]$ and $[c,d]$ can indeed be different within the domain.
You are to find the best approximation with respect to a given norm (inner-product induced) from a given subspace ($span\{x^0,x^1\}$); which is the same as to find the orthogonal projection using the inner product onto the subspace. The solution will be the best approximation in the whole domain. The norm provided a notion of "distance" between functions, and in principle it could be defined using an arbitrary interval within the domain.