<p>This is an edit</p>

<p>By definition,for a convex subset <span class="math-container">$C\subseteq \mathbb{R}^n$</span> a convex function <span class="math-container">$f:C \to \mathbb{R}$</span> satisfy </p>

<p><span class="math-container">$$ f((1-t)x+ty)\leq (1-t)f(x)+tf(y)$$</span></p>

<p>for every <span class="math-container">$x,y\in C$</span> and <span class="math-container">$t \in (0,1)$</span>.</p>

<p>We can see if we let <span class="math-container">$x=(1,3)$</span> and <span class="math-container">$y=(3,1)$</span> and <span class="math-container">$t=\frac{1}{2}$</span> that</p>

<p><span class="math-container">$$ u((1-t)x+ty)=u(2,2)=6 \not \leq 5=\frac{u(1,3)}{2}+\frac{u(3,1)}{2}=(1-t)u(x)+tu(y)$$</span> </p>

<p>meaning your function is not convex. As you mentioned in the comments, the fact that the <span class="math-container">$\min$</span> function is not differentiable around <span class="math-container">$x_1=x_2$</span> gave you a false answer, since the function is piecewise linear.  </p>

<p>The rest of my original answer is irrelevant to the question now, but is still usefull to know. </p>

<p>More generally it helps to know the subspace of convex functions over <span class="math-container">$\mathbb{R}^n$</span> is a cone in the vectorspace of functions over <span class="math-container">$\mathbb{R}^n$</span>.</p>

<p>Specifically, let <span class="math-container">$C$</span> be the set of convex functions over <span class="math-container">$\mathbb{R}^n$</span>, i.e. <span class="math-container">$\mathbb{R}^n \to \mathbb{R}$</span>.</p>

<p>If <span class="math-container">$f,g\in C$</span> and <span class="math-container">$a,b\in \mathbb{R}^+$</span> then <span class="math-container">$a\cdot f+b\cdot g \in C$</span></p>

<p>This means that you can start to see if "complicated" functions are convex, if they are a conic combination of known convex functions. </p>

CC BY-SA 4.0
2019-10-19T02:09:10.203Z
Hi, can you give an example of a complicated convex function and how it arises from a simpler convex function?
Frodo Baggins
CC BY-SA 4.0
2019-10-19T08:43:26.083Z
I have changed my wording to be more precise, but an example would be $f(x,y,z)=23x^4+652y^8+1543z^{12}$ and $g(x,y,z)=exp(xyz)$, then $f+g$ is convex because it is the sum of convex functions. (in fact $f$ itself is a sum of convex functions).
Nikolaj Pedersen
CC BY-SA 4.0
2019-10-21T22:58:14.383Z
In your example above, how did you get 6 in $$ u((1-t)x+ty)=u(2,2)=6$$? I understand you have plugged 2, 2 in a utility function. What utility function is that?
Frodo Baggins
CC BY-SA 4.0
2019-10-22T07:49:52.893Z
in your utility function. I must assume $x=(x_1,x_2)$, meaning plugging (2,2) into your utility function $u(x_1,x_2)=x_1+x_2+\min\{x_1,x_2\}$ gives $u(2,2)=2+2+\min\{2,2\} = 6$.
Nikolaj Pedersen
CC BY-SA 4.0
2019-10-18T19:51:21.850Z
2019-10-19T09:06:41.800Z
2019-10-19T09:06:41.800Z
Nikolaj Pedersen
<p>I assume you meant <span class="math-container">$u(x_1,x_2)=x_1+x_2+\min\{x_1,x_2\}$</span>. To check if a function of two or more variables is convex, you need to check if you can differentiate it twice, calculate its <a href="https://en.wikipedia.org/wiki/Hessian_matrix" rel="nofollow noreferrer">Hessian</a> and check if it is positive semi-definite. On top of that the domain needs to be a convex set but since we talk about utility in economics - you don't need to worry about that too much - <a href="https://economics.stackexchange.com/questions/4725/can-a-utility-function-take-on-negative-values">Can A Utility Function Take On Negative Values?</a></p>

<p>In your example: 
<span class="math-container">$$\mathbf{H}=\begin{bmatrix}
 \frac{\partial^2u}{\partial x_1^2} &amp; \frac{\partial^2u}{\partial x_1x_2}  \\
 \frac{\partial^2u}{\partial x_1x_2} &amp; \frac{\partial^2u}{\partial x_2^2}  \\
\end{bmatrix}=\begin{bmatrix}
 0 &amp; 0  \\
 0 &amp; 0  \\
\end{bmatrix}$$</span></p>

<p>so it is?</p>

<p>The approach described above is a general way of showing a function being convex but as pointed in the comment section, you need to be careful - make sure that all the assumptions are met before jumping to conclusions. (Or else, you end up being mistaken as me right now.)</p>

<p><strong>EDIT.</strong></p>

<p>Minimum function mislead me, I agree. </p>

<p>Let's get back to basics:</p>

<p><span class="math-container">$u(x_1,x_2)=x_1+x_2+\min(x_1,x_2)=x_1+x_2 + \frac{x_1+x_2-|x_1-x_2|}{2}=\begin{cases}x_1+2x_2 \;\; \mathrm{for} \;\; x_1 \geq x_2\\ 2x_1+x_2 \;\; \mathrm{for} \;\; x_1&lt;x_2 \end{cases}$</span> </p>

<p>It looks like that (on horizontal axis <span class="math-container">$x_1$</span>, on vertical axis <span class="math-container">$x_2$</span>: 
<a href="https://i.sstatic.net/IPynM.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IPynM.gif" alt="enter image description here"></a></p>

<p>It is neither convex, nor concave. Due to the absolute value function that is in a core of minimum function: 
<a href="https://math.stackexchange.com/questions/991475/why-is-the-absolute-value-function-not-differentiable-at-x-0">Why is the absolute value function not differentiable at x=0?</a></p>

<p>I thought that eliminating point where <span class="math-container">$x_1=x_2$</span> would solve the issue but as shown in the other answer - it does not.</p>

<p><strong>EDIT. 2 (final)</strong></p>

<p>It is, in fact, concave as the user @afreelunch was telling me. You can see it directly from the definition. Or (what I think is even easier) from the way our utility function is built. </p>

<p>We have <span class="math-container">$u(x_1,x_2) = \min\{2x_1+x_2,x_1+2x_2\}$</span>. Now, let's take it apart: <span class="math-container">$f_1(x_1) = 2x_1$</span> and <span class="math-container">$g_1(x_2) = x_2$</span>, they are both linear <a href="https://math.stackexchange.com/questions/611633/is-linear-function-convex-or-concave">Is linear function convex or concave?</a> - hence, concave (and convex but we care about concavity here) and therefore their sum (<a href="https://en.wikipedia.org/wiki/Concave_function" rel="nofollow noreferrer">property of concave function</a>) <span class="math-container">$h_1(x_1,x_2)=2x_1+x_2$</span> is also concave. Similarly, <span class="math-container">$f_2(x_1) = x_1$</span> and <span class="math-container">$g_2(x_2)=2x_2$</span> and <span class="math-container">$h_2(x_1,x_2)=x_1+2x_2$</span> is concave as well. Knowing that, we get <span class="math-container">$\min\{h_1(x_1,x_2),h_2(x_1,x_2)\}$</span> - minimum of two concave functions - which is then concave (<a href="http://www.princeton.edu/~amirali/Public/Teaching/ORF363_COS323/F14/ORF363_COS323_F14_Lec6.pdf" rel="nofollow noreferrer">also a well known fact</a>). </p>

<p>In short, minimum preserves concavity (and maximum preserves convexity).</p>

CC BY-SA 4.0
2019-10-19T01:01:15.050Z
it is not but partial derivatives are pretty straightforward; https://math.stackexchange.com/questions/150960/derivative-of-the-fx-y-minx-y
bajun65537
CC BY-SA 4.0
2019-10-19T02:12:31.903Z
Graphically, it looks like it is convex, but the hessian is 0. So, how do we conclude that it is convex? The partial derivatives are also 0.
Frodo Baggins
CC BY-SA 4.0
2019-10-19T09:02:44.157Z
Zero matrix is positive semidefinite (and negative semidefinite at the same time). Look here for some logic behind it: https://math.stackexchange.com/questions/3153187/is-a-square-zero-matrix-positive-semidefinite Hessian you ended up with is a 2x2 zero matrix with all its eigenvalues being non-negative, meaning that it is, in fact, positive semidefinite. From here you conclude that the utility function is convex.
bajun65537
CC BY-SA 4.0
2019-10-19T09:57:50.020Z
So to be more precise, under assumption $x_1 \neq x_2$ the utility function is convex - otherwise it is not (because of the min function being not differentiable along the line $x=y$).
bajun65537
CC BY-SA 4.0
2019-10-19T17:44:18.177Z
@afreelunch, A function $f$ is concave over a convex set if and only if the function $−f$ is a convex function over the set. Nikolaj1000000 has proven that the function is not convex - that does not imply that the function is concave. 

Hope that now, my answer is correct?
bajun65537
CC BY-SA 4.0
2019-10-21T19:36:02.823Z
If we have a similar function, but instead of min, it is max : $ u(x) =  \max\{x_{1}, x_{2}\}$, we would still have 0s in the hessian matrix. As  bajun65537 said, Zero matrix can be positive and negative semidefinite simultaneously,  then how can we show that is concave?
Frodo Baggins
CC BY-SA 4.0
2019-10-23T14:01:01.203Z
@afreelunch I finally saw it! Not sure if I should delete or edit my post now. Thanks for valuable tips. ;)
bajun65537
CC BY-SA 4.0
2019-10-18T16:27:05.397Z
2019-10-23T13:59:18.300Z
2019-10-23T13:59:18.300Z
bajun65537
<p>I have a function: <span class="math-container">$ u(x) = x_{1} + x_{2} + \min\{x_{1}, x_{2}\}$</span>. How do we algebraically show if it's convex or not? Also, what would be the general way to show if any given function is convex. </p>

<microeconomics><mathematical-economics><utility><expected-utility>
Algebraic approach towards convexity
Frodo Baggins
# Algebraic approach towards convexity

(Asked by: username_0 on 2019-10-18)

I have a function: $ u(x) = x\_{1} + x\_{2} + \min\{x\_{1}, x\_{2}\}$. How do we algebraically show if it's convex or not? Also, what would be the general way to show if any given function is convex.

**Tags:** microeconomics, mathematical-economics, utility, expected-utility

---

## 2 answers

### Answer by username_1 on 2019-10-18. Score: 0 | Accepted answer

This is an edit

By definition,for a convex subset $C\subseteq \mathbb{R}^n$ a convex function $f:C \to \mathbb{R}$ satisfy

$$ f((1-t)x+ty)\leq (1-t)f(x)+tf(y)$$

for every $x,y\in C$ and $t \in (0,1)$.

We can see if we let $x=(1,3)$ and $y=(3,1)$ and $t=\frac{1}{2}$ that

$$ u((1-t)x+ty)=u(2,2)=6 \not \leq 5=\frac{u(1,3)}{2}+\frac{u(3,1)}{2}=(1-t)u(x)+tu(y)$$

meaning your function is not convex. As you mentioned in the comments, the fact that the $\min$ function is not differentiable around $x\_1=x\_2$ gave you a false answer, since the function is piecewise linear.

The rest of my original answer is irrelevant to the question now, but is still usefull to know.

More generally it helps to know the subspace of convex functions over $\mathbb{R}^n$ is a cone in the vectorspace of functions over $\mathbb{R}^n$.

Specifically, let $C$ be the set of convex functions over $\mathbb{R}^n$, i.e. $\mathbb{R}^n \to \mathbb{R}$.

If $f,g\in C$ and $a,b\in \mathbb{R}^+$ then $a\cdot f+b\cdot g \in C$

This means that you can start to see if "complicated" functions are convex, if they are a conic combination of known convex functions.

> **Comments:**
> **username_0**: Hi, can you give an example of a complicated convex function and how it arises from a simpler convex function?  
> **username_1**: I have changed my wording to be more precise, but an example would be $f(x,y,z)=23x^4+652y^8+1543z^{12}$ and $g(x,y,z)=exp(xyz)$, then $f+g$ is convex because it is the sum of convex functions. (in fact $f$ itself is a sum of convex functions).  
> **username_0**: In your example above, how did you get 6 in $$ u((1-t)x+ty)=u(2,2)=6$$? I understand you have plugged 2, 2 in a utility function. What utility function is that?  
> **username_1**: in your utility function. I must assume $x=(x_1,x_2)$, meaning plugging (2,2) into your utility function $u(x_1,x_2)=x_1+x_2+\min\{x_1,x_2\}$ gives $u(2,2)=2+2+\min\{2,2\} = 6$.  

---

### Answer by username_2 on 2019-10-18. Score: 0

I assume you meant $u(x\_1,x\_2)=x\_1+x\_2+\min\{x\_1,x\_2\}$. To check if a function of two or more variables is convex, you need to check if you can differentiate it twice, calculate its [Hessian](https://en.wikipedia.org/wiki/Hessian_matrix) and check if it is positive semi-definite. On top of that the domain needs to be a convex set but since we talk about utility in economics - you don't need to worry about that too much - [Can A Utility Function Take On Negative Values?](https://economics.stackexchange.com/questions/4725/can-a-utility-function-take-on-negative-values)

In your example:
$$\mathbf{H}=\begin{bmatrix}
\frac{\partial^2u}{\partial x\_1^2} & \frac{\partial^2u}{\partial x\_1x\_2} \\
\frac{\partial^2u}{\partial x\_1x\_2} & \frac{\partial^2u}{\partial x\_2^2} \\
\end{bmatrix}=\begin{bmatrix}
0 & 0 \\
0 & 0 \\
\end{bmatrix}$$

so it is?

The approach described above is a general way of showing a function being convex but as pointed in the comment section, you need to be careful - make sure that all the assumptions are met before jumping to conclusions. (Or else, you end up being mistaken as me right now.)

**EDIT.**

Minimum function mislead me, I agree.

Let's get back to basics:

$u(x\_1,x\_2)=x\_1+x\_2+\min(x\_1,x\_2)=x\_1+x\_2 + \frac{x\_1+x\_2-|x\_1-x\_2|}{2}=\begin{cases}x\_1+2x\_2 \;\; \mathrm{for} \;\; x\_1 \geq x\_2\\ 2x\_1+x\_2 \;\; \mathrm{for} \;\; x\_1

It looks like that (on horizontal axis $x\_1$, on vertical axis $x\_2$:
[![enter image description here](https://i.sstatic.net/IPynM.gif)](https://i.sstatic.net/IPynM.gif)

It is neither convex, nor concave. Due to the absolute value function that is in a core of minimum function:
[Why is the absolute value function not differentiable at x=0?](https://math.stackexchange.com/questions/991475/why-is-the-absolute-value-function-not-differentiable-at-x-0)

I thought that eliminating point where $x\_1=x\_2$ would solve the issue but as shown in the other answer - it does not.

**EDIT. 2 (final)**

It is, in fact, concave as the user @afreelunch was telling me. You can see it directly from the definition. Or (what I think is even easier) from the way our utility function is built.

We have $u(x\_1,x\_2) = \min\{2x\_1+x\_2,x\_1+2x\_2\}$. Now, let's take it apart: $f\_1(x\_1) = 2x\_1$ and $g\_1(x\_2) = x\_2$, they are both linear [Is linear function convex or concave?](https://math.stackexchange.com/questions/611633/is-linear-function-convex-or-concave) - hence, concave (and convex but we care about concavity here) and therefore their sum ([property of concave function](https://en.wikipedia.org/wiki/Concave_function)) $h\_1(x\_1,x\_2)=2x\_1+x\_2$ is also concave. Similarly, $f\_2(x\_1) = x\_1$ and $g\_2(x\_2)=2x\_2$ and $h\_2(x\_1,x\_2)=x\_1+2x\_2$ is concave as well. Knowing that, we get $\min\{h\_1(x\_1,x\_2),h\_2(x\_1,x\_2)\}$ - minimum of two concave functions - which is then concave ([also a well known fact](http://www.princeton.edu/~amirali/Public/Teaching/ORF363_COS323/F14/ORF363_COS323_F14_Lec6.pdf)).

In short, minimum preserves concavity (and maximum preserves convexity).

> **Comments:**
> **username_2**: it is not but partial derivatives are pretty straightforward; https://math.stackexchange.com/questions/150960/derivative-of-the-fx-y-minx-y  
> **username_0**: Graphically, it looks like it is convex, but the hessian is 0. So, how do we conclude that it is convex? The partial derivatives are also 0.  
> **username_2**: Zero matrix is positive semidefinite (and negative semidefinite at the same time). Look here for some logic behind it: https://math.stackexchange.com/questions/3153187/is-a-square-zero-matrix-positive-semidefinite Hessian you ended up with is a 2x2 zero matrix with all its eigenvalues being non-negative, meaning that it is, in fact, positive semidefinite. From here you conclude that the utility function is convex.  
> **username_2**: So to be more precise, under assumption $x_1 \neq x_2$ the utility function is convex - otherwise it is not (because of the min function being not differentiable along the line $x=y$).  
> **username_2**: @afreelunch, A function $f$ is concave over a convex set if and only if the function $−f$ is a convex function over the set. Nikolaj1000000 has proven that the function is not convex - that does not imply that the function is concave.   Hope that now, my answer is correct?  
> **username_0**: If we have a similar function, but instead of min, it is max : $ u(x) =  \max\{x_{1}, x_{2}\}$, we would still have 0s in the hessian matrix. As  bajun65537 said, Zero matrix can be positive and negative semidefinite simultaneously,  then how can we show that is concave?  
> **username_2**: @afreelunch I finally saw it! Not sure if I should delete or edit my post now. Thanks for valuable tips. ;)  

---

