what is the difference between convex, non-convex, concave and non-concave functions? how will we come to know that the given function is convex or non-convex? and if a function is non-convex then it will necessarily be concave one? Thanks in advance
2 Answers
A convex function has one minimum - a nice property, as an optimization algorithm won't get stuck in a local minimum that isn't a global minimum. Take $x^2 - 1$, for example:
A non-convex function is wavy - has some 'valleys' (local minima) that aren't as deep as the overall deepest 'valley' (global minimum). Optimization algorithms can get stuck in the local minimum, and it can be hard to tell when this happens. Take $x^4 + x^3 -2x^2 -2x$, for example:
A concave function is the negative of a convex function. Take $-x^2$, for example:
A non-concave function isn't a widely used term, and it's sufficient to say it's a function that isn't concave - though I've seen it used to refer to non-convex functions. I wouldn't really worry about this one.
-
3$\begingroup$ These answers may be deeply confusing to people trying to learn about convexity. "Has one minimum" does not uniquely characterize convex functions. Non-convex functions may have unique local minima. $\endgroup$– whuber ♦Jan 23, 2018 at 18:29
-
1$\begingroup$ Why do optimization algorithms get stuck in local optima? We could calculate all optima using the derivative and compare their y-values, no? $\endgroup$ Mar 4, 2019 at 1:03
To define a convex function, you need a convex set $X$ as the domain and $\mathbb{R}$ as the codomain.
A function is convex if it satisfies the following property:
$$\forall x_1, x_2 \in X, \forall t \in [0,1], f(tx_1+(1-t)x_2) \le tf(x_1) +(1-t)f(x_2)$$
You should read through the wikipedia page of convex funciton.
In one dimension, you can visualize the dimension as whenever you pick any two points on the domain and connect them using a straight line, the straight line is always equal to or above the graph.
Personally, I find the following property to check convex property to be incredibly useful:
"A continuous, twice differentiable function of several variables is convex on a convex set if and only if its Hessian matrix of second partial derivatives is positive semidefinite on the interior of the convex set."
A function is non-convex if the function is not a convex function.
A function, $g$ is concave if $-g$ is a convex function.
A function is non-concave if the function is not a concave function.
Notice that a function can be both convex and concave at the same time, a straight line is both convex and concave.
A non-convex function need not be a concave function. For example, the function $f(x)=x(x-1)(x+1)$ defined on $[-1,1]$.