I can't solve this question. Someone could explain for me please?
Consider $f: R^n \rightarrow R$ differentiable function. Define for all $x \in R^n$, the functions: $$g(x) = \max \{ 0, f(x) \}\;\; \mbox{and}\;\; h(x) = g(x)^2.$$ So, $\nabla h(x) = 2*g(x)*\nabla f(x).$
I can't solve this.
I am thinking this problem has a direct solution, but I can't solve it. I was thinking this way:
How $f$ is differentiable, then $g$ and $h$ are differentiable too. And for $x \in R^n$ when $f(x) \leq 0$, we have $g(x) = 0$ and the result is true because $\nabla h(x) = 0$.
The problem for me is when $f(x) > 0$. I know that for $x$ such that $f(x) > 0$, we have $g(x) = f(x)$ and $h(x) = f(x)^2$.
But I couldn't to prove the result. The result remember me the chain rule differentiable, but I didn't find a chain rule differentiable for gradients vectors.
You don't need an explicit "chain rule" for two reasons. First, "chain rule"s apply to composition of functions; you want a product rule. Second, the derivation is actually not that hard. Remember the gradient of $h(x)^2$ is gotten by taking partial derivatives: $\frac{\partial}{\partial x_i} h(x)^2$ and you can do this by hand.
Actually if $f$ is differentiable, then $g$ might not be differentiable, because it might have a "kink" if $f$ has both positive and negative values. You would further have to explain how $h$ is differentiable.
Note: The calculations should be fine where $f(x) < 0$ or $f(x) > 0$, but the problems with differentiability happen when $f(x) = 0$.
Example: $f(x) = x$ from $\mathbb{R} \to \mathbb{R}$. Then $g(x) = 0$ when $x < 0$ and $g(x) = x$ when $x \geq 0$, which has a kink at $0$. However, when we define $h(x) = g(x)^2$, we see that $h(x) = 0$ when $x < 0$, but $h(x) = x^2$ when $x \geq 0$ and so there is no kink in $h$ and the derivative of $h$ is in fact $2g(x)f'(x)$.