Derivative of a logarithm (chain rule)

99 Views Asked by At

I am trying to calculate the derivative below:

$$ \frac{\partial }{\partial \theta} \left(-y\cdot \log\left(\frac{1}{1+e^{-\theta x}}\right)\right)=\frac{\partial }{\partial \theta} \left(y\cdot \log(1+e^{-\theta x})\right)= \frac{-y \cdot x \cdot e^{- \theta x}}{1+e^{- \theta x}} $$

where: $ \frac{y }{1+e^{-\theta x}} $ is the derivative of the logarithm and $ -x\cdot e^{- \theta x}$ is the derivative of the inner function.

However, I know from the Mathematica, that the correct answer is $$\frac{-y \cdot x }{1+e^{-\theta x}}$$

What did I do wrong?

2

There are 2 best solutions below

2
On

You are right and Mathematica is wrong !

0
On

\begin{eqnarray} \frac{\partial }{\partial \theta} \left[-y \ln\left(\frac{1}{1+e^{-\theta x}}\right)\right]&=&\frac{\partial }{\partial \theta} \left[y \ln\left(1+e^{-\theta x}\right)\right] \\ &=& -\frac{y x e^{- \theta x}}{1+e^{- \theta x}} \color{red}{\frac{e^{\theta x}}{e^{\theta x}}} \\ &=& -\frac{y x}{1 + e^{\color{red}{+}\theta x}} \end{eqnarray}