Tutorials › Calculus III › Mixed-Term Functions and Their Contours

Graphs, Traces, and Level Sets · Tutorial 261 of 999

Mixed-Term Functions and Their Contours

Learn to complete squares in mixed-term functions and use representative level values to sketch their contour patterns.

Beginner 9 min read

What You'll Learn

  • Define contours as level sets and identify the mixed term in a quadratic function.
  • Complete the square to rewrite a quadratic using new linear coordinates.
  • Convert points between the original and completed-square coordinates.
  • Sketch positive, zero, and negative levels of a mixed-term function.
  • Check contour equations and points by substitution.

Why Mixed Terms Change a Contour Sketch

A function such as \(f(x,y)=x^2+y^2\) depends on the squares of the individual coordinates. A mixed-term function also contains a product such as \(xy\). That product affects the shape and direction of its contours, so reading the formula as though its terms acted independently can lead to a misleading sketch.

A useful first step is to complete the square. This rewrites the expression using combinations of \(x\) and \(y\), making the level curves easier to recognize. We will use the function \(f(x,y)=x^2+xy-y^2\) to see how positive, zero, and negative levels lead to different contour patterns.

Definition: For a function \(f:\mathbb{R}^2\to\mathbb{R}\), the contour at level \(c\) is the set of points \((x,y)\) satisfying \(f(x,y)=c\). A contour is also called a level curve.

Completing the Square in a Mixed-Term Function

Consider the function

$$ f(x,y)=x^2+xy-y^2. $$

To complete the square in \(x\), take half the coefficient of \(x\), treating \(y\) as fixed. Half of \(y\) is \(y/2\), so

$$ x^2+xy = \left(x+\frac{y}{2}\right)^2-\frac{y^2}{4}. $$

Including the remaining term \(-y^2\) gives

$$ f(x,y) = \left(x+\frac{y}{2}\right)^2-\frac{y^2}{4}-y^2 = \left(x+\frac{y}{2}\right)^2-\frac{5y^2}{4}. $$

The two squared quantities have opposite signs. It is convenient to name them:

$$ u=x+\frac{y}{2}, \qquad v=\frac{\sqrt{5}}{2}y. $$

Then \(f=u^2-v^2\). These are not arbitrary labels: the change of coordinates is reversible. Solving for the original coordinates gives

$$ y=\frac{2v}{\sqrt{5}}, \qquad x=u-\frac{v}{\sqrt{5}}. $$

Thus every point \((u,v)\) represents exactly one point \((x,y)\), and vice versa. A contour of the original function can therefore be understood by first looking at the simpler equation \(u^2-v^2=c\), then converting relevant points back to \((x,y)\).

Key result: For \(f(x,y)=x^2+xy-y^2\), completing the square gives \(f=u^2-v^2\), where \(u=x+y/2\) and \(v=\sqrt{5}y/2\). Its level-\(c\) contour is therefore described by \(u^2-v^2=c\).

Why the Rewrite Works

Completing the square is valid because expanding the new expression reproduces the original function exactly. Here is the full check:

1
Expand the first square.
\(\left(x+\frac{y}{2}\right)^2=x^2+xy+\frac{y^2}{4}\).
2
Combine the \(y^2\) terms.
\(\frac{y^2}{4}-\frac{5y^2}{4}=-y^2\).
3
Recover the original expression.
\(\left(x+\frac{y}{2}\right)^2-\frac{5y^2}{4}=x^2+xy-y^2\), as required.

More generally, for real constants \(a,b,c\) with \(a\ne 0\), the quadratic expression \(ax^2+bxy+cy^2\) can be written as

$$ ax^2+bxy+cy^2 = a\left(x+\frac{b}{2a}y\right)^2 + \left(c-\frac{b^2}{4a}\right)y^2. $$

To verify the identity, expand the square: its \(x^2\) term is \(ax^2\), its mixed term is \(bxy\), and its \(y^2\) term is \(b^2y^2/(4a)\). Adding the displayed remaining coefficient of \(y^2\) leaves \(cy^2\). The condition \(a\ne 0\) is necessary for the fractions in this form to be defined. If \(a=0\), this particular completion in \(x\) is unavailable; a different arrangement may be needed.

Worked Example: A Positive Level

Worked Example: Sketching the Level \(f(x,y)=4\)

For \(f(x,y)=x^2+xy-y^2\), the completed-square coordinates give the contour equation

$$ u^2-v^2=4. $$

In the \((u,v)\)-coordinates, setting \(v=0\) gives \(u^2=4\), so \(u=2\) or \(u=-2\). Converting these points back with \(x=u-v/\sqrt{5}\) and \(y=2v/\sqrt{5}\) gives \((x,y)=(2,0)\) and \((-2,0)\).

For another pair of points, set \(v=1\). Then \(u^2-1=4\), so \(u^2=5\) and \(u=\sqrt{5}\) or \(u=-\sqrt{5}\). The corresponding original-coordinate points are \((4/\sqrt{5},2/\sqrt{5})\) and \((-6/\sqrt{5},2/\sqrt{5})\).

Check the first point \((4/\sqrt{5},2/\sqrt{5})\) in the original function:

$$ \left(\frac{4}{\sqrt{5}}\right)^2 +\left(\frac{4}{\sqrt{5}}\right)\left(\frac{2}{\sqrt{5}}\right) -\left(\frac{2}{\sqrt{5}}\right)^2 = \frac{16}{5}+\frac{8}{5}-\frac{4}{5} = 4. $$

So the point lies on the level \(4\). In the completed-square coordinates, the contour has two branches extending in the positive and negative \(u\)-directions. The coordinate conversion maps those branches back to the \((x,y)\)-plane. The listed points provide checks for the sketch; they are not, by themselves, a complete drawing.

The Zero Level and the Two-Line Contour

At level \(c=0\), the equation in completed-square coordinates is \(u^2-v^2=0\). Factoring gives \((u-v)(u+v)=0\), so the level consists of the two lines \(u=v\) and \(u=-v\). In original coordinates, an equivalent calculation is

$$ x^2+xy-y^2 = \left(x-\frac{-1+\sqrt{5}}{2}y\right) \left(x-\frac{-1-\sqrt{5}}{2}y\right). $$

For a product of two real numbers to equal zero, at least one factor must be zero. Therefore the zero contour is the pair of lines

$$ x=\frac{-1+\sqrt{5}}{2}y \qquad\text{or}\qquad x=\frac{-1-\sqrt{5}}{2}y. $$

This factorization can be checked by multiplying: the coefficient of \(xy\) is the negative of the sum of the two displayed roots, which is \(1\), and the coefficient of \(y^2\) is their product, which is \(-1\). The \(x^2\) coefficient is \(1\). The result is exactly \(x^2+xy-y^2\).

Worked Example: Finding and Checking Points on the Zero Contour

Take \(y=1\). The two lines give \(x=(-1+\sqrt{5})/2\) and \(x=(-1-\sqrt{5})/2\). To check the first point, write \(r=(-1+\sqrt{5})/2\). This number satisfies \(r^2+r-1=0\), since

$$ r^2+r-1 = \frac{(-1+\sqrt{5})^2}{4} +\frac{-1+\sqrt{5}}{2}-1 = \frac{6-2\sqrt{5}-2+2\sqrt{5}-4}{4} = 0. $$

Thus \(f(r,1)=r^2+r-1=0\), as required. The other line also gives zero: for \(s=(-1-\sqrt{5})/2\), direct substitution yields \(s^2+s-1=0\). So both lines are part of the level \(0\), not just candidate lines from the factorization.

Worked Example: A Negative Level

Worked Example: Sketching the Level \(f(x,y)=-5\)

The completed-square equation for this contour is

$$ u^2-v^2=-5. $$

Set \(u=0\). Then \(-v^2=-5\), so \(v^2=5\), giving \(v=\sqrt{5}\) or \(v=-\sqrt{5}\). Convert each point back using \(y=2v/\sqrt{5}\) and \(x=u-v/\sqrt{5}\). For \(v=\sqrt{5}\), this gives \((x,y)=(-1,2)\); for \(v=-\sqrt{5}\), it gives \((x,y)=(1,-2)\).

Check the first point in the original function:

$$ f(-1,2)=(-1)^2+(-1)(2)-(2)^2=1-2-4=-5. $$

For additional points, set \(u=2\). Then \(4-v^2=-5\), so \(v^2=9\), giving \(v=3\) or \(v=-3\). The corresponding points are \((2-3/\sqrt{5},6/\sqrt{5})\) and \((2+3/\sqrt{5},-6/\sqrt{5})\). In the \((u,v)\)-plane this level has branches extending in the positive and negative \(v\)-directions. The conversion formulas locate these branches in the original coordinate plane.

Comparing Representative Levels

Different choices of \(c\) change the equation \(u^2-v^2=c\). Consider what happens in each case:

Level Equation in \((u,v)\) Contour description
\(c>0\) \(u^2-v^2=c\) Two branches extending in the \(u\)-direction
\(c=0\) \(u^2-v^2=0\) The two lines \(u=v\) and \(u=-v\)
\(c<0\) \(v^2-u^2=-c\) Two branches extending in the \(v\)-direction

This comparison helps guide a contour sketch, but it does not mean the contours are aligned with the original \(x\)- and \(y\)-axes. The coordinates \(u\) and \(v\) combine the original coordinates, and the inverse formulas are needed to place points correctly in the original plane.

A Common Completing-Square Error

A frequent mistake is to complete the square correctly in the first two terms but then keep the wrong leftover coefficient. For this function, an incorrect calculation might be

$$ x^2+xy-y^2 \mathrel{\color{red}{\not=}} \left(x+\frac{y}{2}\right)^2-y^2. $$

Expanding the right-hand side shows the problem:

$$ \left(x+\frac{y}{2}\right)^2-y^2 = x^2+xy+\frac{y^2}{4}-y^2 = x^2+xy-\frac{3y^2}{4}. $$

The coefficient of \(y^2\) is \(-3/4\), not \(-1\). The correction is to subtract the extra \(y^2/4\) introduced when completing the square, as well as the original \(y^2\):

$$ x^2+xy-y^2 = \left(x+\frac{y}{2}\right)^2-\frac{y^2}{4}-y^2 = \left(x+\frac{y}{2}\right)^2-\frac{5y^2}{4}. $$

Expanding the final expression is a quick and reliable check whenever you complete a square.

Using the Method to Sketch

For a quadratic function with a mixed term, a practical contour sketch begins by rewriting the expression and then examining a few representative levels. Keep the coordinate conversion visible throughout: it connects the simpler equation to the location of points in the original plane.

1
Choose a level.
Write the contour equation \(f(x,y)=c\) for a value such as a positive number, zero, or a negative number.
2
Complete the square.
Rewrite the quadratic exactly and verify it by expanding.
3
Read the simpler level equation.
Use the signs and the value of \(c\) to determine the basic pattern in the new coordinates.
4
Convert and check points.
Use the inverse coordinate formulas to plot representative points, then substitute them into the original function.

These steps matter because a few correct points are not a contour sketch on their own. The level equation describes every point on the contour; the chosen points help place its branches and check the drawing against the original formula.

Check Your Understanding

Use \(f(x,y)=x^2+xy-y^2\) unless a question gives a different function.

  1. Complete the square for \(f(x,y)\), and verify the result by expanding.
  2. What is the equation of the contour at level \(c=0\) in the coordinates \(u=x+y/2\) and \(v=\sqrt{5}y/2\)?
  3. Find two points on the level \(f(x,y)=4\) by setting \(v=0\), and check them in the original formula.
  4. For the level \(f(x,y)=-5\), set \(u=0\). Find the resulting points in \((x,y)\)-coordinates and verify one by substitution.
  5. Why must a point found in completed-square coordinates be converted back before plotting it in the original \(xy\)-plane?