# Maximizing a convex quadratic function in CVX and Matlab

I understand that a convex function can not be maximized as there is no such value. However, consider the following function:

$$\begin{array}{ll} \text{maximize} & 3x^2 + 5y^2\\ \text{subject to} & x+y=12\\ & x,y\geq0\end{array}$$

But executing it in CVX and Matlab I get the following error:

Disciplined convex programming error:   Cannot maximize a(n) convex expression.


But as I have specified the boundaries, should I not get some maximized value in this range?

• CVX only solves convex optimization problems, and maximizing a convex function is not a convex optimization problem. In a convex optimization problem you minimize a convex function over a convex set. – littleO Jul 19 '16 at 12:41
Write $y = 12 - x$. From $x,y \geq 0$, we get $0 \leq x \leq 12$. The objective function becomes
$$3 x^2 + 5 (12 - x)^2 = 720 - 2 x^2$$
Hence, the maximum is $720$, which is attained at $(x,y) = (0,12)$.