For real-valued samples (possibly known to lie in some interval, but without further constraints on them), I am interested in the tightest possible bound on the sample variance $\sigma^2$, given the sample size $n$, sample mean $\mu$, sample minimum $m$, and sample maximum $M$. The context is that of data-sets with these statistics and the sample standard deviation. Namely, tuples $(m, M, \mu, \sigma)$ with $n$ fixed. Their use would be to check the consistency of these values. (You would be amazed to see what errors appear in such datasets!)
I have come across the lower bound attributed to Gyula (Julius) von Szőkefalvi Nagy,
$$\sigma^2\geq\frac{1}{n}\frac{M-m}{2},$$
but have not identified this bound in the claimed source or an academic reference; I assume that $n$ needs to be replaced by $n-1$ if Bessel's correction is used.
I have come across the upper bound named after Bathia and Davis,
$$\sigma^2\leq(M-\mu)(\mu-m).$$
Their paper “A Better Bound on the Variance” is easy to locate.
However, neither bound is claimed to be the tightest possible given $n$, $\mu$, $m$, and $M$. A priori, this seemed unlikely to me as well, because the lower bound does not make use of $\mu$ and the upper does not make use of $n$.
So, my first question is: Have the tightest bounds been described in the literature, and if so, where?
In case this question cannot be answered positively, I have a follow-up question: Are the bounds I derive below the tightest ones? (To start perhaps: Are they valid?)
In what follows, I assume without loss of generality (wlog) that $\mu=0$, so $m\leq0\leq M$. I will work with the samples through their order statistics, i.e.,
$$m=x_{(1)}\leq x_{(2)}\leq\dots\leq x_{(i)}\leq\dots\leq x_{(n-1)}\leq x_{(n)}=M.$$
So then
$$\mu=\frac{1}{n}\sum_{i=1}^nx_{(i)}=\frac{1}{n}\left(m+\sum_{i=2}^{n-1}x_{(i)}+M\right)=0$$
and
$$\sigma^2=\frac{1}{n-1}\sum_{i=1}^n{x_{(i)}}^2=\frac{1}{n-1}\left(m^2+\sum_{i=2}^{n-1}{x_{(i)}}^2+M^2\right).$$
Based on the principle that $kz^2\leq(kz)^2$ for $k\in\mathbb{Z}_{>0}$ and $z\in\mathbb{R}$, we construct hypothetical samples that should minimize and maximize the variance. First with as many possible values close to $\mu=0$ for the lower bound,
$$0=m+\sum_{i=2}^{n-1}x_{(i)}+M=m+(n-2)\nu+M,$$
where $\nu=-\frac{m+M}{n-2}$, so that
$$\sigma^2\geq\frac{1}{n-1}\left(m^2+(n-2)\nu^2+M^2\right).$$
Second with as many values far away from $\mu=0$ for the upper bound,
$$0=m+\sum_{i=2}^{n-1}x_{(i)}+M=n_mm+\kappa+n_MM,$$
where $n_m=\lfloor n\alpha\rfloor$ and $n_M=\lfloor n(1-\alpha)\rfloor$ with $\alpha=\frac{M}{M-m}$ from $0=\alpha m + (1-\alpha)M$ implying $(n_m+n_M=n\wedge\kappa=0)\vee(n_m+n_M=n-1\wedge m<\kappa<M)$, so that
$$\sigma^2\leq\frac{1}{n-1}\left(n_mm^2+\kappa^2+n_MM^2\right).$$
I have checked that these bounds are indeed tighter than the Nagy and Bathia-Davis ones. (I took wlog that $-m=1\geq M$ and plotted for $M\in(0,1]$ and $n\in[3,600]$.)