\[f(x,y)=x^2 + 4y + y^2 -9 y + 3xy\]
f1<-function(x,y) x^2 + 4*y + y^2 -9*y + 3*x*y1) Take the partial derivatives.
library(Deriv)## Warning: package 'Deriv' was built under R version 4.0.5
Deriv(f1)## function (x, y)
## c(x = 2 * x + 3 * y, y = 2 * y + 3 * x - 5)
\[f_x\prime(x,y) \ = \ 2x + 3y\]
\[f_y\prime(x,y) \ = \ 2y + 3x -5\]
2) Solve prime x for 0.
\[x=-\frac{3y}{2} \ and \ y= \frac{-2x}{3}\]
3) Plug above into the other partial derivative to isolate y=2 and thus the below point is a root in both derivatives.
(-3,2) (15/11,10/11)
f1(-3,2)## [1] -15
If you walk up the the x axis only, you see the points are a minimum but only on the x axis.
f1(-2,2)
f1(-3,2)
f1(-4,2)## [1] -14
## [1] -15
## [1] -14
Note the rules for the second derivative test
If D(x,y) > 0 and $f_xx(x,y) > 0 then Relative Minimum
If D(x,y) > 0 and $f_xx(x,y) < 0 then Relative Maximum
If D(x,y) < 0 and $f_xx(x,y) > 0 then Saddle Point
If D(x,y) = 0 then inconclusive.
\[D(x,y) \ = \ f_x\prime(x,y) * f_y\prime(x,y) - f_{xy}\prime\prime(x,y)f_{yx}\prime\prime(x,y)\]
Deriv(Deriv(f1))## function (x, y)
## c(x.x = 2, x.y = 3, y.x = 3, y.y = 2)
D = -9 so the test is inconclusive.
4) Display the function at various angles
x = seq(-10, 10)
y = seq(-10, 10)
z <- outer(x, y, f1)
for (i in 1:3) {
theta<-10*i
persp(x,y, z, theta = theta, phi = 0, expand = 0.5, col = "lightblue", main="x^2 + 4*y + y^2 -9*y + 3*x*y",axes=T, ticktype="detailed")
}