let $f : \mathbb{R}^n \to \mathbb{R} $ be a convex and differentiable function and $\bar x$ is solution of this problem
$$\min f(x) $$
$$s.t \qquad x \geq 0 .$$
Then show $\nabla f(\bar x) \geq 0$ and $\nabla f(\bar x)\bar x = 0$.
I know that if $\bar x$ is solution of a optimizing problem then $\nabla f(\bar x) = 0$ but i can't prove this.
The Lagrange function is $L(x,\lambda) = f(x)- \lambda^Tx$. The KKT conditions are
$$\nabla f(x^*) = \lambda^* \tag{1}$$
$$x^* \geq 0 \tag{2}$$
$$\lambda^* \geq 0 \tag{3}$$
$$(\lambda^*)^Tx^* = 0 \tag{4}$$
The last equality is called complementary slackness condition. From $(4)$ and (2), we have $$\frac{\partial f(x^*)}{\partial x^*_j} = \lambda^*_j, \quad j=1, \dots, n \tag{5}$$ for which
$$\frac{\partial f(x^*)}{\partial x^*_j} =0, \quad \forall j\colon x_j^*>0 \tag{6}$$ $$\frac{\partial f(x^*)}{\partial x^*_j} \geq 0\quad\text{otherwise} \tag{7}$$ $(6)$ and $(7)$ refer to the case where the constraint is inactive and active, respectively.