Why is there an $x$ when solving the derivative of $\theta_1$ and not $\theta_0$?

114 Views Asked by At

img I understand how he found the first derivative but why is there an $x$ superscript (i) in the second but not in the first? I circled it in the image. The original formula is above. Thanks!

1

There are 1 best solutions below

0
On

\begin{align} \frac{\partial}{\partial\theta_1} J(\theta_0,\theta_1) &= \frac{\partial}{\partial\theta_1} \frac{1}{2m}\sum_{i=1}^m (\theta_0 + \theta_1x^{(i)} - y^{(i)})^2 \\ &= \frac{1}{2m}\sum_{i=1}^m \frac{\partial}{\partial\theta_1} (\theta_0 + \theta_1x^{(i)} - y^{(i)})^2 \\ &= \frac{1}{2m}\sum_{i=1}^m 2(\theta_0 + \theta_1x^{(i)} - y^{(i)}) \frac{\partial}{\partial\theta_1} (\theta_0 + \theta_1x^{(i)} - y^{(i)}) \;\;\;\,\text{ Via Chain rule} \\ &= \frac{1}{2m}\sum_{i=1}^m 2(\theta_0 + \theta_1x^{(i)} - y^{(i)}) \frac{\partial}{\partial\theta_1} ( \theta_1x^{(i)})\\ &= \frac{1}{2m}\sum_{i=1}^m 2(\theta_0 + \theta_1x^{(i)} - y^{(i)}) x^{(i)} \underbrace{\frac{\partial}{\partial\theta_1} ( \theta_1) }_1 \\ &= \frac{1}{m}\sum_{i=1}^m (\theta_0 + \theta_1x^{(i)} - y^{(i)}) x^{(i)} \end{align}