Gradient Calculator


Instructions: Use this gradient calculator to compute the vector of partial derivatives for a multivariate function that you provide, showing all the steps. Please type the multivariable function in the form box below.

Enter a multivariate function you want to compute the gradient to (Ex: f(x, y) = x^2 + y^2, etc.)

The Gradient Calculator

This gradient calculator with steps will help you find the gradient vector of a given multivariate function that you provide. This function needs to be a valid, differentiable function with 2 or more variables.

The function you provide needs to come with a full definition of its variable name and function, for example f(x, y) = x^2 + y^2, or f(x,y,z) = xy+z*sin(xy), etc.

Once a valid multivariable function is provided, all that is left to do is to click on the "Calculate" button, in order to get all the steps shown.

Gradients represent the natural extension of derivatives for the multivariable situation, in which the rate of change is better defined by a vector than a number.

Gradient Calculator

What is the Gradient

In simple terms, the gradient is a vector that contains all the first order partial derivatives of a multivariable function \(f\). So then, for a function of two variables \(f(x, y)\), its gradient would be a 2-dimensional vector \(\nabla f(x, y) = \displaystyle \left(\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}\right)\).

Similarly, for a function of three variables \(f(x, y, z\), its gradient would be a 3-dimensional vector \(\nabla f(x, y, z) = \displaystyle \left(\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z}\right)\), and so forth.

Steps for computing the gradient

  • Step 1: Identify the function f you want to work with, and identify the number of variables involved
  • Step 2: Find the first order partial derivative with respect to each of the variables
  • Step 3: Construct the gradient as the vector that contains all those first order partial derivatives found in Step 2

Optionally, you can simplify, if possible, after completing Step 3. Then, with the gradient, you have version of what is the derivative for a univariate function, in this case for a multivariate function.

Applications of the gradient

Same as in the case of univariate functions when looking for critical points we need to find the points where the derivative is zero, for multivariate functions we need to search for points on which the gradient is equal to zero in order to find critical points.

Also, the equivalent to the second derivative tests comes in the form of the hessian rule for multivariate functions.

Gradient Calculator

Tips and tricks

Remember that the gradient is defined for multivariate functions, with two or more variables. Also, keep in mind that the gradient is a vector, where each of the components is a function. More precisely, each of its components is a partial derivative of first order.

As a way of checking your work, don't forget that the gradient is a vector with dimension equals to the number of independent variables defined in the function.

Gradient

Example: Gradient Calculator

Find the gradient associated to the function : \(f(x,y,z)=x^2+y^2+z^2\)

Solution: We consider the following multivariate function: \(\displaystyle f(x,y,z)=x^2+y^2+z^2\), so then we need to compute its gradient.

Differentiating with respect to \(x\)

\( \displaystyle \frac{\partial }{\partial x}\left(x^2+y^2+z^2\right)\)
By linearity, we know \(\frac{\partial }{\partial x}\left( x^2+y^2+z^2 \right) = \frac{\partial }{\partial x}\left(x^2\right)+\frac{\partial }{\partial x}\left(y^2\right)+\frac{\partial }{\partial x}\left(z^2\right)\), so plugging that in:
\( \displaystyle = \,\,\)
\(\displaystyle \frac{\partial }{\partial x}\left(x^2\right)+\frac{\partial }{\partial x}\left(y^2\right)+\frac{\partial }{\partial x}\left(z^2\right)\)
Since the derivative of a constant with respect to \(x\) is 0, we get that:
\( \displaystyle = \,\,\)
\(\displaystyle \frac{\partial }{\partial x}\left(x^2\right)\)
We can use the Power Rule for polynomial terms: \(\frac{\partial }{\partial x}\left( x^2 \right) = 2x\)
\( \displaystyle = \,\,\)
\(\displaystyle 2x\)

Differentiating with respect to \(y\)

\( \displaystyle \frac{\partial }{\partial y}\left(x^2+y^2+z^2\right)\)
By linearity, we know \(\frac{\partial }{\partial y}\left( x^2+y^2+z^2 \right) = \frac{\partial }{\partial y}\left(x^2\right)+\frac{\partial }{\partial y}\left(y^2\right)+\frac{\partial }{\partial y}\left(z^2\right)\), so plugging that in:
\( \displaystyle = \,\,\)
\(\displaystyle \frac{\partial }{\partial y}\left(x^2\right)+\frac{\partial }{\partial y}\left(y^2\right)+\frac{\partial }{\partial y}\left(z^2\right)\)
Since the derivative of a constant with respect to \(y\) is 0, we find that:
\( \displaystyle = \,\,\)
\(\displaystyle \frac{\partial }{\partial y}\left(y^2\right)\)
We use the Power Rule for polynomial terms: \(\frac{\partial }{\partial y}\left( y^2 \right) = 2y\)
\( \displaystyle = \,\,\)
\(\displaystyle 2y\)

Differentiating with respect to \(z\)

\( \displaystyle \frac{\partial }{\partial z}\left(x^2+y^2+z^2\right)\)
By linearity, we know \(\frac{\partial }{\partial z}\left( x^2+y^2+z^2 \right) = \frac{\partial }{\partial z}\left(x^2\right)+\frac{\partial }{\partial z}\left(y^2\right)+\frac{\partial }{\partial z}\left(z^2\right)\), so plugging that in:
\( \displaystyle = \,\,\)
\(\displaystyle \frac{\partial }{\partial z}\left(x^2\right)+\frac{\partial }{\partial z}\left(y^2\right)+\frac{\partial }{\partial z}\left(z^2\right)\)
The derivative of a constant with respect to \(z\) is 0, so then:
\( \displaystyle = \,\,\)
\(\displaystyle \frac{\partial }{\partial z}\left(z^2\right)\)
We use the Power Rule for polynomial terms: \(\frac{\partial }{\partial z}\left( z^2 \right) = 2z\)
\( \displaystyle = \,\,\)
\(\displaystyle 2z\)

Conclusion: Therefore, we can conclude that the gradient of the given function \(\displaystyle f(x,y,z)=x^2+y^2+z^2 \) is equal to:

\[ \nabla f = \left(2x,2y,2z\right)\]

Gradient Calculation Example

For the following function: \(f(x, y) = xy\), find its gradient.

Solution: For this example we have a function of two variables x and y: \(\displaystyle f(x,y)=xy\).

First, differentiating with respect to x

\( \displaystyle \frac{\partial }{\partial x}\left(xy\right)\)
Since it is a constant times \(x\), we directly get: \(\frac{\partial }{\partial x}\left( xy \right) = y\)
\( \displaystyle = \,\,\)
\(\displaystyle y\)

Now, fifferentiate with respect to y

\( \displaystyle \frac{\partial }{\partial y}\left(xy\right)\)
Since it is a constant times \(y\), we directly get: \(\frac{\partial }{\partial y}\left( xy \right) = x\)
\( \displaystyle = \,\,\)
\(\displaystyle x\)

Conclusion: We get directly that the gradient of the function \(\displaystyle f(x,y)=xy \) is:

\[ \nabla f = \left(y, x\right)\]

More gradient examples

Calculate the corresponding gradient of \( f(x, y) = x^2 - y^2 - xy \).

Solution: Finally, the following function needs to be analyzed in this example: \(\displaystyle f(x,y)=x^2-y^2-xy\). Since it is a multivariate function, it makes sense to compute its gradient.

Step 2: Find the derivative with respect to \(x\)

\( \displaystyle \frac{\partial }{\partial x}\left(x^2-xy-y^2\right)\)
By linearity, we know \(\frac{\partial }{\partial x}\left( x^2-xy-y^2 \right) = \frac{\partial }{\partial x}\left(x^2\right)-\frac{\partial }{\partial x}\left(xy\right)-\frac{\partial }{\partial x}\left(y^2\right)\), so plugging that in:
\( \displaystyle = \,\,\)
\(\displaystyle \frac{\partial }{\partial x}\left(x^2\right)-\frac{\partial }{\partial x}\left(xy\right)-\frac{\partial }{\partial x}\left(y^2\right)\)
The derivative of a constant with respect to \(x\) is 0, so then:
\( \displaystyle = \,\,\)
\(\displaystyle \frac{\partial }{\partial x}\left(x^2\right)-\frac{\partial }{\partial x}\left(xy\right)\)
Since it is a constant times \(x\), we directly get: \(\frac{\partial }{\partial x}\left( xy \right) = y\) and we can use the Power Rule for polynomial terms: \(\frac{\partial }{\partial x}\left( x^2 \right) = 2x\)
\( \displaystyle = \,\,\)
\(\displaystyle 2x-y\)

Step 2: Find the derivative with respect to \(y\)

\( \displaystyle \frac{\partial }{\partial y}\left(x^2-xy-y^2\right)\)
By linearity, we know \(\frac{\partial }{\partial y}\left( x^2-xy-y^2 \right) = \frac{\partial }{\partial y}\left(x^2\right)-\frac{\partial }{\partial y}\left(xy\right)-\frac{\partial }{\partial y}\left(y^2\right)\), so plugging that in:
\( \displaystyle = \,\,\)
\(\displaystyle \frac{\partial }{\partial y}\left(x^2\right)-\frac{\partial }{\partial y}\left(xy\right)-\frac{\partial }{\partial y}\left(y^2\right)\)
We use the Power Rule for polynomial terms: \(\frac{\partial }{\partial y}\left( y^2 \right) = 2y\) and since it is a constant times \(y\), we directly get: \(\frac{\partial }{\partial y}\left( xy \right) = x\)
\( \displaystyle = \,\,\)
\(\displaystyle \frac{\partial }{\partial y}\left(x^2\right)-x-2y\)
which then leads to
\( \displaystyle = \,\,\)
\(\displaystyle 0-x-2y\)
By reorganizing/simplifying/expanding the terms that are amenable to
\( \displaystyle = \,\,\)
\(\displaystyle -x-2y\)

Conclusion: Therefore, we can conclude that the gradient of the given function \(\displaystyle f(x,y)=x^2-y^2-xy \) is equal to:

\[ \nabla f = \left(2x-y,-x-2y\right)\]

More derivative calculators

Using a derivative calculator can definitely make your life easier as it will allow you to keep track of all the derivative rules.

Most of the differentiation rules used for univariate functions have their equivalent for multivariate functions. This way, the chain rule, product rule and quotient rule will also work for multivariate function, keeping in mind the right dimensions.

log in to your account

Don't have a membership account?
REGISTER

reset password

Back to
log in

sign up

Back to
log in