# Definition of Convex and Concave Functions

Consider two functions on the figure to the right.

They are both increasing, but their form is different.

That's because one of them is convex and another is concave.

**Definition.** Function `y=f(x)` that is defined and continuous on interval `X` is called **convex (or convex downward or concave upward)** if for any `a` and `b` from `X` and numbers `q_1` and `q_2` such that `q_1+q_2=1` and `q_1>=0,q_2>=0` we have that `f(q_1a+q_2b)<=q_1f(a)+q_2f(b)`.

Similarly we have the following definition of concave function.

**Definition.** Function `y=f(x)` that is defined and continuous on interval `X` is called **concave (or convex upward or concave downward)** if for any `a` and `b` from `X` and numbers `q_1` and `q_2` such that `q_1+q_2=1` and `q_1>=0,q_2>=0` we have that `f(q_1a+q_2b)>=q_1f(a)+q_2f(b)`.

From definition it follows that if `f(x)` is concave upward then `-f(x)` is concave downward, and vice versa. This fact allows us to study mainly only concave upward functions.

**Definition.** Function `y=f(x)` that is defined and continuous on interval `X` is called **strictly convex **if for any `a` and `b` (`a!=b`)from `X` and numbers `q_1` and `q_2` such that `q_1+q_2=1` and `q_1>0,q_2>0` we have that `f(q_1a+q_2b)<q_1f(a)+q_2f(b)`.

Similarly we have the following definition of strictly concave function.

**Definition.** Function `y=f(x)` that is defined and continuous on interval `X` is called **strictly concave** if for any `a` and `b` (`a!=b`) from `X` and numbers `q_1` and `q_2` such that `q_1+q_2=1` and `q_1>0,q_2>0` we have that `f(q_1a+q_2b)>q_1f(a)+q_2f(b)`.

Clearly if function is strictly concave upward (downward) then it is concave upward (downward).

Now, let's see what is the geometric meaning of the concave functions.

Without loss of generality assume that `a<b`. Since `q_1+q_2=1`, and `q_1` and `q_2` are non-negative then expression `c=q_1a+q_2b` is between `a` and `b`, in other words `a<=q_1a+q_2b<=b`.

Now, consider points `A(a,f(a))` and `B(b,f(b))`. Draw line through them. Point `C(c,f(c))` lies on the graph of function between points `a` and `b`. y-coordinate of point with x-coordinate `c` that lies on the line is `q_1f(a)+q_2f(b)`. So, let we have another point `D(c,q_1f(a)+q_2f(b))`.

Thus, function is concave upward if all values of function on interval `[a,b]` lie below line that connects `(a,f(a))` and `(b,f(b))`.

Function is concave downward if all values of function on interval `[a,b]` lie above line that connects `(a,f(a))` and `(b,f(b))`.

**Example 1.** The most trivial example of both concave upward and concave downward function is linear function `f(x)=mx+b`. For it inequality in definition transforms into equality.

**Example 2.** Function `y=x^2` is strictly concave upward. We can check it using definition.

`f(q_1a+q_2b)=(q_1a+q_2b)^2=q_1^2a^2+q_2^2b^2+2q_1q_2ab=q_1q_1a^2+q_2q_2b^2+2q_1q_2ab`.

We know that `q_1+q_2=1` so we replace `q_2` with `1-q_1` and `q_1` with `1-q_2`:

`q_1(1-q_2)a^2+q_2(1-q_1)b^2+2q_1q_2ab=q_1a^2-q_1q_2a^2+q_2b^2-q_1q_2b^2+2q_1q_2ab=`

`=q_1a^2+q_2b^2-q_1q_2(a-b)^2`.

Since `q_1>0`, `q_2>0` and `(a-b)^2>0` then `q_1q_2(a-b)^2>0` and `-q_1q_2(a-b)^2<0`, so

`q_1a^2+q_2b^2-q_1q_2(a-b)^2<q_1a^2+q_2b^2=q_1f(a)+q_2f(b)`.

Therefore, `f(q_1a+q_2b)<q_1f(a)+q_2f(b)`. This proves that function `y=x^2` is strictly concave upward. And also it is simply concave upward.