Multivariable calculus
Gradient of x^2 + xy + y^2: Handling the Cross Term
For f(x, y) = x^2 + xy + y^2 the gradient is (2x + y, x + 2y). The cross term xy contributes to both components: it leaves a y in the x-slot and an x in the y-slot. At (2, -1) the gradient is (3, 0), and the only critical point is the origin.
Differentiate all three terms, including the cross term
Go term by term with frozen. The square gives . The cross term is times , so it gives . The square is a pure constant and gives zero.
Repeat with frozen. Now is the constant, is times and gives , and gives .
At this is , pointing due east. The height there is .
The mistake: charging the cross term to only one component
A frequent answer is , where has been used up in the -component and forgotten in the -component. Each partial derivative is computed from scratch on the whole function, so a term that contains both variables gets counted in both.
You can catch the error by slicing. Fix , so is a one-variable function with . The correct formula gives , which matches. The faulty formula gives , which does not.
- Ask of every term: does it contain the variable I am differentiating? If yes, it contributes.
- contains both variables, so it contributes to both components.
- Slice-and-check with a fixed numeric value for the other variable is the fastest way to verify a suspect component.
A quadratic form, so the gradient is a linear map
Every component is linear in and , which is what always happens for a quadratic form. You can write the gradient as a matrix acting on the position vector.
That matrix is invertible, so the only solution of is . Since is a sum of squares, the origin is a global minimum with value .
The level curves are ellipses tilted at degrees, with the long axis along . Setting gives , which grows slowly, while gives , which grows fast. The gradient is longest where the level curves crowd together, along .
Frequently asked questions
Is the origin a minimum for x^2 + xy + y^2?
Yes, a global minimum. The second derivative test gives , , and with , which confirms a local minimum, and the sum-of-squares form makes it global.
Where is the gradient of x^2 + xy + y^2 horizontal?
Wherever the second component vanishes without the first, meaning away from the origin. That is the line with the origin removed, since at the origin the gradient is the zero vector and points nowhere at all. The point sits on that line, and its gradient is indeed horizontal.