Rotations and quadratic functions with cross termsWorksheet by Mike May, S.J. - maymk@slu.eduEdited by Russell Blyth - blythrd@slu.edurestart;The discriminant test for local extrema of functions of two variables often has the sense of a magic formula to be memorized without understanding. A better context for understanding this formula is obtained if we review the process of rotation of axes to eliminate the cross term from a quadratic function. (If the cross term is zero, it is clear by inspection if a quadratic function has a minimum, maximum, or saddle point from the signs of the x2 and y2 terms.)A general overviewIf the X-Y axes are obtained from the x-y axes by a rotation of angle q, then the new coordinates are obtained from the formulas:x = Xcos(q) - Ysin(q); X = xcos(q) + ysin(q)y = Xsin(q) + Ycos(q); Y = xsin(q) - ycos(q)Consider the results on a standard quadratic function:f(x, y) = ax^2 + bxy + cy^2 = a(Xcos(q) - Ysin(q))^2 + b(Xcos(q) - Ysin(q))(Xsin(q) + Ycos(q)) + c(Xsin(q) + Ycos(q))^2 = X^2(a*cos^2(q) + b*sin(q)*cos(q) + c*sin^2(q) + XY(2*(c-a)*sin(q)*cos(q) + b(cos^2(q)-sin^2(q))) + Y^2(a*sin^2(q) - b*sin(q)*cos(q) + c*cos^2(q)) The cross term is eliminated if (remembering the double angle formulas)0 = (2*(c-a)*sin(q)*cos(q) + b(cos^2(q)-sin^2(q))) = (c-a)*sin(2*q) + b*cos(2*q)or equivalently if b/(a-c) = tan(2*q).It is worth noting that the discriminant is unchanged by such a rotation Consider the new coefficients: A := a*cos(theta)^2 + b*sin(theta)*cos(theta) + c*sin(theta)^2;
B := 2*(c-a)*sin(theta)*cos(theta) + b*(cos(theta)^2-sin(theta)^2);
C := a*sin(theta)^2 - b*sin(theta)*cos(theta) + c*cos(theta)^2;We can set up the discriminant and simplify in terms of these coefficients in the X-Y coordinates system:Dis2 := 4*A*C - B*B;
Dis3 := simplify(expand(Dis2));Thus, if the X-Y-axes have been chosen to eliminate the cross term, the discriminant is 4*A*C, or 4 times the product of the coefficients of X^2 and Y^2. It is clear that the discriminant is negative if those coefficients are of opposite signs. This happens if the quadratic function has a saddle point. If the two coefficients are of the same sign, the function has either a maximum or a minimum and the discriminant is positive.A specific exampleWe start by defining a quadratic function:a := 1: b:= 4: c:= 12:
quad1 :=a*x^2 + b*x*y + c*y^2;We compute the angle of rotation needed to eliminate the cross term.(Remember that if c=a the angle is Pi/4.)T1 := arctan(b/(a-c))/2;Next we make the substitutions.quad2 := subs({x=X*cos(T1) - Y*sin(T1), y=X*sin(T1) + Y*cos(T1)}, quad1);To make that mess easier to work with we collect terms and evaluate the coefficients.quad3 := collect(expand(quad2), [X,Y]);
quad4 := evalf(quad3);Unfortunately, rounding error may leave us with a cross term that is not quite zero, but is small enough to be ignored.Now we compare graphs in the two coordinate systems to see that graphs have simply been rotated. (Note that one graph is done in xy, the other in XY.)plot3d(quad1,x=-2..2,y=-2..2,view=-5..10,style=patchcontour, axes=normal);
plot3d(quad4,X=-2..2,Y=-2..2,view=-5..10,style=patchcontour, axes=normal);Note that the second graph is aligned with the XY axes.We can rotate also the graph of the second surfaces to make them look the same.T2:=(T1*180/Pi);
plot3d(quad1,x=-2..2,y=-2..2,view=-5..10,style=patchcontour, axes=normal, orientation=[45,45]);
plot3d(quad4,X=-2..2,Y=-2..2,view=-5..10,style=patchcontour, axes=normal, orientation=[45-T2,45]);A tool for explorationFinally, we put together one chunk of code to make it easy to use. All you need to do to test a variety of examples is change the values of the coefficients a, b and c.a := 2: b:= -4: c:= 5:
quad1 :=a*x^2 + b*x*y + c*y^2;
Discriminant := 2*a*2*c-b^2;
T1 := arctan(b/(a-c))/2;
quad2 := subs({x=X*cos(T1) - Y*sin(T1), y=X*sin(T1) + Y*cos(T1)}, quad1):
quad3 := collect(expand(quad2), [X,Y]):
quad4 := evalf(quad3);
T2:=evalf(T1*180/Pi);
plot3d(quad1,x=-2..2,y=-2..2,view=-5..10,style=patchcontour,
axes=normal, orientation=[45,45]);
plot3d(quad4,X=-2..2,Y=-2..2,view=-5..10,style=patchcontour,
axes=normal, orientation=[45-T2,45]);In particular, you should look at what happens when a and c are both positive and b is made large enough to change the sign of the discriminant.