Multivariable Optimization Calculator

Multivariable Optimization Calculator
Results are estimates for planning only.

How the Multivariable Optimization Calculator Works

Finding the peaks and valleys of a function of two variables is a core task in calculus, economics, engineering, and machine learning. The Multivariable Optimization Calculator applies the second-derivative test, which is the standard tool for classifying a critical point once you have found one. You enter the three second partial derivatives at that point, namely fxx, fyy, and fxy, and the calculator computes the discriminant D, which is fxx times fyy minus the square of fxy, then uses the sign of D and the sign of fxx to classify the point.

A critical point is a point where both first partial derivatives are zero, which means the surface is locally flat, like the top of a hill, the bottom of a bowl, or the middle of a mountain pass. The second-derivative test looks at the curvature in each direction to decide which shape you are standing on. If D is positive and fxx is positive, the surface curves upward in every direction and the point is a local minimum. If D is positive and fxx is negative, the surface curves downward in every direction and the point is a local maximum. If D is negative, the surface curves up in one direction and down in another, which is the signature of a saddle point.

This calculator starts from the second derivatives rather than from the function itself, which makes it useful in two common situations. Students can check their hand-computed derivatives and classifications quickly, and practitioners who have already estimated curvature from data or from a fitted model can classify a candidate optimum without redoing algebra. The tool assumes the point you are testing really is a critical point, so the first step in any real problem is still to solve for where the first partial derivatives vanish.

Inputs Explained

The three inputs are the second partial derivatives of your function evaluated at the critical point, and each one carries a distinct geometric meaning. The value fxx measures how the slope in the x direction changes as x increases, which is the curvature along the x axis. The value fyy does the same along the y axis. The mixed partial fxy measures how the slope in one direction changes as you move in the other direction, which captures the twist of the surface, and it is this twist term that makes the two-variable test richer than the single-variable version.

  • fxx: the second partial derivative with respect to x twice, evaluated at the critical point.
  • fyy: the second partial derivative with respect to y twice, evaluated at the critical point.
  • fxy: the mixed second partial derivative, with respect to x and then y, at the same point.
  • All three values must come from the same critical point for the classification to be valid.

Worked Example

Suppose the second derivatives at a critical point are fxx equals 2, fyy equals 3, and fxy equals 1. The discriminant is D equals 2 times 3 minus 1 squared, which is 5.0000. Since D is positive and fxx is positive, the calculator classifies the point as a local minimum, which matches the picture of a bowl-shaped surface that rises in every direction from the point.

Two more cases show the other outcomes. With fxx equals 1, fyy equals negative 1, and fxy equals 0, the discriminant is -1.0000, which is negative, so the point is a saddle point, curving up in one direction and down in the other. With fxx equals negative 2, fyy equals negative 4, and fxy equals 1, the discriminant is 7.0000, which is positive while fxx is negative, so the point is a local maximum. These three cases cover the main outcomes students meet in practice.

How to Read Your Results

Read the discriminant first, since its sign does most of the work. A positive D means the curvature has the same sign in the directions that matter, so the point is either a peak or a valley, and the sign of fxx breaks the tie. A negative D means the curvatures disagree, which is the saddle case, and no sign of fxx can rescue it into a peak or valley. A D of exactly zero means the test fails, and the point might be a peak, a valley, a saddle, or something flatter, so further analysis is needed.

Keep in mind that local does not mean global. A local minimum is the lowest point nearby, but the function may dip lower somewhere else entirely, and the same holds for a local maximum. For a global answer, you must also check the boundary of your domain and any other critical points. The second-derivative test is a local tool, and it is most powerful when combined with a picture of the whole surface or a scan of the domain.

Common Mistakes and Limitations

The most common mistake is feeding in derivatives from different points, or using derivatives of the wrong function after a substitution. All three second derivatives must be evaluated at the same critical point, and the mixed partial should be checked for consistency, since for most smooth functions the order of differentiation does not matter. Another frequent error is forgetting to verify that the point is actually critical, because the test says nothing useful if the first derivatives are not zero there.

The test also fails silently in one case that students often miss, which is D equals zero. A zero discriminant does not mean the point is uninteresting, only that curvature alone cannot decide it, and examples exist of minima, maxima, and saddles that all give D equals zero. In that case, look at higher-order terms, examine the function along lines through the point, or use a contour plot to see the shape directly.

Working Through a Full Example

Seeing the test applied to a complete function makes the abstract rules concrete, so consider the function f of x and y equal to x squared plus 3 y squared plus x times y. The first partial derivatives are 2x plus y and 6y plus x, and setting both to zero gives the critical point at the origin, where x and y are both zero. The second derivatives are fxx equals 2, fyy equals 6, and fxy equals 1, so the discriminant is 2 times 6 minus 1 squared, which is 11. Since the discriminant is positive and fxx is positive, the origin is a local minimum, which matches the bowl shape of a sum of squares with a small cross term.

A second function shows the maximum case. Take f equal to negative x squared minus 2 y squared plus x times y, whose first derivatives vanish at the origin as well. The second derivatives are fxx equals negative 2, fyy equals negative 4, and fxy equals 1, giving a discriminant of 8 minus 1, which is 7. The discriminant is positive while fxx is negative, so the origin is a local maximum, like the top of a hill that falls away in every direction. Students often check this case by completing the square, which confirms the hill shape independently of the test.

A third function shows the saddle case. Take f equal to x squared minus y squared, whose derivatives also vanish at the origin. Here fxx equals 2, fyy equals negative 2, and fxy equals 0, giving a discriminant of negative 4. The negative discriminant means the surface rises along the x direction and falls along the y direction, which is exactly a mountain pass. Walking east you climb, walking north you descend, and the origin is neither a peak nor a valley, which is why saddle points are so important in optimization and in game theory.

The Geometry Behind the Test

The discriminant is not a magic formula, since it is the determinant of the Hessian matrix, which is the two-by-two matrix of second derivatives with fxx and fyy on the diagonal and fxy on both off-diagonal entries. The determinant of that matrix tells you about the eigenvalues, which are the curvatures along the principal directions of the surface. A positive determinant with a positive trace means both eigenvalues are positive, which is upward curvature everywhere and a minimum. A positive determinant with a negative trace means both are negative, which is a maximum. A negative determinant means the eigenvalues have opposite signs, which is a saddle.

Thinking in terms of eigenvalues also explains why the mixed partial matters so much. Without a cross term, the principal directions line up with the x and y axes, and the test reduces to checking the signs of fxx and fyy separately. With a large cross term, the principal directions rotate, and the surface can curve upward along a diagonal while curving downward along the axes. The discriminant captures that rotation in a single number, which is why a function can have positive fxx and positive fyy yet still be a saddle when the cross term is large enough to make the discriminant negative.

This geometric view also connects the two-variable test to higher dimensions, where the Hessian becomes a larger matrix and the test becomes a check on whether that matrix is positive definite, negative definite, or indefinite. The two-variable case is the smallest setting where all three outcomes appear, which is why it is taught first and why it builds the right intuition for machine learning, where loss surfaces in thousands of dimensions are analyzed with exactly the same ideas.

When the Test Fails

The test fails when the discriminant is exactly zero, and that case is more interesting than it sounds, since it contains minima, maxima, and saddles all hiding behind the same zero. The function x to the fourth plus y to the fourth has a minimum at the origin with a zero discriminant, because its curvature vanishes there even though the function rises in every direction. The function x to the fourth minus y to the fourth has a saddle at the origin with the same zero discriminant, because it rises along x and falls along y. The two functions look identical to the second-derivative test, yet their shapes are completely different.

When you meet a zero discriminant, the next step is to look at higher-order terms, since the fourth-order behaviour decides what the second-order terms could not. Expanding the function around the point and examining the lowest nonzero terms usually reveals the shape, and checking the function along lines through the point, such as the x axis, the y axis, and the diagonals, often settles the question quickly. If the function rises along every line you test, you likely have a minimum, while a single descending line proves the point is not a minimum at all.

Plotting is the most practical fallback. A contour plot or a three-dimensional surface plot shows the shape around the point directly, and modern tools make such plots in seconds. Use the plot to form a hypothesis, then confirm it with algebra along well-chosen lines, since a picture can mislead near very flat points. The calculator handles the common cases instantly, and the zero case is your invitation to look deeper, which is often where the real understanding begins.

Connecting the Test to Real Optimization Problems

In applied work, the second-derivative test rarely appears alone, since it usually sits inside a larger workflow of modelling, solving, and verifying. An economist might fit a profit function to data, find where marginal profit vanishes in each input, and then use the test to confirm that the candidate point is a maximum rather than a saddle that only looks profitable from one angle. An engineer might optimize a design with two free parameters, such as thickness and length, and use the test to confirm that a candidate design is genuinely best nearby rather than merely flat. A machine learning practitioner meets the same geometry in loss landscapes, where saddle points are far more common than true minima in high dimensions, and understanding the two-variable case builds the intuition needed to reason about those landscapes. In every field the workflow is the same, which is to find candidate points, classify them locally, check the boundaries, and then verify the winner against the real objective. The calculator handles the classification step instantly, which leaves you free to spend your effort on the modelling and verification steps that actually decide whether an optimum is useful. Practising that full workflow on textbook functions, where the answers are known, is the fastest way to build confidence for real problems where the answers are not.

Frequently Asked Questions

What is a critical point?

A critical point is a point where both first partial derivatives are zero, so the surface is locally flat there.

What is the discriminant D?

D is fxx times fyy minus the square of fxy, and its sign drives the second-derivative test.

When is a point a local minimum?

When D is positive and fxx is positive, the surface curves upward in every direction from the point.

When is a point a local maximum?

When D is positive and fxx is negative, the surface curves downward in every direction from the point.

What is a saddle point?

A saddle point curves upward in one direction and downward in another, like a mountain pass.

What does D equal to zero mean?

It means the test is inconclusive, so the point needs higher-order analysis or a direct look at the surface.

Do I need the function itself?

No, this calculator only needs the three second partial derivatives evaluated at the critical point.

What is fxy measuring?

The mixed partial measures how the slope in one direction changes as you move in the other direction, which is the twist of the surface.

Can a local minimum be a global minimum?

Only if it is also lower than every boundary value and every other critical point in the domain.

Does the test work for more variables?

The idea extends with the Hessian matrix, but this calculator is built for exactly two variables.

Why must all derivatives be at the same point?

Because the test describes the local shape at one point, so mixing points mixes shapes.

What if fxx is zero but D is positive?

That case cannot happen with D positive unless fxy is imaginary, so check your derivatives if you see it.

Can I use decimal derivative values?

Yes, any real numbers work, and the calculator handles decimals and negative values.

Is a saddle point a bad result?

Not at all, since saddle points are important in optimization, game theory, and machine learning landscapes.

How do I find critical points first?

Set both first partial derivatives to zero and solve the resulting system for x and y.