<s>[INST] 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).
 [/INST] 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$
</s>