Question:- Find the maximum value of $(x+2) \cdot (12-3x)$. $x$ is a Real number.
The solution given in the textbook applies AM-GM to solve this
$$3 \cdot (x+2) \cdot (4-x)$$
Now, $x+2 = a$ and $4-x = b$
$a+b=6$
Objective to maximize $3 \cdot a \cdot b$
by AM-GM inequality,
$$\frac{a+b}{2} \geq \sqrt{ab}$$
$$a \cdot b \leq 9$$
Therefore $3 \cdot a \cdot b \leq 27$
But is the solution correct? as we know that while applying AM-GM, the terms should be positive real but $a$ and $b$ are not positive for every $x$ as Real number , if I am correct the range of $(-\infty,-2)$ to $(4, \infty)$ should be given for $a$ and $b$ to be both positive and then apply AM-GM, please suggest if some other way is possible too to solve this.
You are right, there's something missing, but we can fix the argument by restricting the domain.
First and foremost, $f(x)<0$ for $x>4\lor x<-2$ and $f(x)\ge 0$ for $-2\le x\le 4$, therefore for the purpose of finding the maximum value we only need to consider $-2\le x\le 4$. For those values of $x$, we have that $x+2\ge 0$ and $4-x\ge 0$, therefore the discussion carries on correctly.
The final step is missing: we have proved that, for $-2\le x\le4$, $$\sqrt{\frac13 f(x)}=GM(x)\le AM(x)=3$$ We still need to prove that there is some $x\in [-2,4]$ for which $AM(x)=GM(x)$. As we know, this is the case if and only if $a(x)=b(x)$, which is fortunately for $x=1\in [-2,4]$.