Rotations and quadratic functions with cross terms
Worksheet by Mike May, S.J.- maymk@slu.edu
> restart;
The discriminant test for local extrema of functions in two variables often has the sense of a majic formula to be memorized without understanding. A better context for understanding is given 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.)
>
A general overview
The basic fact to be noted is that if the X-Y axes are obtained from the x-y axes with a rotation of 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;
In terms of these coordinates we can set up the disrciminant and simplify:
>
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 will be negative if those coefficients are of oposite 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 example
Time to set up an example.
We start by setting up a quadratic function:
>
a := 1: b:= 4: c:= 12:
quad1 :=a*x^2 + b*x*y + c*y^2;
We need to compute the angle of rotation to eliminate the cross term.
(Remember that if c=a the angle is Pi/4.)
> T1 := arctan(b/(a-c))/2;
Next we do the substitution.
> 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 want to 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.
Finally we compare graphs to see that graphs have simply been rotated.. (Note that one graph is done in xy, the other in XY.)
>
plots[contourplot](quad1, x=-10..10,y=-10..10, contours=[10, 50, 100, 1000], scaling=constrained);
plots[contourplot](quad4, X=-10..10,Y=-10..10, contours=[10, 50, 100, 1000], scaling=constrained);
Finally, we put everything in one chunk of code to make it easy to view and experiment with.
>
a := 10: b:= -3: c:= 5:
quad1 :=a*x^2 + b*x*y + c*y^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);
plots[contourplot](quad1, x=-10..10,y=-10..10,
contours=[10, 50, 100, 1000], scaling=constrained);
plots[contourplot](quad4, X=-10..10,Y=-10..10,
contours=[10, 50, 100, 1000], scaling=constrained);
>
>