# Complexity of Determining Convexity of Functions

This wasn’t really my week in terms of results, but I decided to post what I was up to anyway. I always try to solve my problems without help from other sources. Sometimes I make up my own problems that I think shouldn’t be too hard and try to solve those by myself. Sometimes that works, but sometimes I am very incorrect about the difficulty of the problem.

I mentioned previously that I’m in CVX 101, an online class on convex optimization. The homework, unsurprisingly, involves using their software (called CVX, based in Matlab) to solve convex optimization problems. I unfortunately did not bother to read the users manual very carefully before attempting some optimization problems. I got a little frustrated because it wouldn’t let me use something like ${x^2 + xy + y^2}$ as an objective function, even though that’s clearly convex. If I had actually read the users guide I would have known that CVX only allows objective functions constructed from a pre-specified set of rules, and functions like the one I was trying didn’t fall into that category. For example in this problem I rewrote the function as ${\tfrac{1}{2}(x+y)^2 + \tfrac{1}{2}x^2 + \tfrac{1}{2}y^2}$, which is a little inconvenient but CVX accepts since the sum of squares of affine functions is always convex. I asked myself why they would make life so difficult, and I had a guess. I was pretty sure that determining the convexity of a polynomial in ${n}$ variables was NP-hard.

Doing anything with multivariate polynomials is hard in my experience. For example, determining whether a polynomial in ${n}$ variables has at least one real zero is NP-hard. We can reduce from ${3}$-SAT. One of my professors insisted on stating decision problems in the following manner and I got used to it, so bear with me. Here’s the statement for ${3}$-SAT:

INSTANCE: A boolean formula in ${3}$-CNF form with ${n}$ variables
QUESTION: Is the formula satisfiable?

And here’s the statement of the multivariate polynomial problem:

INSTANCE: A polynomial ${f: \mathbb{R}^n \rightarrow \mathbb{R}}$
QUESTION: Does ${f}$ have a zero on ${\mathbb{R}^n?}$

For a clause with literals ${x_i}$, ${x_j}$, ${\neg x_k}$ map it to a term in a polynomial ${[(y_i)(y_j)(1-y_k)]^2}$. Map the rest of the clauses appropriately, and let’s call the polynomial we formed ${f(Y)}$. We see that ${f}$ has a zero if and only if our instance of ${3}$-SAT is satisfiable. If ${3}$-SAT has a satisfying assignment and ${x_i}$ is true in that assignment, let ${y_i = 0}$, otherwise let ${y_i = 1}$. Clearly a satisfying assignment produces a zero of ${f}$. If ${f}$ has a zero then all the terms are zero because they’re all nonnegative, and a term is zero if and only if one of the components is zero, so one of the variables is zero or one. Reverse the mapping and we have a satisfying assignment. A last detail is that if we have a variable that isn’t zero or one in the root of ${f}$, it doesn’t matter in the assignment so we can ignore it.

I’ve never gotten any real verification that thinking like this is a good idea, but when I see a reduction like that I generally think of the problem we reduced to as being “much harder” than the first problem. In this case we could have made all kinds of restrictions to ${f}$; we only needed a polynomial of degree ${6}$ or less and a very specific type of polynomial. Well, ${3}$-SAT is already strongly NP-hard so determining zeroes in multivariate polynomials must be really, really hard, right? Of course in this case we know that the multivariate polynomial problem is in NP and so it’s capped in difficulty, so it sort of implies that going from the restricted types of polynomials to the rest of polynomials is actually easy.

Anyway, back to the convexity problem. Here’s a statement:

INSTANCE: A polynomial ${f: \mathbb{R}^n \rightarrow \mathbb{R}}$
QUESTION: Is ${f}$ convex in ${\mathbb{R}^n}$?

If ${f}$ is degree ${1}$, ${2}$, or ${3}$ this is pretty simple. If it’s degree one the answer is always YES because it’s affine, so convex. If it’s degree three then the answer is always NO. We need only consider the cubic terms. If we find a term of the form ${x_i^3}$ then taking the derivative with respect to ${x_i}$ twice will make it linear in ${x_i}$, and so a diagonal element of the Hessian can be made negative, which implies that it’s not positive semidefinite by the extended version of Sylvester’s criterion. The same arguments works for terms of the form ${x_i^2x_j}$. If all the cubic terms are of the form ${x_ix_jx_k}$ then all diagonal elements are zero, and the principal minor using rows and columns ${i}$ and ${j}$ is negative since it’s ${0}$ on the diagonal and ${x_k}$ on the off-diagonal. As for degree two polynomials, we can just write it in its quadratic form ${x^TAX}$ plus some affine stuff. Then ${f}$ is convex iff ${A}$ is positive semidefinite, which we can either test for with Sylvester’s Criterion or old-fashioned high school math, row reduction. I’m not actually sure which is faster but they’re both polynomial time.

At this point I was feeling pretty good. I had knocked out a few cases, and all that remained was showing this for even degree ${4}$ or higher polynomials. In fact if you can show that deciding the convexity of a degree ${4}$ polynomial is hard then you can just tack on a term like ${x_{n+1}^{2s}}$ for some ${s > 2}$ which is of course convex and you’ll show that deciding the convexity of a higher degree polynomial is also NP-hard. I tried a bunch of stuff but nothing I did really got anywhere. After a few days I decided to give in and started googling for some answers.

It turns out that this is was solved somewhat recently. My guess that determining convexity is hard was correct. It’s proven here by Ahmadi, Olshevsky, Parrilo, and Tsitsiklis [1]. The general outline is that determining non-negativity of biquadratic forms, which are expressions of the form ${b(x,y) = \sum_{i \leq j, k \leq l}x_ix_jy_ky_l}$ where ${x = (x_1, \cdots, x_n)}$ and ${y = (y_1 \cdots, y_m)}$ is NP-hard, as shown in [2]. That reduction uses Clique in [3]. In general I find it kind of difficult to make the jump from discrete structures to continuous objects in reductions. The actual paper is clear and shockingly easy to read, so I won’t summarize it here, but I recommend it. The authors in [1] showed the reduction from the biquadratic form problem to convexity, as well as a bunch of other results: the hardness of determining strict and strong convexity and a polynomial time algorithm for determining quasiconvexity.

At any rate, my plans for proving that determining the convexity of quartics is NP-hard were squashed, but I figured relaxing the problem to rational functions was an acceptable concession. After all, you can easily type a rational function into Matlab, so it’s still a concern for the coders of CVX. After a little bit I realized that there was a somewhat dirty way to do this problem as a reduction from the problem of determining whether a polynomial in ${n}$ variables has a zero. As far as Matlab is concerned, a function like ${\tfrac{x^2}{x}}$ can’t be evaluated at ${x=0}$. Using this you can just take a polynomial in ${n}$ variables and determine whether ${\tfrac{f(X)}{f(X)}}$ is convex, since if it has no zeroes then the polynomial is ${1}$ which is convex and if it has one or more zeroes then it’s not convex according to Matlab because the domain isn’t even convex.

I don’t really like that reduction, so I kept searching. I also relaxed the problem even more, allowing myself to determine the convexity of functions with exponentials and logarithms. Unfortunately I am still on the hunt. If I do manage to find one I’ll edit it in here, but until then that’s all I’ve got.

Sources
[1] A.A. Ahmadi, A. Olshevsky, P.A. Parrilo, and J.N. Tsitsiklis. NP-hardness of Deciding Convexity of Quartic Polynomials and Related Problems. Mathematical Programming vol. 137 Issue 1-2, pages 453-476. A copy is available here.
[2] C. Ling, J. Nie, L. Qu, and Y. Ye. Biquadratic optimization over unit spheres and semidefinite programming relaxations. SIAM Journal on Optimization, 20(3):1286-1310, 2009. [3] T.S. Motzkin and E.G. Strauss. Maxima for graphs and a new proof of a theorem of Turan. Canadian Journal of Mathematics, 17:533-540, 1965. A copy is available here.