Nice!
I'm still wondering though how to arrive at the result....
The only way I can think of, is calculating the integrals of (1+x) with 1 and with cosx (after norming them) to find the projection, which is (1+pi).
And then calculate the integral of ((1+x)-(1+pi))^2, which is indeed .
But isn't this analysis and calculus?
Is there an easier way?
Well, there is no strict boundary between Calculus and Algebra, but if you use the inner product and the concept of orthogonal projection we can consider more an algebraic than analytic method. Besides, if we compute the Gram matrix with respect to the basis of we can express and from this point, the problem is purely algebraic.