1 Introduction

A function \(f: I\subset \mathbb{R}\to \mathbb{R}\) is said to be convex on an nonempty interval I if the inequality

$$ f\biggl(\frac{x+y}{2}\biggr)\le \frac{f(x)+f(y)}{2} $$
(1.1)

holds for all \(x,y\in I\).

If inequality (1.1) reverses, then f is said to be concave on I [1].

Let \(f: I\subset \mathbb{R}\to \mathbb{R}\) be a convex function on an interval I and \(a,b\in I\).

Then

$$ f\biggl(\frac{a+b}{2}\biggr)\le \frac{1}{b-a} \int _{a}^{b} f(t)\,dt\le \frac{f(a)+f(b)}{2}. $$
(1.2)

This double inequality is known in the literature as the Hermite–Hadamard (HH) integral inequality for convex functions.

It has plenty of applications in most different areas of pure and applied mathematics (see [24] and the references therein).

If f is a concave function, then both inequalities in (1.2) hold in the reverse direction, i.e.,

$$ \frac{f(a)+f(b)}{2}\le \frac{1}{b-a} \int _{a}^{b} f(t)\,dt\le f\biggl( \frac{a+b}{2} \biggr). $$
(1.3)

During 130 years of its existence, this inequality has been intensely studied, extended, and generalized by many authors. Some recent trends can be found in [517] and [1823].

As an example we quote an improvement by arbitrary means given in [24].

Let \(f: I\subset \mathbb{R}^{+}\to \mathbb{R}\) be a convex function and \(S=S(a,b)\), \(T=T(a,b)\) be some means of positive numbers \(a, b\in I\).

Then

$$ \frac{1}{b-a} \int _{a}^{b} f(t)\,dt\le \frac{1}{2} f(S)+ \frac{1}{2(b-a)}\bigl[(S-a)f(a)+(b-S)f(b)\bigr]; $$
(1.4)

and

$$ \frac{1}{b-a} \int _{a}^{b} f(t)\,dt\ge \frac{1}{b-a} \biggl[(T-a)f\biggl( \frac{a+T}{2}\biggr)+(b-T)f\biggl(\frac{T+b}{2} \biggr)\biggr]. $$
(1.5)

For any means S and T, approximations (1.4) and (1.5) are better than original (1.2).

In this article we investigate the possibility of a form of the Hermite-Hadamard inequality for functions that are not necessarily convex/concave on I. This has already been attempted in [25] where the convexity/concavity of the second derivative was shown to be crucial in managing improvements of the HH inequality as a linear combination of its endpoints.

We derive here two forms of the Hermite-Hadamard inequality under the sole condition that the second derivative of the target function f exists locally on an interval I. Thus, \(f\in C^{(2)}(I)\) and, because \(f''\) is continuous on a closed interval \(E:=[a,b]\subset I\), it follows that the quantities \(m=m_{f}(a,b):=\min_{t\in E}f''(t)\) and \(M=M_{f}(a,b):=\max_{t\in E}f''(t)\) exist.

These numbers will play an important role in the sequel.

2 Results and proofs

We begin with an improved variant of the Hermite–Hadamard inequality.

Lemma 2.1

Let \(f: I\subset \mathbb{R}\to \mathbb{R}\) be a convex function on an interval I and \(a,b\in I\).

Then

$$ f\biggl(\frac{a+b}{2}\biggr)\le \frac{1}{b-a} \int _{a}^{b} f(t)\,dt\le \frac{1}{2}\biggl[ \frac{f(a)+f(b)}{2}+f\biggl(\frac{a+b}{2}\biggr)\biggr]. $$
(2.1)

It is shown in [4] that this improvement is best possible of the form

$$ p \frac{f(a)+f(b)}{2}+ q f\biggl(\frac{a+b}{2}\biggr);\quad p,q\ge 0, p+q=1. $$

Our first main result is the following.

Theorem 2.2

Let \(g\in C^{(2)}(E)\) and \(p+q=r+s=1\), \(0\le p\), \(r\le 1/2\).

Then

$$\begin{aligned}& r \frac{g(a)+g(b)}{2} + s g\biggl(\frac{a+b}{2}\biggr)+\bigl(sm-r(m+M)\bigr) \frac{(b-a)^{2}}{24} \\& \quad \le \frac{1}{b-a} \int _{a}^{b} g(t)\,dt \\& \quad \le p \frac{g(a)+g(b)}{2} + q g\biggl(\frac{a+b}{2}\biggr)+\bigl(q M-p(m+M)\bigr) \frac{(b-a)^{2}}{24}, \end{aligned}$$

with \(m:=\min_{x\in [a,b]}g''(x)\), \(M:=\max_{x\in [a,b]}g''(x)\), and \(E:=[a,b]\).

Proof

For given \(g\in C^{(2)}(E)\), define an auxiliary function f by \(f(t):= g(t)-m t^{2}/2\). Since \(f''(t)=g''(t)-m\ge 0\), we find out that f is a convex function on E. Therefore, applying the form of Hermite–Hadamard inequality given by (2.1), we obtain

$$\begin{aligned}& g\biggl(\frac{a+b}{2}\biggr)-\frac{m}{2}\biggl(\frac{a+b}{2} \biggr)^{2} \\& \quad \le \frac{1}{b-a} \int _{a}^{b} g(t)\,dt -\frac{m}{2} \frac{b^{3}-a^{3}}{3(b-a)} \\& \quad \le\frac{1}{2}\biggl[\frac{g(a)+g(b)}{2}-\frac{m}{2}\biggl( \frac{a^{2}+b^{2}}{2}\biggr)+g\biggl( \frac{a+b}{2}\biggr)-\frac{m}{2} \biggl(\frac{a+b}{2}\biggr)^{2}\biggr], \end{aligned}$$

that is,

$$ \begin{aligned} g\biggl(\frac{a+b}{2}\biggr)+\frac{m}{24}(b-a)^{2} &\le \frac{1}{b-a} \int _{a}^{b} g(t)\,dt \\ &\le \frac{1}{2}\biggl[ \frac{g(a)+g(b)}{2}+g\biggl(\frac{a+b}{2}\biggr)\biggr]-\frac{m}{48}(b-a)^{2}. \end{aligned} $$
(2.2)

On the other hand, taking the auxiliary function f as \(f(t)=Mt^{2}/2-g(t)\), we see that it is also convex on E.

Applying Lemma 2.1 again, we obtain

$$ \begin{aligned} \frac{1}{2}\biggl[\frac{g(a)+g(b)}{2}+g\biggl( \frac{a+b}{2}\biggr)\biggr]-\frac{M}{48}(b-a)^{2} &\le \frac{1}{b-a} \int _{a}^{b} g(t)\,dt \\ &\le g\biggl(\frac{a+b}{2} \biggr)+ \frac{M}{24}(b-a)^{2}. \end{aligned} $$
(2.3)

Now, for arbitrary \(\alpha , \beta \ge 0\), \(\alpha +\beta =1\), multiplying the right-hand sides of inequalities (2.2) and (2.3) with α and β respectively, we get

$$\begin{aligned} \frac{1}{b-a} \int _{a}^{b} g(t)\,dt &\le \frac{\alpha }{2} \biggl[ \frac{g(a)+g(b)}{2}+g\biggl(\frac{a+b}{2}\biggr)\biggr]- \frac{m}{24}(b-a)^{2}]\\ &\quad {}+\beta \biggl[g\biggl( \frac{a+b}{2} \biggr)+\frac{M}{24}(b-a)^{2}\biggr] \\ &=\frac{\alpha }{2}\biggl(\frac{g(a)+g(b)}{2}\biggr)+(\beta +\alpha /2)g\biggl( \frac{a+b}{2}\biggr)+(\beta M-\alpha m/2)\frac{(b-a)^{2}}{24}. \end{aligned}$$

Similar treating of the left-hand sides of (2.2) and (2.3) involving numbers \(\gamma , \delta \ge 0\), \(\gamma +\delta =1\), gives

$$ \frac{1}{b-a} \int _{a}^{b} g(t)\,dt\ge \frac{\gamma }{2}\biggl( \frac{g(a)+g(b)}{2}\biggr)+(\delta +\gamma /2)g\biggl(\frac{a+b}{2}\biggr)+( \delta m- \gamma M/2)\frac{(b-a)^{2}}{24}. $$

Denoting \(\gamma /2=r\), \(\delta +\gamma /2=s\); \(\alpha /2=p\), \(\beta +\alpha /2=q\), we obtain the required result. □

There are plenty of applications of Theorem 2.2. For instance, an improvement of the assertion from Lemma 2.1 is given in the following.

Corollary 2.3

Let \(f\in C^{(2)}(E)\). Then

$$ f\biggl(\frac{a+b}{2}\biggr)+m\frac{(b-a)^{2}}{24}\le \frac{1}{b-a} \int _{a}^{b} f(t)\,dt \le \frac{1}{2}\biggl[ \frac{f(a)+f(b)}{2}+f\biggl(\frac{a+b}{2}\biggr)\biggr]-m \frac{(b-a)^{2}}{48}. $$

Proof

Putting \(r=0\), \(s=1\); \(p=q=1/2\), we get the desired result. Note that \(m\ge 0\) if f is a convex function on E. □

Of great importance in the theory of numerical integration is the so-called Simpson’s rule (cf. [26]).

Lemma 2.4

Let \(f\in C^{(4)}(E)\). Then

$$ \frac{f(a)+f(b)}{6}+\frac{2}{3}f\biggl(\frac{a+b}{2}\biggr)- \frac{1}{b-a} \int _{a}^{b} f(t)\,dt=\frac{f^{(4)}(\xi )}{2880}(b-a)^{4}, \quad a< \xi < b. $$

Therefore, we obtain at once an estimation

$$ \frac{n}{2880}(b-a)^{4}\le \frac{f(a)+f(b)}{6}+\frac{2}{3}f \biggl( \frac{a+b}{2}\biggr)-\frac{1}{b-a} \int _{a}^{b} f(t)\,dt\le \frac{N}{2880}(b-a)^{4}, $$

where \(n=n_{f}(a,b):=\min_{t\in E}f^{(4)}(t)\) and \(N=N_{f}(a,b):=\max_{t\in E}f^{(4)}(t)\).

There is a problem how to apply Simpson’s rule if \(f\notin C^{(4)}(E)\). A possible answer for twice differentiable functions is given in the following.

Corollary 2.5

Let \(f\in C^{(2)}(E)\). Then

$$ \biggl\vert \frac{f(a)+f(b)}{6}+\frac{2}{3}f\biggl(\frac{a+b}{2} \biggr)-\frac{1}{b-a} \int _{a}^{b} f(t)\,dt \biggr\vert \le \frac{1}{72}(M-m) (b-a)^{2}. $$

Proof

Putting in Theorem 2.2\(r=p=1/3\); \(s=q=2/3\), we obtain

$$ -(M-m)\frac{(b-a)^{2}}{72}\le \frac{f(a)+f(b)}{6}+\frac{2}{3}f\biggl( \frac{a+b}{2}\biggr)-\frac{1}{b-a} \int _{a}^{b} f(t)\,dt\le (M-m) \frac{(b-a)^{2}}{72}, $$

and the proof follows. □

Another refinement of the Hermite–Hadamard inequality is given in the following.

Corollary 2.6

For \(f\in C^{(2)}(E)\), denote \(M/m=t\ge 1\). Then

$$ \begin{aligned} \frac{1}{t+2}\frac{f(a)+f(b)}{2}+\frac{t+1}{t+2}f\biggl(\frac{a+b}{2} \biggr)&\le \frac{1}{b-a} \int _{a}^{b} f(t)\,dt\\ &\le \frac{t}{2t+1} \frac{f(a)+f(b)}{2}+\frac{t+1}{2t+1}f\biggl(\frac{a+b}{2}\biggr). \end{aligned} $$

Proof

Applying Theorem 2.2 with \(r=1/(t+2)\), \(s=(t+1)/(t+2)\); \(p=t/(2t+1)\), \(q=(t+1)/(2t+1)\), we obtain the proof since in this case

$$ sm-r(m+M)=qM-p(m+M)=0. $$

 □

The restriction \(0\le r\), \(p\le 1/2\) is unavoidable in the proof of Theorem 2.2. Nevertheless, the following assertion gives an integral representation which absolutely enlarges the range of p, q.

Lemma 2.7

For \(\phi \in C^{(2)}(E)\) and arbitrary p, q; \(p+q=1\), we have the identity

$$ p \frac{\phi (a)+\phi (b)}{2}+ q \phi \biggl(\frac{a+b}{2}\biggr)-\frac{1}{b-a} \int _{a}^{b} \phi (t)\,dt= \frac{(b-a)^{2}}{16} \int _{0}^{1} t(2p-t) \bigl( \phi ''(x)+\phi ''(y)\bigr)\,dt, $$

where \(x:=a\frac{t}{2}+b(1-\frac{t}{2})\), \(y:=b\frac{t}{2}+a(1-\frac{t}{2})\).

It is not difficult to prove the above relation by a double partial integration of its right-hand side.

Hence, our second main result is given in the following.

Theorem 2.8

Let \(\phi \in C^{(2)}(E)\) and, for \(p\in \mathbb{R}\), denote

$$ p \frac{\phi (a)+\phi (b)}{2}+ (1-p) \phi \biggl(\frac{a+b}{2}\biggr)- \frac{1}{b-a} \int _{a}^{b} \phi (t)\,dt:=T_{\phi }(a,b;p). $$

Then

$$ 1. \quad (3p-1)\frac{(b-a)^{2}}{24}m\le T_{\phi }(a,b;p)\le (3p-1) \frac{(b-a)^{2}}{24}M $$

for \(p\ge \frac{1}{2}\);

$$ 2. \quad \bigl(A(p) m-B(p) M\bigr)\frac{(b-a)^{2}}{6}\le T_{\phi }(a,b;p) \le \bigl(A(p) M-B(p)m\bigr)\frac{(b-a)^{2}}{6}, $$

with \(A(p)=p^{3}\), \(B(p)=(p+1)(p-1/2)^{2}\), and \(0< p <\frac{1}{2}\);

$$ 3. \quad (3p-1)\frac{(b-a)^{2}}{24}M\le T_{\phi }(a,b;p)\le (3p-1) \frac{(b-a)^{2}}{24}m $$

for \(p \le 0\).

Proof

We prove only the right-hand side inequalities. The other proofs are analogous.

1. In the case \(p\ge 1/2\), \(0\le t\le 1\), note that \(2p-t\ge 0\); \(\phi ''(x)\), \(\phi ''(y)\le M\). Hence, by Lemma 2.7, we get

$$\begin{aligned} T_{\phi }(a,b;p)&=\frac{(b-a)^{2}}{16} \int _{0}^{1} t(2p-t) \bigl(\phi ''(x)+ \phi ''(y)\bigr)\,dt \le 2M\frac{(b-a)^{2}}{16} \int _{0}^{1} t(2p-t)\,dt \\ &= M\biggl(p-\frac{1}{3}\biggr)\frac{(b-a)^{2}}{8}. \end{aligned}$$

2. For \(0< p<1/2\), write

$$\begin{aligned} T_{\phi }(a,b;p)&=\frac{(b-a)^{2}}{16} \int _{0}^{2p} t(2p-t) \bigl(\phi ''(x)+ \phi ''(y)\bigr)\,dt\\ &\quad {}- \frac{(b-a)^{2}}{16} \int _{2p}^{1} t(t-2p) \bigl(\phi ''(x)+ \phi ''(y)\bigr)\,dt \\ &\le 2M \frac{(b-a)^{2}}{16} \int _{0}^{2p} t(2p-t)\,dt-2m \frac{(b-a)^{2}}{16} \int _{2p}^{1} t(t-2p)\,dt\\ &=\frac{(b-a)^{2}}{8}\biggl[ \frac{4p^{3}}{3}M-\biggl(\frac{1}{3}-p +\frac{4p^{3}}{3}\biggr)m \biggr], \end{aligned}$$

which is equivalent to statement 2.

3. In the case \(p\le 0\), we have \(2p-t\le 0\); \(\phi ''(x)\), \(\phi ''(y)\ge m\). Therefore,

$$\begin{aligned} T_{\phi }(a,b;p)&\le 2m\frac{(b-a)^{2}}{16} \int _{0}^{1} t(2p-t)\,dt \\ &= m\biggl(p-\frac{1}{3}\biggr)\frac{(b-a)^{2}}{8}. \end{aligned}$$

 □

Remark 2.9

The approximations from Theorems 2.2 and 2.8 can be compared if \(r=p\), \(s=q\); \(0\le p\le 1/2\). It is not difficult to see that they coincide for \(p=0\) and \(p=1/2\). In other cases the second approximation is better.

For example, if \(p=1/3\), we obtain an improvement of Corollary 2.5, i.e., another estimation of Simpson’s rule for twice differentiable functions.

Corollary 2.10

Let \(f\in C^{(2)}(E)\). Then

$$ \biggl\vert \frac{f(a)+f(b)}{6}+\frac{2}{3}f\biggl(\frac{a+b}{2} \biggr)-\frac{1}{b-a} \int _{a}^{b} f(t)\,dt \biggr\vert \le \frac{1}{162}(M-m) (b-a)^{2}. $$

We conjecture that the constant \(1/162\) is best possible.