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.
Completing the Square in a Mixed-Term Function
Consider the function
To complete the square in \(x\), take half the coefficient of \(x\), treating \(y\) as fixed. Half of \(y\) is \(y/2\), so
Including the remaining term \(-y^2\) gives
The two squared quantities have opposite signs. It is convenient to name them:
Then \(f=u^2-v^2\). These are not arbitrary labels: the change of coordinates is reversible. Solving for the original coordinates gives
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)\).
Why the Rewrite Works
Completing the square is valid because expanding the new expression reproduces the original function exactly. Here is the full check:
\(\left(x+\frac{y}{2}\right)^2=x^2+xy+\frac{y^2}{4}\).
\(\frac{y^2}{4}-\frac{5y^2}{4}=-y^2\).
\(\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
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
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:
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
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
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
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
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:
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
Expanding the right-hand side shows the problem:
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\):
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.
Write the contour equation \(f(x,y)=c\) for a value such as a positive number, zero, or a negative number.
Rewrite the quadratic exactly and verify it by expanding.
Use the signs and the value of \(c\) to determine the basic pattern in the new coordinates.
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.
- Complete the square for \(f(x,y)\), and verify the result by expanding.
- What is the equation of the contour at level \(c=0\) in the coordinates \(u=x+y/2\) and \(v=\sqrt{5}y/2\)?
- Find two points on the level \(f(x,y)=4\) by setting \(v=0\), and check them in the original formula.
- For the level \(f(x,y)=-5\), set \(u=0\). Find the resulting points in \((x,y)\)-coordinates and verify one by substitution.
- Why must a point found in completed-square coordinates be converted back before plotting it in the original \(xy\)-plane?