Suppose we want to estimate $\int_0^{h}f(x) dx$ using Lagrangian interpolating polynomials and with nodes $x_0 = 0,x_1 = \frac{2}{3}h$. Thus we compute the quadrature rule
$$ Q(f) = a_0f(0)+a_1f(\frac{2}{3}h). $$
Now using the fact that $$ a_k = \int_0^hl_k(x)dx $$
we can find $$ Q(f) = \frac{h}{4}(f(0)+3f(\frac{2}{3}h)). $$
Then here comes the part where I get confused. We are then asked to find the composite quadrature rule for $\int_0^1f(x)dx$ and use it to estimate $\int_0^1 \cos(x)dx$ using a step size $h=0.5$.
I am not so sure how to proceed from here. Cheers in advance for any help.
Split the interval $[0,1]$ into two $[0,1/2)\cup [1/2,1]$, so that
$$ \int_0^1{\rm d}x~f(x) = \int_0^{1/2}{\rm d}x~f(x) + \int_{1/2}^1{\rm d}x~f(x) = \int_0^{h}{\rm d}x~f(x) + \int_{h}^{2h}{\rm d}x~f(x) \tag{1} $$
with $h=1/2$. The second integral in the "problematic" one, to solve it, use the change of variables $y = x - h$, ${\rm d}x = {\rm d}y$ it then becomes
$$ \int_0^1{\rm d}x~f(x) = \int_0^{h}{\rm d}x~f(x) + \int_{0}^{h}{\rm d}y~f(y + h) \tag{2} $$
Now both integrals can be approximated with the rule you described. In both cases $f(x) = \cos(x)$, so that $\cos(y+h) = \cos(y + 1/2)$