According to a calculus book I have been reading, we call a function $g(x)$ a convex function if

$$g(\lambda x +(1-\lambda)y) \leq \lambda g(x) +(1-\lambda)g(y)$$, for all $x,y$ and $0<\lambda<1$.

But if I have to check if a given function is convex or not,this definition seems hard and impractical to use. So,my question is, is there any easier way of checking convexity of a function and if there is,then why it is equivalent to this defiinition.

Thanks in advance!

  • 2
    $\begingroup$ look at the second derivative if it exists and is non-negative $\endgroup$ Aug 16, 2019 at 19:09
  • 3
    $\begingroup$ @J.W.Tanner provided the function has one! $\endgroup$
    – Anurag A
    Aug 16, 2019 at 19:11
  • $\begingroup$ Just to remind you guys, i am interested in the proof also $\endgroup$ Aug 16, 2019 at 19:12
  • 1
    $\begingroup$ Your question is too vague to provide various proves. Have a look at ljk.imag.fr/membres/Anatoli.Iouditski/cours/convex/… if you want to look at various convexity criteria with the associated proves. $\endgroup$ Aug 16, 2019 at 19:26
  • $\begingroup$ @mathcounterexamples.net thanks! $\endgroup$ Aug 16, 2019 at 19:47

4 Answers 4


What you gave is the standard definition of a convex function.

If $f$ is supposed to be continuous, it is enough to check that

$$f\left(\frac{x+y}{2}\right) \le \frac{f(x)+f(y)}{2}$$ for all $x,y$.

If $f$ is twice differentiable, it is enough to check that the second derivative is non negative.

  • $\begingroup$ Can you please show me how the standard definition is equivalent to these two criteria? $\endgroup$ Aug 16, 2019 at 19:24
  • 1
    $\begingroup$ Again this is standard. Have a look to ljk.imag.fr/membres/Anatoli.Iouditski/cours/convex/… or other articles on convex maps. $\endgroup$ Aug 16, 2019 at 19:27
  • 3
    $\begingroup$ Why is that condition sufficient to check if $f$ is continuous? It seems like you just chose a specific value for $\lambda$, i.e. $\lambda=\frac{1}{2}$, in the general definition. $\endgroup$
    – Mjoseph
    Sep 20, 2022 at 18:46
  • $\begingroup$ @Mjoseph I was wondering the same just now and don't take my word for it, but I think it's got something to do with the geometric interpretation of convexity and the arithmetic mean? Or something? And because for the sake of simplicity you can use $\lambda = \frac{1}{2}$ because then $\lambda = 1 - \lambda$? And because if your function is discontinuous and has a singularity, then all of this stuff doesn't really work anymore... ugh idk lol. I lost my track of thought. If someone has a better explanation, go ahead. $\endgroup$ Feb 16 at 21:12

Check the Hessian matrix of the function. If the matrix is:

  1. Positive-definite then your function is strictly convex.
  2. Positive semi-definite then your function is convex.

A matrix is positive definite when all the eigenvalues are positive and semi-definite if all the eigenvalues are positive or zero-valued.


For convexity of a function $f(x)$ you like to have the graph of your function on an interval [a,b] falls below or on the graph of a straight line segment connecting $f(a)$ and $f(b)$.

You can check arbitrary points or in case the second derivative exist you want your second derivative be non negative.

That makes the slopes to increase and the curve falls above the tangent lines and below the secant lines.


For particular functions, there are indeed easier ways of checking.

For example, for any function $g(x)$ which is twice differentiable in an interval $(a,b)$ $$( \forall x\in(a,b) (\frac{d^2g}dx^2 \leq 0) ) \implies g(x) \mbox{ is convex in } (a,b)$$

That is, a function with non-negative second derivative in an interval is convex in that interval.

Another property is that any function $g(x)$ which is not continuous on $(a,b)$ cannot be convex on $(a,b)$.

But there can be other functions which are more difficult to deal with. Suppose $g(x)$ is continuous on $(a,b)$ but is not everywhere differentiable, or has a discontinuous first derivative, so that the second derivative does not exist everywhere. Such a function can still be convex; for example

Somebody changed my answer, saying that a function with a non-positive second derivative is convex. Of course, what one calls "convex" or "concave" for a function from $\Bbb R \to \Bbb R$ is somewhat just a matter of convention, but if you believe that the common usage is the definition found in Wikipedia, the function $x^2$ is convex.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .