# To find the maximum and minimum value of this expression

I have a function of the form of $$f(x,y)=\frac{ax+by+c}{\sqrt{dx^2+ey^2+fxy+gx+hy+i}}$$

I want to find its maximum and minimum values.

I used the limits on $x$ and $y$ to find the function tends to $\pm\frac{a}{\sqrt{d}}$ when $x\to\pm\infty$ and $\pm\frac{b}{\sqrt{e}}$ when $y\to\pm\infty$. But I am having trouble analyzing the function behavior with variation of both $x$ and $y$. I am looking for an expression of maxima and minima in terms of the constants $a,b,c,d,e,f,g,h$ and $i$.

I was able to plot the function in MATLAB but still having trouble in deriving the exact maximum and minimum value. Can someone guide me on how to do it?

Thanks

• The usual way to start would be to find critical points by computing where the partial derivatives both vanish. – amd Sep 1 '18 at 20:23
• Yes, I tried that. Its just that the derivatives become very complicated and I was wondering if there is a standard solution for the problem. – Khushboo Sep 1 '18 at 20:34
• It does look a bit messy, but not all that complicated. You only have to work with the numerators, which consist of a linear combination of quadrics, one of which is a pair of intersecting planes. – amd Sep 1 '18 at 20:45
• The critical point (rather than points) doesn't appear too bad: $\left\{x\to \frac{4 a e i-a h^2-2 b f i+b g h-2 c e g+c f h}{-2 a e g+a f h-2 b d h+b f g+4 c d e-c f^2},y\to \frac{-2 a f i+a g h+4 b d i-b g^2-2 c d h+c f g}{-2 a e g+a f h-2 b d h+b f g+4 c d e-c f^2}\right\}$. – JimB Sep 1 '18 at 22:37
• @JimB Messy, but promising. If you worked that out yourself (it looks like Mathematica output) you should post how as an answer. – amd Sep 1 '18 at 22:55

Proceeding in the usual way, find critical points of the function by setting its partial derivatives to zero and solving. You’re using $f$ for both the function and one of the coefficients in its definition, so I’ll call the function $F$ here. To reduce clutter, let $G(x,y)=dx^2+ey^2+fxy+gx+hy+i$, so that $F(x,y) = (ax+by+c) G(x,y)^{-1/2}$. Differentiating, we have \begin{align} F_x(x,y) &= (a G(x,y) - \frac12 (ax+by+c) (2dx+fy+g))G(x,y)^{-3/2} = 0 \\ F_y(x,y) &= (b G(x,y) - \frac12(ax+by+c)(fx+2ey+h))G(x,y)^{-3/2} = 0, \end{align} so the problem becomes that of finding the intersections of a pair of conics. A general strategy for doing this is to find a degenerate linear combination of the two conics, split it into linear factors and then solve the simpler line-conic intersections. In this case, we’re already most of the way there: subtract $2a$ times the second equation from $2b$ times the first to get $$(ax+by+c)\left[ (af-2bd)x + (2ae-bf)y + (ah-bg)\right] = 0,$$ which is already split into linear terms. The intersection points of the two conics are thus the intersections of the two lines defined by these factors with either of the two original conics.

Turning to the first line, setting $ax+by+c=0$ reduces the partial derivative equations to $aG(x,y)=0$ and $bG(x,y)=0$. Unless $a=b=0$, this means that $G(x,y)=0$, but $F$ is undefined in this region, so there can be no critical points there. That leaves the intersections of the line $$(af-2bd)x + (2ae-bf)y + (ah-bg) = 0$$ with either of the other conics, which I’ll leave to you to work out.

If you’re interested in exploring the qualitative behavior of this family of functions, I’d suggest examining the simpler cases in which $G(x,y)=0$ is one of the canonical examples of the different types of conics. All of the functions in this family can be obtained via an affine coordinate transformation from one of these canonical equations, which will move the critical points in a well-defined way.

If you need to produce contour plots with the critical point, here is some R code to do so.

The function critPoints takes 13 arguments: (1) the first 9 are a, b, c, d, e, f, g, h, and i and (2) the last 4 are xmin, xmin, ymin, and ymax for the range of values to show the contours. The function uses the 2nd partial derivative test to determine if the critical point is a relative minimum, relative maximum, saddle point, or undetermined.

critPoints = function(a,b,c,d,e,f,g,h,i, xmin, xmax, ymin, ymax) {

# Determinant
determ = (-0.25*(4*c*d*e - c*f**2 - 2*a*e*g + b*f*g - 2*b*d*h +
a*f*h)**6)/((c**2*(4*d*e - f**2) - (b*g - a*h)**2 +
2*c*(-2*a*e*g + b*f*g - 2*b*d*h + a*f*h) + 4*(b**2*d + a**2*e -
a*b*f)*i)**2*(-f*g*h + d*h**2 + f**2*i + e*(g**2 - 4*d*i))**3)

# Partial second derivative for x
fxx = (-(c**2*d*(4*d*e - f**2) + 2*c*d*(-2*a*e*g + b*f*g -
2*b*d*h + a*f*h) + g*(-b**2*d*g + 2*a*b*d*h + a**2*(e*g -
f*h)) + (-2*b*d + a*f)**2*i))/((4*c*d*e - c*f**2 - 2*a*e*g +
b*f*g - 2*b*d*h + a*f*h)*(((c**2*(-4*d*e + f**2) + (b*g -
a*h)**2 + c*(4*a*e*g - 2*b*f*g + 4*b*d*h - 2*a*f*h) -
4*(b**2*d + a**2*e - a*b*f)*i)*(-f*g*h + d*h**2 + f**2*i +
e*(g**2 - 4*d*i)))/(4*c*d*e - c*f**2 - 2*a*e*g + b*f*g -
2*b*d*h + a*f*h)**2)**1.5)

# Critical points
x0 = (-2*c*e*g + c*f*h + b*g*h - a*h**2 + 4*a*e*i - 2*b*f*i)/
(4*c*d*e - c*f**2 - 2*a*e*g + b*f*g - 2*b*d*h + a*f*h)
y0 = (-(c*f*g) + b*g**2 + 2*c*d*h - a*g*h - 4*b*d*i + 2*a*f*i)/
(-4*c*d*e + c*f**2 + 2*a*e*g - b*f*g + 2*b*d*h - a*f*h)

# Critical value
value = (a*x0 + b*y0 + c)/sqrt(d*x0^2 + e*y0^2 + f*x0*y0 + g*x0 + h*y0 + i);

# Type of critical value
status = "Indeterminant"
if (determ > 0 & fxx < 0) status = "Relative maximum"
if (determ > 0 & fxx > 0) status = "Relative minimum"
if (determ < 0) status = "Saddle point"

# Create a contour plot
n = 50
z = matrix(rep(NA,(n+1)^2), nrow=(n+1))
for (ix in 0:n) {
x = xmin + (xmax-xmin)*ix/n
for (iy in 0:n) {
y = ymin + (ymax-ymin)*iy/n
z[ix+1,iy+1] = (a*x + b*y + c)/sqrt(d*x^2 + e*y^2 + f*x*y + g*x + h*y + i)
}}
contour(x = xmin+(xmax-xmin)*c(0:n)/n,
y = ymin + (ymax-ymin)*c(0:n)/n,
z, nlevels = 10, las=1, labcex=1,
main=paste(status,"\nValue =",value))
points(x0, y0, pch=16, col="red")

# Return a summary
data.frame(status=status, value=value, x0=x0, y0=y0, determ=determ, fxx=fxx)

}


Here are some examples:

critPoints(1, 2,   3, 5,  1.2, 3.2, 5, 7, 2,      -1, 0, 1, 3)
#         status    value         x0       y0      determ        fxx
#   Saddle point 1.612708 -0.6427557 1.949574 -0.02584146 -0.4945823


critPoints(-2, 2, -6, 5, 10,   7,   1, 7, 8,      0.5, 1.5, -2, 0)
#           status    value        x0         y0   determ      fxx
# Relative minimum -3.19118 0.8495413 -0.8311927 4.002717 1.708459


 critPoints(-2, 2,  6, 5, 10,   7,   1, 7, 8,        -2, 0, -1, 1)
#          status    value        x0        y0   determ        fxx
#Relative maximum 2.403424 -0.800554 0.2077562 1.050759 -0.9305445


The critical point is given by

$$x_0 = \frac{4 a e i-a h^2-2 b f i+b g h-2 c e g+c f h}{-2 a e g+a f h-2 b d h+b f g+4 c d e-c f^2}$$

$$y_0 = \frac{2 a f i-a g h-4 b d i+b g^2+2 c d h-c f g}{2 a e g-a f h+2 b d h-b f g-4 c d e+c f^2}$$

The determinant is

$$D = -\frac{\left(-2 a e g+a f h-2 b d h+b f g+4 c d e-c f^2\right)^6}{4 \left(e \left(g^2-4 d i\right)+d h^2+f^2 i-f g h\right)^3 \left(4 i \left(a^2 e-a b f+b^2 d\right)+2 c (-2 a e g+a f h-2 b d h+b f g)-(b g-a h)^2+c^2 \left(4 d e-f^2\right)\right)^2}$$

and the second partial of the function for x evaluated at the critical point is given by

$$f_{xx} = -\frac{g \left(a^2 (e g-f h)+2 a b d h-b^2 d g\right)+2 c d (-2 a e g+a f h-2 b d h+b f g)+i (a f-2 b d)^2+c^2 d \left(4 d e-f^2\right)}{\left(-2 a e g+a f h-2 b d h+b f g+4 c d e-c f^2\right) \left(\frac{\left(e \left(g^2-4 d i\right)+d h^2+f^2 i-f g h\right) \left(-4 i \left(a^2 e-a b f+b^2 d\right)+c (4 a e g-2 a f h+4 b d h-2 b f g)+(b g-a h)^2+c^2 \left(f^2-4 d e\right)\right)}{\left(-2 a e g+a f h-2 b d h+b f g+4 c d e-c f^2\right)^2}\right)^{3/2}}$$

• Thanks a lot for the detailed answer! – Khushboo Sep 5 '18 at 14:58
• You're welcome. I used Mathematica to create the equations but because that software is not inexpensive, I showed the results using R. If you need the Mathematica code, I could add that. – JimB Sep 5 '18 at 15:09
• I downloaded Mathematica using my university license. There is so much I can do there. Thanks for letting me know about it. – Khushboo Sep 5 '18 at 17:36