I want to find the derivative of the function: $h(x) = x^2(x+1)$
We know that the correct derivative is $h'(x) = 3x^2+2x$
I want to know if chain rule can as well be applied here: $h′(x)=f′(g(x))∗g′(x)$
Can we say the following?
We have the inner function $g(x)$, which adds one to the argument:
$g(x) = x+1$
And we have the outer function $f(x)$, which multiplies the argument by $x^2$:
$f(x) = x^2*x$ (or better write $f(y) = x^2*y$ to avoid confusion?).
But if I proceed and say $f'(x)=3x^2$ and $g'(x) = 1$, then $h′(x)=f′(g(x))∗g′(x) = 3(x+1)^2*1=3x^2+6x+3 \neq 3x^2+2x$
Please let me know where I am wrong and if chain rule is applicable here at all. I know that in this situation product rule is better to be used here. But if chain rule cannot be applied here, please explain where the logic breaks.
PS. I have seen a similar question here Finding derivative using product and chain rule and it implies that chain rule may be used.
The 'trick' is that you have to apply the multivariate version of the chain rule. When function is a composition of a bivariate function with arguments that each are monovariate functions :
$${[f\circ (g,h)]'(x) = \bigl[g'\cdot f^{(1,0)}\circ(g,h)+h'\cdot f^{(0,1)}\circ(g,h)\bigr](x)}$$
Now let $h(x) = f(x, x+1)$ where $f(x,y)=x^2y$. $$h(x)= x^2~(x+1)$$
Then we have the partial derivatives $f^{(1,0)}(x,y)=2xy$ and $f^{(0,1)}(x,y)=x^2$ .
$${f^{(1,0)}(x,x+1)=2x~(x+1)\\f^{(0,1)}(x,x+1)=x^2}$$
The above chain rule gives us: $$\begin{align}h'(x) &= (x)' f^{(1,0)}(x,x+1)+ (x+1)' f^{(0,1)}(x,x+1)\\&= 2x~(x+1)+x^2\\&=3x^2+2x\end{align}$$