Is this function composition convex? Say we have two functions $f:R^n\rightarrow R$ , $g:R^m\rightarrow R^n$.
Given that $f$ is convex, under what conditions on $f$ and $g$ we will be able to say that the composition function $f(g(v)):R^m\rightarrow R$ is convex as well?
and the second question will be how the conditions will change if $dom(f)\neq R^n$
and $dom(g)\neq R^m$?
Thanks
 A: If $h\colon \Bbb R^k \to \Bbb R$ and $g\colon \Bbb R^n \to \Bbb R^k$, then their composition is given by
$$f(x)=h(g(x)) \qquad \qquad \operatorname{dom}(f)=\{x\in\operatorname{dom}(g)\mid g(x)\in \operatorname{dom}(h)\}.$$
We denote by $\tilde h$ the extended-value extension of $h$, which assigns the value $\infty$ ($-\infty$) to points not in $\operatorname{dom}(h)$ for $h$ convex (concave).
Then we have the following: 


*

*$f$ is convex if $h$ is convex,$\tilde h$ is nondecreasing, and $g$ is convex.

*$f$ is convex if $h$ is convex, $\tilde h$ is nonincreasing, and $g$ is concave.

*$f$ is concave if $h$ is concave, $\tilde h$ is nondecreasing, and $g$ is concave.

*$f$ is concave if $h$ is concave, $\tilde h$ is nonincreasing, and $g$ is convex.


These results can be found at page 83-84 equation (3.11) of the book Convex optimization by Boyd and Vandenberghe, freely available here. You might be interested in the whole chapter 3.2 ("Operations that preserve convexity") of this book.
