Suppose that $f \colon [0, 1] \to \mathbb{R}$ is a $C^\infty$ function satisfying the constraints
$$
f(0) = f'(0) = f(1) = f'(1) = 0, \quad \mbox{and} \quad \int\_0^1 (f''(y))^2 \, dy \leq 1. 
$$
Denote this class of functions $\mathcal{F}.$


I want to know what is the best approximation one can give of the $L^2$ norm of $f$ in terms of the evaluation of $f$ on a uniform grid. Basically, I want to know what we can say about
$$
\sup\_{f \in \mathcal{F}} 
\Big\{\int\_0^1 f^2(y) \, dy - \frac{1}{n}\sum\_{i=1}^n f^2(i/n) \Big\}.
$$
My conjecture is that the error should go down as $n^{-4}$ since the quadratic interpolant should have this error, but I had difficulty checking this to be the case.




---


**Addendum:** I have added an additional periodicity constraint, primarily because as indicated by the argument from Iosif below, one can apply the Euler-Maclaurin formula to obtain $n^{-p}$ for any $p$ provided that $f \in C^\infty$ is periodic on $[0, 1]$. Hence, let's make the problem easier. We assume periodicity for the function and first order derivative. The naive application of Euler-Maclaurin gives an upper bound on the quantity above of $O(1/n^2)$ uniformly over the class. However, I cannot construct an $f$ that actually achieves this, subject to my constraints.



Optimal constant to compare $L^2$ norm of smooth function on $[0, 1]$ to a grid
By the [Euler–Maclaurin formula](https://en.wikipedia.org/wiki/Euler%E2%80%93Maclaurin_formula#The_formula) (with $p=4$, $m=0$, and $g(x):=\frac1n\,f^2(\frac xn)$ in place of $f(x)$ there in the formula),
$$d\_n(f):=\int\_0^1 f^2(y) \, dy - \frac{1}{n}\sum\_{i=1}^n f^2(i/n) \\
=-\frac1{2n}\,f^2(1)-\frac1{6n^3}\,f(1)f'(1)+O(n^{-4})\le O(n^{-4})$$
for each $f\in\mathcal F$.




---


However, one cannot get a constant factor $O(n^{-4})$ good for all $f\in\mathcal F$ at once. Specifically, for $n\ge2$,
$$\sup\_{f\in\mathcal F}d\_n(f)\ge d\_n(f\_n)
=\frac{1}{\pi ^4 (2 n+1)^2}\sim\frac1{4\pi^4 n^2} \tag{1}\label{1}$$
as $n\to\infty$, where
$$f\_n(x):=\frac1{\pi^2}\,
\Big(\sin (\pi x)-\frac{\sin (\pi (2 n+1) x)}{(2 n+1)^2}\Big),$$
so that $\int\_0^1(f\_n'')^2=1$ and $f\_n(0)=0=f\_n(1)$.


(Note that $f\_n\notin\mathcal F$, since $f\_n'(0)\ne0$ and $f\_n'(1)\ne0$. However, $f\_n$ can be approximated however closely by functions in $\mathcal F$ with respect to the norm given by the formula
$$\|f\|^2=\max\_{[0,1]}(f^2)+\int\_0^1(f'')^2.$$
More generally, this approximation shows that $\sup\_{f\in\mathcal F}d\_n(f)$ will not change if the conditions $f'(0)=0=f'(1)$ are removed from the definition of $f\in\mathcal F$.)




---


On the other hand, even without the conditions $f(1)=f'(1)=0$ on $f\in\mathcal F$ (added later by the OP), one can see that
$$\sup\_{f\in\mathcal F}d\_n(f)\le \frac1{72 n^5}+\frac1{12 n^2}\sim\frac1{12 n^2} \tag{2}\label{2}$$
as $n\to\infty$, so that the lower bound on $\sup\_{f\in\mathcal F}d\_n(f)$ in \eqref{1} is sharp up to a universal positive real constant factor.


To get \eqref{2}, use the [Euler–Maclaurin formula](https://en.wikipedia.org/wiki/Euler%E2%80%93Maclaurin_formula#The_formula) again, but this time with $p=2$, which together with the condition $\int\_0^1(f'')^2\le1$ yields
$$d\_n(f)\le-\frac1{2n}\,f^2(1)-\frac1{6n^3}\,f(1)f'(1)+\frac1{12 n^2} \tag{3}\label{3}$$
for all $f\in\mathcal F$. Using the condition $\int\_0^1(f'')^2\le1$ again, now together with the condition $f'(0)=0$, we get $|f'(1)|\le\int\_0^1|f''|\le1$, whence
$$-\frac1{2n}\,f^2(1)-\frac1{6n^3}\,f(1)f'(1)
\le-\frac1{2n}\,f^2(1)+\frac1{6n^3}\,|f(1)|\le\frac1{72 n^5},$$
so that \eqref{2} follows from \eqref{3}.


