# In general, are functions of this form convex?

I know that quadratic functions, i.e. functions of the form $$f(x) = \frac{1}{2}x^TAx+b^Tx+c$$ (with $$A\in\mathbb{R}^{nxn}$$, $$b\in\mathbb{R}^n$$, $$c\in\mathbb{R}$$), are convex over $$\mathbb{R}^n$$ when A is positive semi-definite (PSD).

Is this in general true for functions of the form of $$g(x)=f^2(x)$$? (i.e. $$g(x)=(\frac{1}{2}x^TAx+b^Tx+c)^2$$) How can I show this?

Thank you!!

• No, consider $f(x)=x^2-1$. – Michal Adamaszek Apr 30 '20 at 17:27

## 2 Answers

In general, if $$f$$ is convex on a convex domain $$D$$, and $$h$$ is convex and increasing on a set containing $$f(D)$$, then $$h \circ f$$ is convex on $$D$$. That is,

$$f(t x + (1-t) y) \le t f(x) + (1-t) f(y)$$ implies $$h(f(t x + (1-t) y)) \le h(t f(x) + (1-t) f(y)) \le t h(f(x)) + (1-t) h(f(y))$$

Since $$h(t) = t^2$$ is convex and increasing on $$[0,\infty)$$, $$f^2$$ will be convex when $$f$$ is convex and nonnegative. So what you need in your example is $$\frac12 x^T A x + b x + c \ge 0$$.

You have to show that $$g''(x)$$ is positive semi-definite for for all $$x$$, that is to say

$$x^\top g''(x) x \geq 0 \text{ , for all x}$$

• The second derivative does not need to exist. What if $f(x) = \sqrt{|x|}$? – LinAlg May 2 '20 at 12:31
• @linAlg, this is the easiest way for his forth order polynomial. – Reda May 3 '20 at 17:23