  Corrected trapezoidal rules are proved for $\int_a^b f(x)\,dx$ under the
assumption that $f"\in L^p([a,b])$ for some $1\leq p\leq\infty$. Such
quadrature rules involve the trapezoidal rule modified by the addition of a
term $k[f'(a)-f'(b)]$. The coefficient $k$ in the quadrature formula is found
that minimizes the error estimates. It is shown that when $f'$ is merely
assumed to be continuous then the optimal rule is the trapezoidal rule itself.
In this case error estimates are in terms of the Alexiewicz norm. This includes
the case when $f"$ is integrable in the Henstock--Kurzweil sense or as a
distribution. All error estimates are shown to be sharp for the given
assumptions on $f"$. It is shown how to make these formulas exact for all cubic
polynomials $f$. Composite formulas are computed for uniform partitions.
