Math calculators

Gradient Calculator

Updated Sep 5, 2026 By Jehan Wadia
Rate Formulas
Function & Options
Use ^ for powers and * for products; sin, cos, ln, log, exp, sqrt, abs are supported.
Leave blank to auto-detect and sort variables alphabetically.
Comma-separated values in the same order as the variables.
Clickable Examples
Gradient Results
Gradient Components at the Point

Introduction

This gradient calculator finds the gradient of a function with two or more variables. Type a function like x^3 + y^5, and the tool takes the partial derivative with respect to each variable, then collects those parts into one vector, written as ∇f.

You can also enter a point, such as (1, 7). The calculator plugs those numbers in and returns the gradient at that spot, along with the length (magnitude) of the vector and the unit vector, which points the way the function grows the fastest.

Open the Steps tab to see the work one line at a time, with the rules used along the way, like the power rule, product rule, quotient rule, and chain rule. The Graph tab draws a gradient vector field, so you can see the arrows and how strong they are in each area.

The tool handles powers, roots, fractions, trig functions, logs, and exponentials. Use the math keyboard if you do not want to type symbols, or click any example to load it right away. Use it to check homework, study for a calculus test, or see how partial derivatives work.

How to use our Gradient Calculator

Type a function of two or more variables, and this gradient calculator finds each partial derivative, the full gradient vector, its magnitude, the direction of steepest ascent, step-by-step work, and a vector field graph.

Function f(x, y, z, …): Enter your function in the first box. Use ^ for powers, * for times, and / for divide. You can also use sin, cos, tan, ln, log, exp, sqrt, and abs. Example: x^3 + y^5.

Variable Order (optional): List your variables with commas, like x, y, z. This sets the order of the gradient parts. Leave it blank and the calculator finds the variables for you and puts them in alphabetical order.

Evaluate at Point (optional): Type one number for each variable, in the same order, like 1, 7. The calculator then gives the gradient value at that point. Leave it blank to get only the symbolic answer.

Math Keyboard: Click "Open Math Keyboard" to add roots, powers, trig functions, logs, and Greek letters without typing them.

Calculate Gradient: Click this button to see your answer. Use the Solution, Steps, and Graph tabs to view the result, the full work, and the gradient vector field. Click Reset to start over, or click any example to try a ready-made problem.

What Is a Gradient?

The gradient of a function is a vector that holds all of its partial derivatives. It is written with the symbol ∇ (called "nabla" or "del"), so the gradient of a function f is written ∇f. It only works for functions with two or more variables, like f(x, y) or f(x, y, z).

What Is a Partial Derivative?

A partial derivative is the derivative with respect to just one variable. You treat every other variable as a plain number. For example, with f(x, y) = x³ + y⁵:

  • ∂f/∂x = 3x² (here y⁵ acts like a constant, so it goes to 0)
  • ∂f/∂y = 5y⁴ (here x³ acts like a constant, so it goes to 0)

Put them in a list and you get the gradient: ∇f = (3x², 5y⁴).

How to Find a Gradient

  1. List your variables in order, such as x, y, z.
  2. Take the partial derivative for each one, holding the others still.
  3. Write the answers as a vector: ∇f = (∂f/∂x, ∂f/∂y, ∂f/∂z).
  4. If you have a point, plug the numbers into each part.

What the Gradient Tells You

The gradient points in the direction where the function grows the fastest. This is called the direction of steepest ascent. Think of standing on a hill: the gradient points straight uphill. The opposite direction points straight downhill.

The magnitude (length) of the gradient tells you how steep that climb is. You find it with the square root of the sum of the squares:

‖∇f‖ = √((∂f/∂x)² + (∂f/∂y)² + …)

Divide the gradient by its magnitude and you get the unit gradient vector, which shows only the direction, with length 1.

Rules You Will Use

  • Power rule: the derivative of xⁿ is n·xn−1
  • Constant rule: terms with no chosen variable become 0
  • Product rule: for two parts multiplied together
  • Quotient rule: for a fraction of two parts
  • Chain rule: for a function inside another function, like sin(x²)

Zero Gradient and Critical Points

If every partial derivative is 0 at a point, the gradient is the zero vector. That spot is a critical point. It may be a peak, a valley, or a saddle. At a critical point the surface is flat, so there is no steepest direction.

Where Gradients Are Used

  • Machine learning: gradient descent moves down the gradient to lower error.
  • Physics: heat, electric, and gravity fields flow along gradients.
  • Maps and terrain: the gradient shows the slope of the land.
  • Optimization: finding the biggest or smallest value of a function.

Gradient vs. Directional Derivative

A directional derivative gives the rate of change in one chosen direction. The gradient does more: it gives the best direction and the fastest rate at once. In fact, the largest possible directional derivative at a point equals the magnitude of the gradient there.


Formulas used

Gradient vector (definition)
\nabla f(x_1,\,x_2,\,\dots,\,x_n) = \left(\frac{\partial f}{\partial x_1},\; \frac{\partial f}{\partial x_2},\; \dots,\; \frac{\partial f}{\partial x_n}\right)
Gradient magnitude
\left\|\nabla f\right\| = \sqrt{\left(\frac{\partial f}{\partial x_1}\right)^2 + \left(\frac{\partial f}{\partial x_2}\right)^2 + \cdots + \left(\frac{\partial f}{\partial x_n}\right)^2}
Unit gradient (direction of steepest ascent)
\hat{u} = \frac{\nabla f}{\left\|\nabla f\right\|}
Product rule for partial derivatives
\frac{\partial}{\partial x}\left(u\,v\right) = \frac{\partial u}{\partial x}\,v + u\,\frac{\partial v}{\partial x}
Quotient rule for partial derivatives
\frac{\partial}{\partial x}\left(\frac{u}{v}\right) = \frac{\dfrac{\partial u}{\partial x}\,v - u\,\dfrac{\partial v}{\partial x}}{v^2}
Power rule with chain rule
\frac{\partial}{\partial x}\left(u^{n}\right) = n\,u^{n-1}\,\frac{\partial u}{\partial x}
General power rule (variable base and exponent)
\frac{\partial}{\partial x}\left(u^{v}\right) = u^{v}\left(\frac{\partial v}{\partial x}\ln u + v\,\frac{1}{u}\frac{\partial u}{\partial x}\right)
Direction angle of the plotted gradient field
\theta = \arctan\!\left(\frac{\partial f/\partial y}{\partial f/\partial x}\right) \cdot \frac{180}{\pi}

Frequently asked questions

Is the gradient a vector or a scalar?

The gradient is a vector. Each slot in it holds one partial derivative, so a function of x and y gives a gradient with two parts, and a function of x, y, and z gives three parts.

Because it is a vector, it has both a direction (the way the function rises fastest) and a length (how steep that rise is). Only the length, called the magnitude, is a plain number.

Is the gradient the same as the slope?

Not quite. A slope is one number that tells you how steep a line is. A gradient is a vector that holds a slope for every variable at once.

They are linked, though. The magnitude of the gradient equals the steepest slope at that point, and the gradient vector tells you which way that steepest slope faces. For f(x, y) = x² + y² at (1, 1), the gradient is (2, 2) and the steepest slope is √8 ≈ 2.83.

What does the ∂ symbol mean in ∂f/∂x?

The curly ∂ is called "partial d." You read ∂f/∂x as "the partial derivative of f with respect to x."

The curly symbol is a signal that the function has more than one variable. A straight d, as in df/dx, is used when there is only one variable. When you take ∂f/∂x, you treat every other variable like a fixed number.

Why is the gradient perpendicular to level curves?

A level curve (or contour line) is a path where the function value never changes. If you walk along it, the rate of change is zero.

The gradient points the way the function changes the fastest. The fastest change can never be along a path of no change, so the gradient must cross the contour at a 90° angle. On a map, this is why the steepest way up a hill cuts straight across the contour lines.

How do you find a directional derivative using the gradient?

Take the dot product of the gradient with a unit vector u that points the way you want to go:

Duf = ∇f · u

Example: if ∇f = (3, 4) and u = (1, 0), then Duf = 3·1 + 4·0 = 3. Make sure u has length 1 first; divide it by its own length if it does not.

Can a gradient be negative?

Single parts of the gradient can be negative. A negative component means the function goes down as that variable gets bigger. For f(x, y) = −x² + y, the gradient is (−2x, 1), which is negative in the x slot when x is positive.

The magnitude ‖∇f‖ is never negative, because it comes from a square root of squares. The smallest it can be is 0.

Does a function of one variable have a gradient?

Not in the usual sense. With one variable you just take the ordinary derivative, f′(x). The gradient is built for functions of two or more variables, since it needs one partial derivative per variable.

Some books do write ∇f = (f′(x)) as a one-slot vector, but it holds the same information as the plain derivative.

How do you find a tangent plane using the gradient?

For a surface z = f(x, y) at the point (a, b), use:

z = f(a, b) + fx(a, b)(x − a) + fy(a, b)(y − b)

For a surface written as F(x, y, z) = k, the gradient ∇F at the point is the normal vector (it sticks straight out of the surface). The plane is then Fx(x − x₀) + Fy(y − y₀) + Fz(z − z₀) = 0.

What is the difference between gradient, divergence, and curl?

  • Gradient: starts with a number function, gives a vector. It shows the steepest uphill direction.
  • Divergence: starts with a vector field, gives a number. It shows how much the field spreads out or squeezes in.
  • Curl: starts with a vector field, gives a vector. It shows how much the field spins.

All three use the ∇ symbol, but they act on different things.

What is the gradient in polar coordinates?

In polar coordinates (r, θ) the gradient is:

∇f = (∂f/∂r) r̂ + (1/r)(∂f/∂θ) θ̂

The extra 1/r is there because a small change in the angle θ moves you farther when r is big. In regular x-y coordinates there is no such factor.

What are the units of a gradient?

Each part of the gradient carries the units of the function divided by the units of that variable.

If f is temperature in degrees Celsius and x is distance in meters, then ∂f/∂x is in °C per meter. So a gradient of 5 means the temperature climbs 5 degrees for every meter you move that way.

What is the difference between the gradient and the Hessian?

The gradient holds the first partial derivatives and is a vector. The Hessian holds the second partial derivatives and is a square matrix.

You use the gradient to find critical points by setting it to zero. Then you use the Hessian to tell what kind of point it is: a peak, a valley, or a saddle.