# Idea behind the definition of convex functions

Recently, I had to work on a lot of problems concerning convex functions (e.g. showing they are continuous on an open interval ).

This definition is always given:

A function $f:X \rightarrow R$ $$\forall x_1, x_2 \in X, \forall t \in [0, 1]: \qquad f(tx_1+(1-t)x_2)\leq t f(x_1)+(1-t)f(x_2)$$

And I can work on it, but I have no idea where it comes from. I know what a convex graph looks like, but how did they come up with that formula? What is the motivation behind that $\forall t \in [0, 1]$ that pops up everywhere when talking about convex functions?

On Wikipedia there even is an "illustration", but I can't make sense of it either. https://en.wikipedia.org/wiki/Convex_function#/media/File:ConvexFunction.svg

Could somebody please explain, how somebody looked at a convex graph one time and came up with this definition for a convex function?

• Is the idea of a convex set clearer to you? For example, take a set in $\mathbb{R}$ and then choose two points $x,y$ in this set. Do all points on a straight line between $x$ and $y$ also lie in your set? If yes, can we do this for all $x,y$ in this set? If yes, then you call it convex. Now, take a look at the epigraph of a function. You can now call this function convex iff its epigraph is convex. The definition you gave is equivalent to this. – Agala Bufu Feb 2 '17 at 11:04
• To be honest, no I have never heard of a convex set and your definition of a convex function( at least not that explicitly ), but I'd be intrigued to hear more – Jonathan Feb 2 '17 at 11:06
• $\forall t\in [0,1]$ is to imagine something continuously change during a 1 unit time interval. f (0) represents what it looks like in the begining. f (1) at the end. And f (t) at a specific point in the middle. This is often thought of as a "path" where someone walks along at an unsteady pace. f (t) is where he is at time t. – fleablood Feb 2 '17 at 11:08
• Convex means bowed shaped or bent outward,right. So in this the RHS represents a fly crawling along straight line from endpoint to end point. The LHS represents an ant crawling along the function itself. The ant is always below the fly because the curve is bowed shape. – fleablood Feb 2 '17 at 11:13
• So imagine the fly. At time zero she is at f (x1). At time 1 she is at f(x2). At time in between she is at $f (x1)+ t [f (x2)-f (x1)]$ which expands to the RHS. The ant travels a constant speed along the x axis (both the fly and the ant do; that's how we know when to look to see if the ant is below the fly). At time 0 the ant is at x1. At tee 1 at x2. And at time t at x1+t (x2-x1) which is equal to tx1+(1-t)x2. So on the curve the ant is at f (tx1+(1-t)x2) at time t. – fleablood Feb 2 '17 at 11:25

To answer the first question. Where does $\forall t\in [0,1]$ come from and what does it mean:

Basically it is a means to indicate a "path" between two states where $f(0)$ is the first state and $f(1)$ is the end state and $f(t)$ is the state and any "time" in between.

The simplest example is a line segment between two points $a, b$ in $\mathbb R^n$. Let $f(t) = a + t(b-a) = a(1-t) + t*b$. Note: $f(0) = a$ the point at "time" 0. And $f(1) = b$ the point at "time" 1. And $f(t)$ is the position at proportion $t$ of the line. (e.g. midpoint of the line is $f(.5) = \frac {a+b}2$; quarter point is $f(.25) = \frac {3a + b}4$; etc.)

Here's a thought experiment: Suppose we had a curve. The graph of $y =f(x) = x^2 + 3x + 5$. And suppose we had another curve. The graph of $y =g(x)= x^3-27$. And we wanted to "bend" one curve into the other and we wanted to describe the process of bending the curve so we can describe all the bent curves in between. How would we do that?

Well we use the idea of "paths". At time $0$ we will have $y(0) = f(x) =x^2 + 3x + 5$ and at time $1$ we will have $y(0) = g(x) = x^3 - 27$. And at time $t$ we have $y(t) =f(x)(1-t) + g(x) t = (x^2 + 3x + 5)(1-t) + t(x^3 - 27)$. We think of that as a continuous "path" function $H:[0,1]\times \mathbb R \rightarrow \mathbb R$ the notation of which confused the HECK out of me when I first encountered it. But all it means is we have a bunch of functions $H(t,x) =y_t(x) = whatever$ and this is classifying them all so we can access each one by index $t$ where each $y_t(x)$ represents some function "in between" $f(x)$ and $g(x)$.

Okay... I digress.

But this is useful.

Okay... what does "convex" mean? It means "bowed". What does that mean. It means that if you picked any two points on the graph and drew a line between them, all the points on the convex curve will be to one side (right) of the line. Or you can never draw a from any point of the curve to any other point of the curve and have to curve intersect.

How to define that mathematically?

Well, you pick any two points of the curve. $(x_1, f(x_1))$ and $(x_2, f(x_2))$ and draw a line between them. Meanwhile we also have the curve between those two points.

Suppose there were an ant crawling along the curve traversing the horizontal direction at a constant speed, while at the same time we have a spider crawling along the line also traversing the horizontal direction at the exact speed. i.e. The spider and the fly will always be vertically directly above or below or at the same spot as each other.

As the curve is convex the spider, on the line, will always be above the ant, on the curve.

The spider, traveling in a line will at time $t$ be at $(x_1(1-t) + x_2*t, f(x_1)(1-t) + f(x_2)t)$.

The ant traveling along the curve will at time $t$ be ate $(x_1(1-t) + x_2*t, f(x_1(1-t) + x_2*t))$.

As the spider is above the ant:

$f(x_1)(1-t) + f(x_2)t \ge f(x_1(1-t) + x_2*t)$

• I don't know what to say. Magical answer! – Jonathan Feb 3 '17 at 9:50