How to prove a known inequality from a book The following inequality is from page 125 of D.S. Mitrinovic, J. Pecaric, A.M. Fink, Classical and new inequalities in analysis, Kluwer
Academic Publishers, Dordrecht/Boston/London, 1993.
If $a_i>0$, $b_i>0$ for $i=1,\cdots, n$ and $A=\frac{\max a_k}{\min a_k}$, $B=\frac{\max b_k}{\min b_k}$ with $\frac{1}{p}+\frac{1}{q}=1$, $p>1$. Then
$$\left(\sum\limits_{i=1}^na_i^p\right)^{1/p}\left(\sum\limits_{i=1}^nb_i^q\right)^{1/q}\le \frac{1}{p^{1/p}}\frac{1}{q^{1/q}}\frac{A^pB^q-1}{(BA^p-A)^{1/q}(AB^q-B)^{1/p}}\sum\limits_{i=1}^na_ib_i$$
My question is how to prove this inequality (The book does not contain a proof). Though this is a known result, I am expecting different proofs from interested readers. Hopefully this does not go far away from the principle of this forum.
Added There are already satisfactory answers below, but let me add one question 
If $a_{1i}>0$, $a_{2i}>0, \cdots, a_{ri}>0$   for $i=1,\cdots, n$ and $A_1=\frac{\max a_{1k}}{\min a_{1k}}$, $A_2=\frac{\max a_{2k}}{\min a_{2k}},\cdots, A_r=\frac{\max a_{rk}}{\min a_{rk}}$ with $\sum\limits_{i=1}^r\frac{1}{p_i}=1$, $p_i>1$. Then $$\left(\sum\limits_{i=1}^na_{1i}^{p_1}\right)^{1/p_1}\left(\sum\limits_{i=1}^na_{2i}^{p_2}\right)^{1/p_2}\cdots \left(\sum\limits_{i=1}^na_{ri}^{p_r}\right)^{1/p_r}\le M(A_1,\cdots, A_r)\sum\limits_{i=1}^na_{1i}a_{2i}\cdots a_{ri}$$
What would $M(A_1,\cdots, A_r)$ be? 
 A: sorry, it is not full proof, but too long for comment
By scaling argument, we may suppose $a_i\in [1,A]$, $b_i\in [1,B]$.
Note that the difference LHS-RHS is convex function in each $a_i$ and $b_i$ (the function $f(x)=(x^p+M)^{1/p}$ for constants $M>0$ and $p>1$ is convex on $(0,\infty)$). Hence it maximum on a closed segment is attained on one of endpoints. So, without loss of generality $a_i\in \{1,A\}, b_i\in\{1,B\}$. Also, for fixed arrays of $a_i$'s and $b_i$'s the RHS is minimal if large $a$'s are coupled with small $b$'s. It reduces our problem to the 2-parametric problem: number of ones in arrays of $a_i$'s, $b_i$'s. I guess that in the optimal situation number of ones between $a_i$'s equals the number of $B$'s between $b_i$'s, but I do not see any clear proof.
A: It is less or more the same as GH's proof, but let me explain how may one naturally come to such argument even without a priori knowing the constant. I do not refer here to other comments.
At first, by standard scaling argument, $a_i\in [1,A]$, $b_i\in [1,B]$. Let's try to estimate $\sum a_ib_i$ from below via $\sum a_i^p$ and $\sum b_i^q$. The easiest way is by summing up inequalities $a_ib_i\geq \alpha a_i^p+\beta b_i^q$ for some positive constants $\alpha$, $\beta$. This inequality may be rewritten as $1\geq \alpha x+\beta x^{-q/p}$, where $x=a_i^{p-1}/b_i$. Since the RHS is convex in $x$, it suffices to check for maximal and minimal possible values of $x$, which corresponds to minimal $a_i$ and maximal $b_i$ or viceversa. In other words, we need to check two inequalities $B\geq \alpha+\beta B^q$, $A\geq \alpha A^p+\beta$, which correspond to pairs $(a_i,b_i)=(1,B)$ and $(a_i,b_i)=(A,1)$. It is natural to take $\alpha$, $\beta$ so that both inequalities are equalities. This is $2\times 2$ system, we solve it to find $\alpha=(AB^q-B)/(B^qA^p-1)$, $\beta=(BA^p-A)/(B^qA^p-1)$. Now it remains to get 
$$
\sum a_ib_i\geq \alpha\sum a_i^p+\beta\sum b_i^q\geq (\alpha p)^{1/p}(\beta q)^{1/q}
(\sum a_i^p)^{1/p}(\sum b_i^q)^{1/q}.$$
A: Here's how one can finish off Fedor's solution. We have $1\le k,r \le n$ and $A,B \geq 1$. We have to prove
$$\left(p(AB^q-B)(n-k+kA^p)\right)^{1/p}\left(q(BA^p-A)(n-r+rB^p)\right)^{1/q}\le (A^pB^q-1)S$$ where $S=Ak+Br+(n-k-r)$ when $n\geq k+r$, and $S=B(n-k)+A(n-r)+AB(k+r-n)$ when $k+r\geq n$. 
Using Young's inequality $x^{1/p}y^{1/q}\le \frac{x}{p}+\frac{y}{q}$ on LHS (and after simplifying the expression) we reduce to proving
$$(A^p-A)(B^q-B)\geq (A-1)(B-1)$$ in the case $n\geq k+r$, and 
$$(A-1)(B-1)\geq (1-\frac{1}{A^{p-1}})(1-\frac{1}{B^{q-1}})$$ in the other case. 
The first one follows from Bernoulli's inequality, $A^p-A=(1+(A-1))^p-A\geq 1+p(A-1)-A=(p-1)(A-1)$, and similarly $B^q-B\geq (q-1)(B-1)$, now notice that $(p-1)(q-1)=1$.
The second case follows from the arithmetic-geometric mean, we have that $(p-1)A+\frac{1}{A^{p-1}}\geq p$ so $1-\frac{1}{A^{p-1}}\le (p-1)(A-1)$, and similarly for $B$, now just take the product.
A: The following proof was inspired by Fedor Petrov's and Gjergji's Zaimi's argument, but it is simpler.
By a scaling argument we may assume $a_i\in[1,A]$, $b_i\in[1,B]$.
The inequality can be rewritten as
$$x^{1/p}y^{1/q} \leq (A^pB^q-1)\sum_{i=1}^n a_ib_i,$$
where
$$x:=p(AB^q-B)\sum_{i=1}^na_i^p\qquad\text{and}\qquad
y:=q(BA^p-A)\sum_{i=1}^nb_i^q.$$
By Young's inequality $x^{1/p}y^{1/q}\le \frac{x}{p}+\frac{y}{q}$, the above follows from
$$\frac{x}{p}+\frac{y}{q}\leq (A^pB^q-1)\sum_{i=1}^n a_ib_i.$$
Therefore it suffices to show, for any $i$,
$$(AB^q-B)a_i^p+(BA^p-A)b_i^q\leq (A^pB^q-1)a_ib_i.$$
The difference LHS-RHS is a convex function of $a_i$ and $b_i$, hence we can assume that 
$a_i\in\{1,A\}$, $b_i\in\{1,B\}$. The inequality becomes an identity when exactly one of $a_i$ and $b_i$ equals 1, while in the other two cases it is equivalent to
$$(1-A^{1-p})(1-B^{1-q})\leq(A-1)(B-1)\leq (A^p-A)(B^q-B).$$
By convexity again,
$$1-A^{1-p}\leq(p-1)(A-1)\leq A^p-A,$$
$$1-B^{1-q}\leq(q-1)(B-1)\leq B^q-B,$$
whence the required inequality follows upon noting that $(p-1)(q-1)=1$.
A: This is a typical question about a convex envelope. I doubt that there is a nice answer for $M$ in high dimensions but let me tell you what that constant is going to be. 
Consider the function $B(x_{1},x_{2},\ldots, x_{n})=x_{1}^{1/p_{1}}x_{2}^{1/p_{2}}\cdots x_{n}^{1/p_{n}}$ on the parallelepiped $\Omega=[\ell_{1},r_{1}]\times [\ell_{2},r_{2}]\times\ldots\times[\ell_{n},r_{n}]$ such that $0<\ell_{i}\leq r_{i}$. Let $B^{convex}(x_{1},\ldots, x_{n})$ be a convex envelope of $B$ on $\Omega$. Since $B$ is a concave function  the graph of $B^{convex}$  is the lower boundary of the convex hull of the points  $(c_{i},B(c_{i}))$ where $c_{i}$ are the corners (extreme points) of the parallelepiped $\Omega$ (in total there are $2^{n}$ points). Then $M$ is the  minimal number such that $M\cdot  B^{convex} \geq B$ on $\Omega$. This follows from the observation that the the following function
$$
H(u_{1},u_{2},\ldots,u_{n})=\inf_{f_{1},\ldots, f_{n}}\left\{\int_{0}^{1}B(f_{1}(x),\ldots, f_{n}(x)) dx, \; \int_{0}^{1} f_{i}=u_{i},\;  \ell_{i}\leq f_{i}\leq r_{i}, \; i=1..n\right\}
$$ 
is the maximal convex function on $\Omega$ with the obstacle $H\leq  B$ on $\Omega$ (i.e., $H=B^{convex}$)
Thus it follows that 
$$
M\cdot \int_{0}^{1}B(f_{1}(x),\ldots, f_{n}(x)) dx \geq M\cdot B^{convex}\left(\int_{0}^{1} f_{1},...,\int_{0}^{1} f_{n}\right) \geq  B\left(\int_{0}^{1}f_{1},\ldots, \int_{0}^{1} f_{n}\right)
$$ 
All these inequalities are sharp. In your case $A_{i} = \frac{r_{i}}{\ell_{i}}$.. 
