One Formula, Several Surface Patches
A function of two variables can be defined by different formulas on different parts of its domain. Its graph is then assembled from surface patches: each formula determines heights only over the region where that formula applies. The contour map is assembled in the same way. A contour equation must be solved separately on each region, and each resulting curve must be restricted to that region.
The main challenge is not usually solving the equations. It is keeping track of where each solution is valid, especially along the curve where the defining rule changes. That boundary may be included in one region, shared by both formulas, or assigned a height that differs from the height approached from the other side.
For a graph, each point \((x,y)\) in a region contributes the point \((x,y,f_i(x,y))\) in three-dimensional space. For a contour, the same point is retained when its height equals \(c\). In either case, the formula is not used outside its assigned region.
A Reliable Sketching Procedure
Begin by identifying the regions and the curve or curves that separate them. Then work with one formula at a time. For a surface sketch, use each formula to determine heights over its own region. For a contour at height \(c\), solve \(f_i(x,y)=c\), then keep only the solutions in \(D_i\). Finally, inspect the boundary: determine which rule applies there and compare the heights from the adjoining pieces.
Write down the inequalities defining where each formula applies. Include the boundary in the region specified by the inequality.
Use the formula only over the part of the domain assigned to it; do not extend a patch across a boundary unless the definition does so.
Set each formula equal to the chosen height, solve, and intersect the solution with its assigned region.
Use the actual boundary rule to decide which points belong, and compare the heights on the two sides to see whether the patches meet.
Worked Example: Two Planes Meeting Along a Boundary
Worked Example: Two Planes Meeting Along a Boundary
Consider the function
The dividing line is \(x=0\). The left patch is the plane \(z=y\), restricted to \(x<0\); the right patch is the plane \(z=x+y\), restricted to \(x\ge 0\). The line itself belongs to the right-hand region. At \(x=0\), that rule gives \(z=0+y=y\), the same height as the left-hand formula would give there.
At height \(c\), solve on the left:
This is the horizontal line \(y=c\) restricted to the left half-plane. On the right, solve:
Thus the full contour consists of a leftward horizontal ray and a right-hand sloping ray, meeting at \((0,c)\). For example, at \(c=1\), the pieces are \(y=1\) for \(x<0\) and \(y=1-x\) for \(x\ge0\). The left piece has height \(f(x,1)=1\). On the right piece, \(f(x,1-x)=x+(1-x)=1\). At their meeting point, \(f(0,1)=0+1=1\).
At \(c=0\), the pieces are \(y=0\) for \(x<0\) and \(y=-x\) for \(x\ge0\). Substitution gives \(f(x,0)=0\) on the left and \(f(x,-x)=x-x=0\) on the right. In both cases, the boundary point \((0,0)\) is included by the right-hand rule and has height zero.
The surface patches meet along the line \(x=0\), where both give \(z=y\). The contour pieces also meet at \((0,c)\) for every height \(c\). This agreement does not mean the formulas are identical; it means their heights agree on the boundary.
Why Restricting the Solutions Is Necessary
For a fixed height \(c\), let \(C\) be the contour of the piecewise function and let \(C_i\) be the set of points in region \(D_i\) where the \(i\)-th formula equals \(c\). Then the contour is exactly the union of the restricted pieces.
To justify this, take any point \((x,y)\) in the contour on the left. It belongs to the domain, so it lies in one of the regions \(D_i\). On that region, \(f(x,y)=f_i(x,y)\). Since \(f(x,y)=c\), it follows that \(f_i(x,y)=c\), and the point belongs to the corresponding set on the right. Conversely, any point in a set on the right lies in some \(D_i\) and satisfies \(f_i(x,y)=c\). The piecewise definition gives \(f(x,y)=f_i(x,y)\) there, so \(f(x,y)=c\). The point therefore belongs to the contour on the left. Both inclusions hold, proving the equality.
This argument explains why solving a piecewise contour equation without applying the region restrictions can add false points. A solution of one formula is a contour point only if that formula is the one defining the function at that point.
Worked Example: Different Curvature on the Two Sides
Worked Example: Different Curvature on the Two Sides
Consider
The left patch is the left half of the bowl \(z=2x^2+y^2\); the right patch is the right half of \(z=x^2+y^2\). At \(x=0\), both expressions give \(z=y^2\), and the boundary is assigned to the right-hand rule.
At height \(c=4\), the left contour satisfies \(2x^2+y^2=4\) with \(x<0\). It is the left half of an ellipse. The right contour satisfies \(x^2+y^2=4\) with \(x\ge0\), the right half of a circle. At the dividing line, both equations give \(y^2=4\), so the pieces meet at \((0,2)\) and \((0,-2)\).
Check representative points. At \((-\sqrt{2},0)\), the point is in the left region and
At \((2,0)\), the point is in the right region and \(f(2,0)=2^2+0^2=4\). At the boundary point \((0,2)\), the right-hand rule gives \(f(0,2)=0^2+2^2=4\). Each point lies on the claimed contour.
For \(c=0\), both formulas can equal zero only when \(x=0\) and \(y=0\), so the contour is the single point \((0,0)\). For \(c<0\), there are no contour points, because both formulas are sums of nonnegative terms. These checks also show that the same region-based method handles different heights without changing the boundary rule.
When the Patches Do Not Meet
Not every piecewise graph joins smoothly—or even joins continuously—at its dividing curve. The formula that applies on the boundary determines the graph there. Heights approached from a neighboring region may differ from that assigned boundary height. A contour can therefore have an included endpoint on the boundary, an excluded endpoint, or no nearby piece from one side.
Worked Example: A Jump Across the Boundary
Let
The upper region includes the boundary \(y=0\), where the assigned height is \(x^2\). The lower patch is the bowl \(z=x^2+y^2+2\), restricted to \(y<0\). For a fixed \(x\), the upper heights approach \(x^2\) at the boundary, while lower heights approach \(x^2+2\). The two patches have a vertical separation of two units at the seam; the boundary itself belongs to the upper patch.
At height \(c=1\), the upper rule gives \(x^2+y^2=1\) with \(y\ge0\), the upper semicircle including its endpoints. The lower rule would require \(x^2+y^2=-1\), which has no real solutions. The contour is just that upper semicircle.
At height \(c=3\), the upper rule gives \(x^2+y^2=3\) with \(y\ge0\), including its endpoints. The lower rule gives \(x^2+y^2=1\) with \(y<0\), the lower semicircle without its endpoints. Check the upper point \((0,\sqrt{3})\): it has \(f(0,\sqrt{3})=0+3=3\). Check the lower point \((0,-1)\): it has \(f(0,-1)=0+1+2=3\). The upper endpoints \((\pm\sqrt{3},0)\) are included and have height \(3\) under the upper rule. The lower circle's endpoints \((\pm1,0)\) are excluded from the lower region; their actual boundary height is \(1\), not \(3\).
At height \(c=2\), the upper solution is \(x^2+y^2=2\) with \(y\ge0\). The lower equation becomes \(x^2+y^2=0\), whose only candidate is \((0,0)\); it is not in the lower region because that region requires \(y<0\). The contour is therefore only the upper semicircle of radius \(\sqrt{2}\), with its endpoints. This example shows why a candidate on a region boundary must always be checked using the rule that actually applies there.
A Common Mistake: Drawing Every Full Curve
A frequent error is to solve each equation correctly but draw its entire solution curve, ignoring the region restriction. For the previous example with different curvature, the height-four equation on the left is \(2x^2+y^2=4\) with \(x<0\). Drawing the full ellipse would incorrectly include \((\sqrt{2},0)\). But that point has \(x>0\), so the right-hand rule applies there and gives
not \(4\). The correction is to keep only the left half of the ellipse, then draw the right half-circle from the right-hand equation. Likewise, a point on the dividing line must be evaluated using the boundary assignment in the original definition.
Reading and Checking the Finished Sketch
A useful piecewise sketch should communicate three things clearly: which formula governs each region, which portions of the resulting surfaces or curves are retained, and what happens at the boundary. For surface sketches, compare the formulas on the dividing curve to decide whether the patches meet or have different heights. For contour maps, solve for each region separately and check endpoints and boundary intersections. If a point appears in a contour, substitution into the original piecewise definition—not merely into an equation used to find it—is the decisive check.
This way of working is useful whenever a model changes its rule across a threshold, such as a cost formula that changes after a quantity limit or a height function defined differently on either side of a line. A contour can still be found by solving equations, but the region conditions are part of the answer, not optional annotations.
Check Your Understanding
Use the region restrictions as well as the equations when answering these questions.
- For \(f(x,y)=y\) when \(x<0\) and \(f(x,y)=x+y\) when \(x\ge0\), describe the contour at height \(c=2\), including the point where its pieces meet.
- For \(f(x,y)=2x^2+y^2\) when \(x<0\) and \(f(x,y)=x^2+y^2\) when \(x\ge0\), which halves of the ellipse and circle form the height-four contour?
- In a piecewise definition with a region \(y\ge0\) and another region \(y<0\), which rule must be used at a point where \(y=0\)?
- For the jump example, why is \((1,0)\) not on the height-three contour, even though it lies on the circle \(x^2+y^2=1\)?
- State the two inclusions that justify expressing a piecewise contour as the union of the region-restricted contours.