I was asked to solve the following problem:
Let $a$ and $b$ be two positive real numbers with $a+b=20$. Find the maximum possible value of $a^2b$.
I first approached the problem in this way:
Approach 1: From AM-GM inequality we have $$\frac{a+a+b}{3}\geq \sqrt[3]{a^2b}\\ \implies a^2b\leq \left(\frac{2a+b}{3}\right)^3$$ The maximum is achieved when the equality holds, that is when $a=b=10$. Hence, $\max(a^2b)=\left(\frac{30}{3}\right)^3=1000$.
It looked nice to me until I noticed that if $a=11$ and $b=9$, then $a^2b=1089>1000$. Indeed $1000$ is not the maximum and I found that in the following approach:
Approach 2: Since $b=20-a$, let $f(a)=a^2(20-a)$. Now $f'(a)=40a-3a^2$ and $f''(a)=40-6a$. Maximum is achieved when $40a-3a^2=0\implies a=\frac{40}{3}$. Hence $\max(a^2b)=\frac{32000}{27}>1000$.
Now my question is why am I getting a wrong answer in my first approach. I don't find any reason for which that is wrong. Moreover, it is more natural to me to use known inequalities like AM-GM before using a calculus approach.
(I'm pretty sure that this kind of problem has been posted before in MSE. But as I want to know what is wrong in my solution, this is possibly not a duplicate.)
The issue is that your upper bound derived from AMGM inequality depends on your variables $a,b$. Therefore the equality condition does not actually inform you about the maximal value of $a^2b$.
For example, if $f(a,b)\leq C$ where $C$ is constant and you know the equality condition, then you know the condition for the maximum $C$ to be attained. If instead $f(a,b)\leq g(a,b)$, then the equality condition only tells you when $f(a,b)=g(a,b)$, not when $f(a,b)$ takes a maximum. The crucial thing is that the RHS of the inequality changes too.