# Chain rule doubt

I have a doubt of appling the chain rule. I have this $$L$$ function: $$L = y\cdot log(\frac{e^{a x+b}}{e^{ax+b} + exp^{cx+d}})$$ I can rewrite it as: $$L = y\cdot log(p)$$ where $$p = \frac{e^{v_{0}}}{e^{v_{0}}+e^{v_{1}}}$$ $$v_{0} = ax+b$$ $$v_{1} = cx+d$$

If I apply the chain rule I have this:

$$\frac{\partial L}{\partial x} = \frac{\partial L}{\partial p} \cdot \frac{\partial p}{\partial v_{0}} \cdot \frac{\partial v_{0}}{\partial x}$$

But I know that I am missing somewhere the value of $$\frac{\partial v_{1}}{\partial x}$$

What I am doing wrong?

## 2 Answers

Note that $$p=p(v_0,v_1)\\ \frac{dp}{dx}=\frac{\partial p}{\partial v_0}\frac{dv_0}{dx}+\frac{\partial p}{\partial v_1}\frac{dv_1}{dx}$$

Your result is wrong because $$p$$ is a function of $$x$$ that contains the two functions $$\nu_0$$ and $$\nu_1$$ but not in the nested form $$p(\nu_0(\nu_1))$$. So we must write its derivative using also the quotient rule as:

$$\frac{\partial p}{\partial x}=\frac{e^{\nu_0}\frac{\partial \nu_0}{\partial x}(e^{v_{0}}+e^{v_{1}})-e^{\nu_0}(e^{v_{0}}\frac{\partial \nu_0}{\partial x}+e^{v_{1}}\frac{\partial \nu_1}{\partial x})}{(e^{v_{0}}+e^{v_{1}})^2}$$

and the correct final result is $$\frac{\partial L}{\partial x} = \frac{\partial L}{\partial p} \cdot \frac{e^{\nu_0}\frac{\partial \nu_0}{\partial x}(e^{v_{0}}+e^{v_{1}})-e^{\nu_0}(e^{v_{0}}\frac{\partial \nu_0}{\partial x}+e^{v_{1}}\frac{\partial \nu_1}{\partial x})}{(e^{v_{0}}+e^{v_{1}})^2}$$