Finding the maximum of $ \sqrt{x + 27} + \sqrt{13 - x} + \sqrt{x}$ for $0\le x \le 13$ using the Cauchy-Schwarz inequality gives two different answers I am trying to find the maximum of the expression $$\sqrt{x+27} + \sqrt{13-x} + \sqrt{x} \qquad \text{for } 0 \le x \le 13.$$
Clearly using Cauchy is the way to go here, so I tried $$((x + 27) + 2(13-x) + x)(1 + 0.5 + 1) = (x + 27 + 26 - 2x + x)\frac 52 = \frac{265}{2} \ge (\sqrt{x+27} + \sqrt{13-x} + \sqrt{x})^2.$$
But then, we also have that $$\left( 1 + \frac{1}{3} + \frac{1}{2} \right) ((x + 27) + 3(13 - x) + 2x) = 121 \ge (\sqrt{x + 27} + \sqrt{13 - x} + \sqrt{x})^2.$$
Clearly, these are two different values. What gives? How could I “guess” the correct combination of scalars that lead to the correct answer? (as the first attempt is incorrect).
 A: How to "guess":
The form is making something nice, so I try to guess something to make $x+27,13-x,x$ are all squares, and indeed $x=9$, son the previous three numbers are $6^2,2^2,3^2$. So, this can have
$$(\sqrt{x+27} + \sqrt{13-x} + \sqrt{x})^2\le(6+2+3)(\frac{x+27}6+\frac{13-x}2+\frac{x}3)=121$$
So we can get $\sqrt{x+27} + \sqrt{13-x} + \sqrt{x}\le 11$, equality taken if $x=3$
The correct values will be yielded when the equality of Cauchy-Schwartz holds.
How to really calculate:
I am going to try this for Cauchy-Schwartz:
$$(\frac 1u+1+\frac 1{1-u})(u(x+27)+(13-x)+(1-u)x)\ge(\sqrt{x+27} + \sqrt{13-x} + \sqrt{x})^2$$
This holds if
$$(x+27)u^2=13-x=x(1-u)^2$$
Solving for $x$ we have
$$x=\frac{13}{1+(1-u)^2}$$
Using $1+\frac{27}{x}=\frac{x+27}{x}=\frac{(1-u)^2}{u^2}$ we have
$$1+27(\frac{1+(1-u)^2}{13})=\frac{(1-u)^2}{u^2}$$
Clearing the denominators, we have
$$27u^4-54u^3+54u^2+26u-13=0$$
Factoring (in fact, try the rational roots first) gives
$$(3u-1)(9u^3-15u^2+13u+13)=0$$
And the latter $9u^3-15u^2+13u+13$ has no positive real roots. So, you can set $u=1/3$ and yield the same result.
By the way, both Cauchy-Schwartz and the derivative will give you the following inequality:
$$\frac{1}{\sqrt x}+\frac{1}{\sqrt{27+x}}=\frac{1}{\sqrt{13-x}}$$
This is equivalent to
$$\frac{1}{x^2}+\frac{1}{{(27+x)^2}}+\frac{1}{{(13-x)^2}}=\frac{1}{x{(27+x)}}+\frac{1}{(13-x)x}+\frac{1}{(27+x)(13-x)}$$
And you can solve this equation, but I don't want to present it here.
A: Your approach is fine. You start by writing $$(\sqrt{x+27}+\sqrt{13-x}+\sqrt{x})^2\le[(x+27)+a(13-x)+bx]\left(1+\frac1a+\frac1b\right)$$
The factors $a$ and $b$ are to be determined. Since you want the right hand side to be an absolute maximum, that does not depend on $x$, you have
$$1-a+b=0$$
You also know that the Cauchy inequality transforms into an equality if the elements of the two sums on the right hand side are proportional:
$$\frac{x+27}1=\frac{a(13-x)}{1/a}=\frac{bx}{1/b}$$
We can simplify this:
$$x+27=a^2(13-x)\\x+27=b^2x$$
Now find $x$ in terms of $b$, plug it into the equation for $a$ in terms of $x$
$$27=(b^2-1)x\\a^2=\frac{x+27}{13-x}=\frac{27/(b^2-1)+27}{13-27/(b^2-1)}=\frac{27(b^2-1)+27}{13(b^2-1)-27}=\frac{27b^2}{13b^2-40}$$
Finally use the first condition (maximum not dependent on $x$):
$$a^2=1+2b+b^2=\frac{27b^2}{13b^2-40}\\13b^4+26b^3-54b^2-80b-40=0$$
From the rational root theorem, you can see that $b=2$ is a good choice. Then $a=3$
