Grad

Grad[f,{x1,,xn}]

gives the gradient .

Grad[f,{x1,,xn},chart]

gives the gradient in the coordinates chart.

Details

  • Grad is also known as the raised covariant derivative.
  • Grad[f,x] can be input as xf. The character can be typed as del or \[Del]. The list of variables x is entered as a subscript.
  • An empty template can be entered as grad, and moves the cursor from the subscript to the main body.
  • All quantities that do not explicitly depend on the variables given are taken to have zero partial derivative.
  • If f is an array of dimensions {n1,,nk}, then Grad[f,{x1,,xm}] yields an array of dimensions {n1,,nk,m}.
  • If f is a scalar, Grad[f,{x1,x2,,xn},chart] returns a vector in the orthonormal basis associated with chart.
  • In Grad[f,{x1,,xn},chart], if f is an array, it must have dimensions {n,,n}. The components of f are interpreted as being in the orthonormal basis associated with chart.
  • For coordinate charts on Euclidean space, Grad[f,{x1,,xn},chart] can be computed by transforming f to Cartesian coordinates, computing the ordinary gradient and transforming back to chart. »
  • A key property of Grad is that if chart is defined with metric g, expressed in the orthonormal basis, then Grad[g,{x1,,xn]},chart] gives zero. »
  • Coordinate charts in the third argument of Grad can be specified as triples {coordsys,metric,dim} in the same way as in the first argument of CoordinateChartData. The short form in which dim is omitted may be used.
  • Grad works with SparseArray and structured array objects.

Examples

open allclose all

Basic Examples  (4)

The gradient in three-dimensional Cartesian coordinates:

The gradient using an orthonormal basis for three-dimensional cylindrical coordinates:

The gradient in two dimensions:

Use del to enter and to enter the list of subscripted variables:

Use grad to enter the template ; press to move between inputs:

Scope  (7)

The gradient of a vector field in Cartesian coordinates, the Jacobian matrix:

Compute the Hessian of a scalar function:

In a curvilinear coordinate system, a vector with constant components may have a nonzero gradient:

Gradient specifying metric, coordinate system, and parameters:

Grad works on curved spaces:

The gradient of the coordinates with respect to themselves:

This is the identity matrix in n dimensions:

The gradient of the norm in n dimensions:

Specialize to the result in three dimensions:

Applications  (4)

Compute the force from a potential function:

Find the critical points of a function of two variables:

Compute the signs of and the Hessian determinant:

By the second derivative test, the first two pointsred and blue in the plotare minima, and the thirdgreen in the plotis a saddle point:

Find the critical points of a function of three variables:

Compute the Hessian matrix of f:

When the eigenvalues of a critical point all have the same sign, the point is a local extremum; if there are both positive and negative values, it is a saddle point:

Since the third and fourth points have all positive eigenvalues, they are local minima, and the global minimum can be determined by evaluating f at those two points:

For this function, any three of the critical points are linearly dependent, so they all lie in a single plane:

Compute the normal to that plane:

Visualize the function, with the minima green and the non-extreme critical points red:

Compute the gradients at the origin of a vector-valued function up to order 6:

View the value of the function and its first three derivatives at the origin:

Compute the third-order Maclaurin series of f by hand:

Programmatically compute the sixth-order Maclaurin series:

Properties & Relations  (6)

Grad[f,vars] is effectively equivalent to D[f,{vars}]:

Grad adds a new tensor slot at the end, corresponding to a new innermost dimension:

To add the new slot at the beginning, use Transpose to exchange the first and last slots:

This is relevant when working with directional derivatives of arrays:

Compute Grad in a Euclidean coordinate chart c by transforming to and then back from Cartesian coordinates:

The result is the same as directly computing Grad[f,{x1,,xn},c]:

The gradient of an array equals the gradient of its components only in Cartesian coordinates:

If chart is defined with metric g, expressed in the orthonormal basis, Grad[g,{x1,,xn},chart] is zero:

Grad preserves the structure of SymmetrizedArray objects:

The gradient has an additional dimension but the same symmetry as the input:

Interactive Examples  (2)

The normal vectors to the level contours of a function equal the normalized gradient of the function:

Create an interactive contour plot that displays the normal at a point:

View expressions for the gradient of a scalar function in different coordinate systems:

Wolfram Research (2012), Grad, Wolfram Language function, https://reference.wolfram.com/language/ref/Grad.html (updated 2014).

Text

Wolfram Research (2012), Grad, Wolfram Language function, https://reference.wolfram.com/language/ref/Grad.html (updated 2014).

CMS

Wolfram Language. 2012. "Grad." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Grad.html.

APA

Wolfram Language. (2012). Grad. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Grad.html

BibTeX

@misc{reference.wolfram_2023_grad, author="Wolfram Research", title="{Grad}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Grad.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_grad, organization={Wolfram Research}, title={Grad}, year={2014}, url={https://reference.wolfram.com/language/ref/Grad.html}, note=[Accessed: 19-March-2024 ]}