While reading an article on Convex functions, I came across the following statement:
The absolute value function $f(x)=|x|$ is convex (as reflected in the triangle inequality), even though it does not have a derivative at the point $x = 0$.
Now we know that $f^{'}(x)=1,\text{ for }x>0$ and $f^{'}(x)=-1,\text{ for }x<0$. Considering all values of $x\neq0$, we can still conclude that $f^{''}(x)=0$ for all $x\neq0$. But a function is said to be convex iff $f^{''}(x)>0$. Where ami I going wrong? Is there another definition for convex functions?
$\endgroup$ 15 Answers
$\begingroup$Here is an another proof which I find easier to understand as it involves an alternative definition of convexity (which is more intuitive I find...)
Definition of convexity
Let $f$ be a real function defined on a real interval $I$, $f$ is convex on $I$ if and only if:
$$ f(\alpha x + \beta y) \leq \alpha f(x) + \beta f(y)$$
$$ \forall x,y \in I \ : \forall \alpha, \beta \in \mathbb{R}_{\geq 0}, \ \alpha + \beta = 1 \ $$
Proof that $f(x) = |x|$ is convex:
Let $x,y \in R$ and $\alpha, \beta \in R_{\geq0}$ subject to $\alpha + \beta = 1$
\begin{aligned} f(\alpha x + \beta y ) & = |\alpha x + \beta y| &\text{Definition of $f$} \\ & \leq | \alpha x | + | \beta y| &\text{Triangle inequality} \\ & = | \alpha | |x| + |\beta| |y| &\text{Absolute value is multiplicative} \\ & = \alpha f(x) + \beta f(y) &\text{By definition} \end{aligned}
$\endgroup$ $\begingroup$According to Wikipedia a convex function is "... if the line segment between any two points on the graph of the function lies above or on the graph"
Also (again Wikipedia), "If f is twice continuously differentiable and the domain is the real line, then we can characterize it as follows - $f$ convex if and only if $f''(x) \geq 0$ for all $x$".
But your function is not twice continuously differentiable.
$\endgroup$ $\begingroup$What is incorrect is your definition of convex functions.
According to the wikipedia page you linked, a function is called convex if $\forall x_1, x_2 \in X, \forall t \in [0, 1]: f(tx_1+(1-t)x_2)\leq t f(x_1)+(1-t)f(x_2).$
This is not equivalent to $f''(x)>0$.
$\endgroup$ $\begingroup$$$\forall x_1, x_2 \in X, \forall t \in [0,1], f(tx_1+(1-t)x)2) \leq tf(x_1)+(1-t)f(x_2)$$
Can you check that $|x|$ is indeed convex using this definition? Hint: Triangle inequality.
The corresponding case when second derivative exists is $f^{"}(x) \geq 0$
$\endgroup$ $\begingroup$Lots of definitions: but what you describe with $f''(x) > 0$ is strictly convex. Regular convex would be $f''(x) \ge 0$. The geometric definition is that the points in a line segment between two points lie above or on the graph. If we remove the "or on" options and require above and never on then we are talking strictly convex.
postscript: well $f''(x) > 0$ is not a definition of strictly convex either. ... sigh....
if $f''(x) > 0$ for all $x$ but then $f$ is strictly convex but the converse needn't be true. But I think if $f$ is strictly convex and $f$ is doubly differentiable then $f''(x) = 0$ can only occur for at most one $x$. I think. And, of course, $f$ need not be doubly differentiable everywhere.
Anywhoo.... a linear function $f(x) = mx + b$ is technically convex. And that is doubly differentiable everywhere $f''(x) = 0$.
$\endgroup$ 2