Level Curves Calculator

Slice a surface at constant heights and read its hills, valleys, and passes from the contour map.

Level Curves Calculator

Draws the contour map of f(x, y): curves where f is constant.

What Are Level Curves?

Level curves (or contour lines) are the curves in the plane where a function of two variables takes a constant value:

f(x, y) = c   for a chosen constant c.

Each level curve is a horizontal slice of the surface z = f(x, y), the set of all input points that produce the same output height. Drawing several of them at evenly spaced heights produces a contour map, the same device that shows elevation on a topographic map or temperature on a weather chart. The map compresses a three-dimensional surface into a two-dimensional picture, and from it you can read the entire shape of the surface: closed loops surround peaks and pits, tightly packed curves mark steep terrain, widely spaced curves mark gentle slopes, and crossing patterns reveal saddle points. This calculator draws the contour map of your function over a chosen window, selecting representative levels automatically and explaining how to read the resulting picture.

How to Use the Level Curves Calculator

Enter f(x, y) and a viewing window for x and y. The tool samples the function to determine its range, selects several level values spread across that range, and draws the corresponding contour curves. The steps report the levels drawn, explain how contour spacing encodes steepness, and describe the gradient's perpendicular relationship to the curves. The graph is the contour map itself. This visualizes the surfaces whose slopes the gradient calculator computes and whose critical points the multivariable critical points calculator classifies; the gradient is always perpendicular to these level curves, a fact central to directional derivatives.

Worked Example

Consider the paraboloid f(x, y) = x² + y², an upward bowl. Its level curves are given by

x² + y² = c,   which are circles of radius √c centered at the origin (for c > 0).

The contour map is a family of concentric circles, and their spacing tells the story of the surface. Because the circles for equally spaced heights c = 1, 2, 3, 4 have radii 1, 1.41, 1.73, 2, they crowd together as you move outward: the surface gets steeper away from the center, exactly as a paraboidal bowl does. The single point at the center (where c = 0) is the minimum. Change the function to x² − y² (the second chip) and the level curves become hyperbolas, with the level c = 0 forming an X of two crossing lines, the signature of a saddle point, where the surface rises in one direction and falls in the perpendicular one. Reading these patterns, closed loops for extrema, crossing curves for saddles, is a core skill of multivariable calculus.

Why the Gradient Is Perpendicular to Level Curves

The single most important fact about contour maps is that the gradient ∇f is always perpendicular to the level curves, and it points in the direction of steepest increase. The reason is clean: along a level curve, f does not change (it is constant by definition), so the directional derivative of f in the direction of the curve is zero. But the directional derivative is ∇f dotted with the direction, so ∇f must be perpendicular to the curve's tangent, that is what makes the dot product vanish. This is why a hiker following a contour line stays at constant elevation and feels no uphill or downhill pull, while stepping perpendicular to the contours is the steepest possible climb. The spacing of the contours encodes the gradient's magnitude: where curves bunch tightly, a small horizontal step crosses many levels, so the surface is steep and |∇f| is large; where curves spread apart, the surface is gentle and |∇f| is small. This perpendicularity underlies gradient descent (which moves against the gradient, crossing contours at right angles toward a minimum), the method of Lagrange multipliers (where an optimum occurs when a constraint curve is tangent to a level curve of the objective), and the entire visual language of reading multivariable functions from their contour maps.

Common Mistakes to Avoid

  • Confusing level curves with the graph of the surface. Level curves live in the 2D input plane; the surface lives in 3D. The contour map is the surface's shadow-with-labels, not the surface itself.
  • Reading contour spacing backward. Closely spaced contours mean steep terrain (large gradient), widely spaced means gentle. Confusing the two inverts every conclusion about where the function changes fastest.
  • Assuming contours are always closed loops. Only extrema produce closed loops. Saddles produce crossing or hyperbola-like curves, and monotone surfaces (like a tilted plane) produce parallel straight lines. The pattern reveals the critical-point type.
  • Expecting evenly spaced levels to mean evenly spaced curves. Equal height increments produce unequal curve spacing precisely because the surface's steepness varies; that unevenness is the information, not an error.
  • Forgetting the gradient direction. The gradient is perpendicular to contours and points toward higher values (uphill). Getting the direction wrong reverses steepest-ascent and steepest-descent reasoning.

Real-World Applications

Contour maps are among the most widely used scientific visualizations, precisely because they turn an abstract function of two variables into a readable picture. Cartography invented them: topographic maps show land elevation as contour lines, and reading terrain steepness, ridges, valleys, and passes from contour spacing is a fundamental skill in hiking, surveying, and civil engineering. Meteorology draws isobars (curves of constant pressure) and isotherms (constant temperature) on weather maps, where tightly packed isobars signal strong winds, exactly the steep-gradient reading.

Frequently Asked Questions

What is a level curve?

The set of points (x, y) where a function f(x, y) equals a fixed constant c. It is a horizontal slice of the surface z = f(x, y), showing all inputs that give the same output. Drawing several at different constants creates a contour map of the function.

How do I read steepness from a contour map?

By the spacing. Closely packed level curves mean the function changes rapidly over a short distance, so the surface is steep and the gradient is large. Widely spaced curves mean gentle change and a small gradient. Contour density is a direct visual measure of steepness.

Why is the gradient perpendicular to level curves?

Because f is constant along a level curve, its rate of change in the curve's direction is zero. Since that rate is ∇f dotted with the direction, the gradient must be perpendicular to the curve's tangent. The gradient therefore points across contours, in the direction of steepest increase.

What do closed loops in a contour map mean?

They surround a local maximum (a peak) or minimum (a pit). Nested closed loops shrinking toward a point indicate an extremum there, with the innermost loop nearest the peak or bottom. Weather maps use closed isobars to mark high- and low-pressure centers this way.

How do saddle points appear on a contour map?

As crossing curves, often forming an X or hyperbola pattern at the critical level. A saddle rises in one direction and falls in the perpendicular direction, so its contours do not close into loops but instead pass through, like the level x² − y² = 0 forming two intersecting lines.

Why are equally spaced levels drawn as unequally spaced curves?

Because the surface's steepness varies. Equal height increments cross the surface at different horizontal spacings depending on the slope: steep regions pack the curves close, gentle regions spread them out. This uneven spacing is exactly the information a contour map conveys about the gradient.

What is the difference between a level curve and a level set?

For a two-variable function the level set f = c is a curve, hence "level curve." For three variables f(x, y, z) = c the level set is a surface (a level surface), and in higher dimensions it is a hypersurface. Level curve is the 2D case of the general level-set concept.

How are level curves used in optimization?

Gradient descent moves perpendicular to level curves toward lower values, and constrained optimization by Lagrange multipliers finds where a constraint curve is tangent to a level curve of the objective, meaning their gradients align. Visualizing the contours makes both methods geometrically transparent.

What are equipotential lines?

Level curves of a potential function (electric, gravitational, or fluid). They are always perpendicular to the field lines, because the field is the gradient of the potential and the gradient is perpendicular to level curves. Physicists read field strength from equipotential spacing exactly as one reads steepness from a topographic map.

Can a level curve be a single point or empty?

Yes. At an extremum the level equals the function's minimum or maximum value, and the level set can shrink to a single point (the bottom of a bowl, f = 0 for x² + y²). For values outside the function's range, the level set is empty, no input achieves that height.