Exercises 5-8:

Solution 5:

\[f(x,y)=x^2y-x+2y+3\] at (1,2)

Calculate differentiation of a function:

f5 <- expression((x**2*y) - x + 2*y + 3)
x <- 1
y <- 2

fx5 <- D(f5, "x")
fx5
## 2 * x * y - 1
fy5 <- D(f5, "y")
fy5
## x^2 + 2

Now evaluate an expression:

eval(fx5)
## [1] 3
eval(fy5)
## [1] 3

Solution 6:

\[f(x,y)=x^3-3x+y^2-6y\] at (-1,3)

f6 <- expression(x**3 - 3*x + y**2 - 6*y) 
x <- -1
y <- 3

fx6 <- D(f6, "x")
fx6
## 3 * x^2 - 3
fy6 <- D(f6, "y")
fy6
## 2 * y - 6
eval(fx6)
## [1] 0
eval(fy6)
## [1] 0

Solution 7:

\[f(x,y)=sin(y)cos(x)\] at \[\frac{\pi}{3}, \frac{\pi}{3}\]

take the partial derivative of f(x,y) with respect to x and y.

\[f_x(x,y)=-sin(y)sin(x)\]

\[f_y(x,y)=cos(y)cos(x)\]

Now substitute with \[x=\frac{\pi}{3}, y=\frac{\pi}{3}\]

\[f_x(\frac{\pi}{3},\frac{\pi}{3})=-sin(\frac{\pi}{3})sin(\frac{\pi}{3})=-\frac{\sqrt3}{2}*\frac{\sqrt3}{2}=-\frac{3}{4} \]

\[f_y(\frac{\pi}{3},\frac{\pi}{3})=cos(\frac{\pi}{3})cos(\frac{\pi}{3})=\frac{1}{2}*\frac{1}{2}=\frac{1}{4} \]

Solution 8:

\[f(x,y)=ln(xy)\] at (-2, -3)

f8 <- expression(log(x*y)) 
x <- -2
y <- -3

fx8 <- D(f8, "x")
fx8
## y/(x * y)
fy8 <- D(f8, "y")
fy8
## x/(x * y)
eval(fx8)
## [1] -0.5
eval(fy8)
## [1] -0.3333333

What were the most valuable elements you took away from this course?

Learned the computational mathematics concepts that are important for machine learning.