Show that $\forall a,b\in \mathbb{R}$, with $a<b$, we have$$\int \limits _a^bq(x)\,dx=\frac{b-a}{2}(q(b)+q(a))-\frac{(b-a)^2}{12}(q'(b)-q'(a)),$$ where $q\in \mathcal{P}_3$ is a cubic polynomial.
I've tried doing integration by parts with $1$ and $q(x)$. But that just gives $b-a$ instead of $\dfrac{b-a}{2}$.
For the cubic polynomial $q(x)$, we have $q'''(a)= q'''(b)= q’’’$ and \begin{align} &q'(a)-\ q'(b)=q''(b)(a-b)+\frac12 q'''(a-b)^2\\ &q'(b)-\ q'(a)=q''(a)(b-a)+\frac12 q'''(b-a)^2\\ \end{align} which result in $q''(b)+q''(a)=\frac{2(q'(b)-q'(a))}{b-a}$. Integrate the following integral by parts twice \begin{align} &\int_a^b\left(x-\frac{a+b}{2}\right)q'(x)dx \\ =& \int_a^b \frac{q'(x)}2d[(x-\frac{a+b}{2})^2] = \frac{(b-a)^2}8(q'(b)-q'(a)) - \int_a^b \frac{q''(x)}6d[(x-\frac{a+b}{2})^3]\\ = &\ \frac{(b-a)^2}8(q'(b)-q'(a)) - \frac{(b-a)^3}{48}(q''(b)+q''(a))=\frac{(b-a)^2}{12}(q'(b)-q'(a))\tag1 \\ \end{align}
On the other hand, an alternative integration by parts yields the following
$$\int_a^b\left(x-\frac{a+b}{2}\right)q'(x)dx =\frac{b-a}2(q(b)+q(a))-\int_a^b q(x)dx\tag2 $$ Combine (1) and (2) to obtain $$\int_a^b q(x)dx = \frac{b-a}{2}(q(b)+q(a)) - \frac{(b-a)^2}{12}(q'(b) - q'(a))$$