Explore calculusLesson 28 of 48 · 8 min
Take one partial derivative at a time
Build a gradient with an explicit order of input variables.
Maths refresher: Partial change
A partial derivative varies one coordinate while the other independent inputs stay fixed.
At , the gradient is . Its entries refer to and respectively.
A function of several variables can change in several directions. A partial derivative changes one input while holding the others fixed. The gradient collects those partial derivatives in a stated variable order.
SymPy diff treats other independent symbols as constants when differentiating with respect to one symbol. Parameters are not automatically functions of that symbol; declare functional dependence explicitly if the model requires it.
The quadratic example has inputs x and y with a cross term. Compute each partial derivative, form a column vector and evaluate it at a point. A zero gradient is a candidate for an interior stationary point; it does not by itself prove a minimum, maximum or feasible solution.
When taking the partial derivative of with respect to , does also differentiate to one?
Write a prediction (optional)
Exact symbolic investigation
Select Run Python with the code unchanged.
Your saved draft is open. To use the published code, select Restore example in Tools. Use Recover draft to bring back your code.
Tools
About Python
Python and the course packages can load while you read. Each run starts with fresh user variables; imported modules stay loaded. Stop replaces the worker. Runtime details ↗
Ctrl+Enter or ⌘+Enter runs Python.
Execution error
Technical error details
Your result
Python text output
Compare with the worked example
Executed from the published Python during the site build. Your own run appears above. Build environment ↗
Worked text output
Function: x**2 + x*y + y**2 Gradient, order (x,y): Matrix([[2*x + y], [x + 2*y]]) Gradient at (1,2): Matrix([[4], [5]]) Mixed partial: 1
Read the starter result
The first Gradient, order (x,y) component holds y fixed and the second holds x fixed. The term therefore contributes y to the first component and x to the second.
Edit and compare
Append +3*x*y to the expression line. Select Run Python and compare the first and second entries in Gradient, order (x,y). Which variable is held fixed for each added term?
Scope. This example assumes independent coordinates and smooth polynomial derivatives; constraints and nonsmooth points require care.
Try a fresh case
A function has gradient zero at a point. What has been established?
Need a hint?
Hint 1
A flat slope can occur at a maximum or saddle as well as a minimum.
Hint 2
Separate finding candidates from classifying them.