# Convex function

A convex function is a continuous function whose value at the midpoint of every interval in its domain does not exceed the arithmetic mean of its values at the ends of the interval.

A function $f: I \mapsto \mathbb{R}$ for some interval $I \subseteq \mathbb{R}$ is convex (sometimes written concave up) over $I$ if and only if the set of all points $(x,y)$ such that $y \ge f(x)$ is convex. Equivalently, $f$ is convex if for every $\lambda \in [0,1]$ and every $x,y \in I$, $\lambda f(x) + (1-\lambda)f(y) \ge f\left( \lambda x + (1-\lambda) y \right)$.

We say that $f$ is strictly convex if equality occurs only when $x=y$ or $\lambda \in \{ 0,1 \}$.

Usually, when we do not specify $I$, we mean $I = \mathbb{R}$.

We say that $f$ is (strictly) concave (or, occasionally, that it is concave down) if $-f$ is (strictly) convex.

If $f$ is differentiable on an interval $I$, then it is convex on $I$ if and only if $f'$ is non-decreasing on $I$. Similarly, if $f$ is twice differentiable over an interval $I$, we say it is convex over $I$ if and only if $f''(x) \ge 0$ for all $x \in I$.

Note that in our previous paragraph, our requirements that $f$ is differentiable and twice differentiable are crucial. For a simple example, consider the function $f(x) = \lfloor x \rfloor (x - \lfloor x \rfloor ) + {\lfloor x \rfloor \choose 2}$,

defined over the non-negative reals. It is piecewise differentiable, but at infinitely many points (for all natural numbers $x$, to be exact) it is not differentiable. Nevertheless, it is convex. More significantly, consider the function $f(x) = \left( |x| - 1 \right)^2$

over the interval $[-2, 2]$. It is continuous, and twice differentiable at every point except ${} (0, 1)$. Furthermore, its second derivative is greater than 0, wherever it is defined. But its graph is shaped like a curvy W, and it is not convex over $[-2,2]$, although it is convex over $[-2,0]$ and over $[0,2]$.
{"ft_lang_label":"__label__en","ft_lang_prob":0.93911326,"math_prob":0.99999285,"size":1515,"snap":"2022-27-2022-33","text_gpt3_token_len":331,"char_repetition_ratio":0.16214427,"word_repetition_ratio":0.0074626864,"special_character_ratio":0.21254125,"punctuation_ratio":0.12751678,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99996793,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70],"im_url_duplicate_count":[null,6,null,6,null,null,null,null,null,6,null,null,null,6,null,6,null,6,null,null,null,null,null,6,null,null,null,6,null,null,null,7,null,null,null,null,null,null,null,8,null,null,null,null,null,null,null,null,null,6,null,6,null,null,null,6,null,null,null,6,null,6,null,6,null,7,null,6,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-11T21:41:04Z\",\"WARC-Record-ID\":\"<urn:uuid:5c34d9f1-cb89-4b1c-b708-3f73cc062935>\",\"Content-Length\":\"39929\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a31a31d0-1589-44ea-914c-735b2fbb86dd>\",\"WARC-Concurrent-To\":\"<urn:uuid:2c0d3c6e-7f95-4ca6-8874-1dabe0f7702d>\",\"WARC-IP-Address\":\"104.26.10.229\",\"WARC-Target-URI\":\"https://artofproblemsolving.com/wiki/index.php/Convex_function\",\"WARC-Payload-Digest\":\"sha1:MGURIVT4P2DECLIEWMEKD5OLX2CPP6PK\",\"WARC-Block-Digest\":\"sha1:O3XUATTN7RV355XSVZWRFMFRWWDD7A4B\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882571502.25_warc_CC-MAIN-20220811194507-20220811224507-00787.warc.gz\"}"}