Gradient Calculator - Partial Derivatives and Direction of Steepest Ascent
Use this gradient calculator to compute partial derivatives, gradient vector, magnitude, and the direction of steepest ascent for f(x, y) and f(x, y, z).
Gradient Calculator
Results
What Is Gradient Calculator?
A gradient calculator evaluates the gradient of a scalar function f(x, y) or f(x, y, z) at a user-chosen point. The gradient is the vector of partial derivatives, ∇f = (∂f/∂x, ∂f/∂y, ∂f/∂z), and it points in the direction where the function increases fastest.
- • Multivariable calculus homework: Check partial derivatives, gradient vectors, and critical points for a polynomial f(x, y) or f(x, y, z) without working through each derivative by hand.
- • Direction of steepest ascent: Find the unit vector along which a scalar field grows most quickly and the maximum rate of change at any point.
- • Optimization and critical points: Confirm where the gradient equals the zero vector, which is required when locating local minima, maxima, and saddle points.
- • Physics and engineering models: Compute the gradient of potential-energy, temperature, or pressure fields used in physics and engineering.
The calculator accepts the coefficients of a polynomial f(x, y) or f(x, y, z) and a single point (x₀, y₀[, z₀]). It returns the three partial derivatives, the gradient vector, its magnitude, the unit direction of steepest ascent, and the maximum rate of change. A 2D/3D toggle lets you add z², x·z, y·z, and z terms when needed.
The gradient is the starting point for related problems: dotting it with a unit vector gives the directional derivative, and the sign of each partial tells you whether f is increasing or decreasing in that coordinate.
For problems that need a single scalar slope instead, see our Slope Percentage Calculator.
How Gradient Calculator Works
The calculator uses the partial-derivative rules of multivariable calculus. For a polynomial f(x, y) or f(x, y, z), the partial with respect to one variable treats the other variables as constants and applies the standard power rule.
- ax2, ay2, az2: Coefficients multiplying x², y², and z². They contribute 2·ax2·x, 2·ay2·y, and 2·az2·z to the partials.
- axy, axz, ayz: Coefficients of the x·y, x·z, and y·z cross terms. Each cross term contributes once to two partials.
- ax, ay, az: Linear coefficients that pass directly into the corresponding partials as constants.
- a0: Constant term; its derivative is zero, so it does not affect the gradient.
- x0, y0, z0: Coordinates of the point at which every partial and the gradient are evaluated.
Each partial is the derivative of the polynomial with the other variables held constant, evaluated at the chosen point.
The magnitude is the maximum rate of change at that point, and the unit vector along the gradient gives the direction of fastest increase. According to Khan Academy, the gradient always points in the direction of steepest ascent.
Worked example: gradient of f(x, y) = x² + y² at (1, 1)
ax2 = 1, ay2 = 1, x0 = 1, y0 = 1 (2D)
∂f/∂x = 2x = 2; ∂f/∂y = 2y = 2; |∇f| = √8 ≈ 2.8284
Gradient vector (2, 2); magnitude 2.8284; unit direction of steepest ascent (0.7071, 0.7071).
The function grows fastest along the line y = x from the origin, with a max slope of about 2.83 at this point.
Worked example: gradient of f(x, y, z) = x² + 2y² + z² at (1, 1, 1)
ax2 = 1, ay2 = 2, az2 = 1, x0 = 1, y0 = 1, z0 = 1 (3D)
∂f/∂x = 2x = 2; ∂f/∂y = 4y = 4; ∂f/∂z = 2z = 2; |∇f| = √24 ≈ 4.899
Gradient vector (2, 4, 2); magnitude 4.899; unit direction of steepest ascent (0.4082, 0.8165, 0.4082).
The y coefficient is largest, so the unit direction leans toward the y axis, while x and z contribute equal shares.
According to Khan Academy, the gradient of a scalar function f(x, y, z) is the vector of its partial derivatives, ∇f = (∂f/∂x, ∂f/∂y, ∂f/∂z), and it always points in the direction of steepest ascent
According to Wikipedia, the gradient of f is the vector field whose components are the partial derivatives of f with respect to each variable, and its direction gives the direction of fastest increase of f
To compute |∇f| by hand, the Vector Magnitude Calculator walks through the same square-root-of-sum-of-squares step used in the worked examples.
Key Concepts Explained
These four concepts come up every time you work with a gradient, and they map directly onto the calculator's outputs.
Partial derivative
A partial derivative measures how f changes when only one variable moves and the others stay fixed. For a polynomial, you apply the power rule to that variable's term and substitute the evaluation point.
Gradient vector
The gradient ∇f is the ordered list of all partial derivatives. In 2D it is a 2-component vector, in 3D a 3-component vector. It encodes the local behavior of the scalar field at a single point.
Magnitude of the gradient
|∇f| is the length of the gradient vector. It equals the maximum directional derivative at that point, so it reports how fast f can change per unit distance from the point.
Direction of steepest ascent
The unit vector ∇f / |∇f| points along the direction in which f increases fastest. The opposite unit vector gives the direction of fastest decrease.
When the magnitude is zero, every partial is zero and the point is critical. The next step is to inspect the Hessian, but the gradient alone locates candidates for local extrema or saddle points.
If you want the directional derivative along a specific unit vector, combine the gradient with the Dot Product Calculator to dot the two vectors together.
How to Use This Calculator
Enter the coefficients of your polynomial scalar field, choose 2D or 3D, pick a point, and read the gradient results.
- 1 Set the polynomial coefficients: Type the coefficients of x², y², x·y, x, y, and the constant a₀. Leave a coefficient at 0 if that term is missing.
- 2 Choose 2D or 3D: Use the toggle to include z², x·z, y·z, and z terms. The 3D inputs stay in the form but are ignored in 2D.
- 3 Pick the evaluation point: Enter (x₀, y₀) for 2D or (x₀, y₀, z₀) for 3D. The calculator substitutes these into each partial derivative.
- 4 Read the partials and gradient: Check ∂f/∂x, ∂f/∂y, and (in 3D) ∂f/∂z. Together they form the gradient vector shown above the magnitude.
- 5 Use magnitude and direction: Compare the magnitude to the maximum rate of change, and follow the unit direction for the path of steepest ascent or descent.
- 6 Check for critical points: If the magnitude is zero, the point is stationary. Switch to nearby points to classify it as a minimum, maximum, or saddle.
For f(x, y) = 3x² + 2xy − y² at (2, −1), type 3 for the x² coefficient, −1 for the y² coefficient, 2 for x·y, and 2 and −1 for the point. The gradient is (10, 6) with magnitude about 11.66.
If you want to plot the point and the gradient vector on the same picture, the Coordinate Plane Calculator accepts the same x and y inputs and visualizes them.
Benefits of Using This Calculator
A working gradient calculator removes the most error-prone step in multivariable calculus: keeping three partials, a magnitude, and a unit direction consistent.
- • Quick partial derivatives: Compute ∂f/∂x, ∂f/∂y, and ∂f/∂z at any point without reapplying the power rule for each variable.
- • Gradient vector and magnitude in one view: See the assembled vector, its length, and the unit direction of steepest ascent side by side.
- • Critical-point detection: Spot stationary points when every partial equals zero, the first condition for any local minimum, maximum, or saddle.
- • 2D and 3D in the same tool: Toggle between f(x, y) and f(x, y, z) without re-entering coefficients. The 3D fields are ignored while you stay in 2D.
- • Direction of fastest increase: Get a unit vector you can feed into gradient-ascent and gradient-descent workflows used in optimization and machine learning.
The calculator is meant for homework, exam review, and quick sanity checks. It is not a substitute for a full symbolic engine.
When you need a vector perpendicular to the gradient, such as for level curves, the Cross Product Calculator builds that vector from the same partial-derivative inputs.
Factors That Affect Your Results
A few small things change the values you see and how to interpret them.
Choice of evaluation point
The gradient is a local property. Moving the point (x₀, y₀, z₀) can change the magnitude, the direction, and whether the point is critical. The same polynomial can have a zero gradient at one location and a large one nearby.
Polynomial form and term mix
Cross terms such as x·y appear in two partials at once, so a coefficient that looks small can still produce a meaningful gradient component.
2D vs 3D mode
Switching from 2D to 3D adds the partial ∂f/∂z to the gradient and changes both the magnitude and the unit direction.
Coefficient magnitudes
Large coefficients amplify the partials quickly, especially when combined with points far from the origin. Outputs are formatted with up to four decimals and fall back to scientific notation when very large.
Numerical rounding
Each output is rounded to four decimal places, so the magnitude and the max rate of change can differ by a few ten-thousandths from an exact symbolic answer.
- • The calculator accepts only polynomial scalar fields up to degree 2 in each variable. Non-polynomial functions such as sin, exp, or log must be approximated first.
- • It reports the gradient at a single point, not along a curve or surface. Directional derivatives along a parameterized path need a separate symbolic step.
- • The unit direction of steepest ascent is undefined when the gradient is the zero vector. The calculator flags this as a stationary point instead of guessing a direction.
Treat the gradient result as a starting point. If you plan to translate the magnitude or the unit direction into a step, check that the units of the inputs match what you use downstream.
According to Paul's Online Math Notes, the magnitude of the gradient vector at a point equals the maximum rate of change of the function at that point, which is why the same value appears for both outputs.
When you translate the magnitude of the gradient into a physical distance, the Length of a Line Segment Calculator takes the same x and y coordinates and reports the segment length you can move per unit of rate change.
Frequently Asked Questions
Q: What is the gradient of a function?
A: The gradient of a scalar function f(x, y, z) is the vector of its partial derivatives, written ∇f = (∂f/∂x, ∂f/∂y, ∂f/∂z). It points in the direction in which the function increases fastest at a given point, and its magnitude equals the maximum rate of change.
Q: How do I compute partial derivatives of a multivariable function?
A: Hold every variable except one fixed and differentiate the polynomial with respect to that variable using the power rule. Then substitute the evaluation point. The three resulting partials form the gradient.
Q: What does the gradient vector tell me about a surface?
A: At any point, the gradient is normal to the level surface of f that passes through that point, and it shows the direction in which the function's value rises most quickly. The magnitude is the slope of that rise per unit distance.
Q: What is the difference between gradient and slope?
A: Slope is the rate of change of a one-variable function, written as a single number. The gradient is the multivariable generalization: a vector of partial derivatives that captures the slope in every direction at once.
Q: How do I find the direction of steepest ascent?
A: Normalize the gradient vector by dividing each partial by the magnitude |∇f|. The resulting unit vector is the direction in which f grows fastest, and its opposite gives the direction of steepest descent used in gradient descent algorithms.
Q: Can the magnitude of a gradient ever be zero?
A: Yes. When every partial derivative evaluates to zero, the gradient is the zero vector and the magnitude is 0. That marks a critical or stationary point, which is a candidate for a local minimum, maximum, or saddle.