If you find any mistakes, please make a comment! Thank you.

Solution to Mathematics for Machine Learning Exercise 5.3

Compute the derivative $f’(x)$ of the function $$f(x)=\exp\left(-\frac{1}{2\sigma^2}(x-\mu)^2\right).$$ Solution: Clearly, we have $$\left(-\frac{1}{2\sigma^2}(x-\mu)^2\right)’=-\frac{1}{2\sigma^2}2(x-\mu)=\frac{-(x-\mu)}{\sigma^2}.$$Therefore, by Chain rule (5.32), we have \begin{align*}f’(x)=&\ \exp\left(-\frac{1}{2\sigma^2}(x-\mu)^2\right)\cdot \left(-\frac{1}{2\sigma^2}(x-\mu)^2\right)’\\=&\ \frac{-(x-\mu)}{\sigma^2}\cdot\exp\left(-\frac{1}{2\sigma^2}(x-\mu)^2\right)\end{align*}

Continue Reading

Solution to Mathematics for Machine Learning Exercise 5.2

Compute the derivative $f’(x)$ of the logistic sigmoid $$f(x)=\frac{1}{1+\exp(-x)}.$$ Solution: By Chain rule (5.32), we have $$(1+\exp(-x))’=0+\exp(-x)(-x)’=-\exp(-x).$$ By the Quotient rule (5.30), we have\begin{align*}f’(x)=&\ \frac{(1)’(1+\exp(-x))-1(1+\exp(-x))’}{(1+\exp(-x))^2}\\=&\ \frac{0(1+\exp(-x))-(-\exp(-x))}{(1+\exp(-x))^2}\\=&\ \frac{\exp(-x)}{(1+\exp(-x))^2}.\end{align*}

Continue Reading

Solution to Mathematics for Machine Learning Exercise 5.1

Compute the derivative $f’(x)$ for $$ f(x)=\log(x^4)\sin(x^3).$$ Solution: By Chain Rule (5.32), we have$$ \big(\sin(x^3)\big)’=\cos(x^3)(x^3)’=3x^2\cos(x^3). $$We also have$$ \big(\log(x^4)\big)’=\big(4\log(x)\big)’=\frac{4}{x}=4x^{-1}. $$Applying Product Rule (5.29), we obtain\begin{align*} f’(x)=&\ \log(x^4) \sin(x^3)\\=&\ \big(\log(x^4)\big)’\sin(x^3)+\log(x^4)\big(\sin(x^3)\big)’\\=&\ 4x^{-1}\sin(x^3)+\log(x^4)3x^2\cos(x^3)\\=&\…

Continue Reading
Close Menu