linalg(deprecated)/grad - Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : linalg(deprecated)/grad

linalg(deprecated)

 grad
 vector gradient of an expression

 Calling Sequence grad(expr, v) grad(expr, v, co)

Parameters

 expr - scalar expression v - vector or list of variables co - (optional), is either of type = or a list of three elements. This option is used to compute the gradient in orthogonally curvilinear coordinate systems.

Description

 • Important: The linalg package has been deprecated. Use the superseding command VectorCalculus[Gradient], instead.
 - For information on migrating linalg code to the new packages, see examples/LinearAlgebraMigration.
 • The function grad computes the gradient of expr with respect to v.
 • It computes the following vector of partial derivatives:
 vector( [diff(expr, v), diff(expr, v), ...] ).
 • In the case of three dimensions, where expr is a scalar expression of three variables and v is a list or a vector of three variables:
 If the optional third argument co is of the form coords = coords_name or coords = coords_name({[const]}), grad will operate on commonly used orthogonally curvilinear coordinate systems. See ?coords for the list of the different coordinate systems known to Maple.

 For orthogonally curvilinear coordinates v, v, v with unit vectors a, a, a, and scale factors h, h, h: Let the rectangular coordinates x, y, z be defined in terms of the specified orthogonally curvilinear coordinates. We have: h[n]^2 = [diff(x,v[n])^2 + diff(y,v[n])^2 + diff(z,v[n])^2], n=1,2,3. The formula for the gradient vector is: grad(expr) = sum(a[n]/h[n]*diff(expr,v[n]),n=1..3);

 If the optional third argument co is a list of three elements which specify the scale factors, grad will operate on orthogonally curvilinear coordinate systems.
 • To compute the gradient in other orthogonally curvilinear coordinate systems, use the addcoords routine.
 • The two dimensional case is similar to the three dimensional one.
 • The command with(linalg,grad) allows the use of the abbreviated form of this command.

Examples

Important: The linalg package has been deprecated. Use the superseding command VectorCalculus[Gradient], instead

 > $\mathrm{with}\left(\mathrm{linalg}\right):$
 > $\mathrm{grad}\left(3{x}^{2}+2yz,\left[\begin{array}{ccc}x& y& z\end{array}\right]\right)$
 $\left[\begin{array}{ccc}{6}{}{x}& {2}{}{z}& {2}{}{y}\end{array}\right]$ (1)
 > $f≔r\mathrm{sin}\left(\mathrm{θ}\right){z}^{2}:$$v≔\left[r,\mathrm{θ},z\right]:$
 > $\mathrm{grad}\left(f,v,\mathrm{coords}=\mathrm{cylindrical}\right)$
 $\left[\begin{array}{ccc}{\mathrm{sin}}{}\left({\mathrm{θ}}\right){}{{z}}^{{2}}& {\mathrm{cos}}{}\left({\mathrm{θ}}\right){}{{z}}^{{2}}& {2}{}{r}{}{\mathrm{sin}}{}\left({\mathrm{θ}}\right){}{z}\end{array}\right]$ (2)
 > $g≔{r}^{2}\mathrm{sin}\left(\mathrm{θ}\right)\mathrm{cos}\left(\mathrm{φ}\right):$$v≔\left[r,\mathrm{θ},\mathrm{φ}\right]:$
 > $\mathrm{grad}\left(g,v,\mathrm{coords}=\mathrm{spherical}\right)$
 $\left[\begin{array}{ccc}{2}{}{r}{}{\mathrm{sin}}{}\left({\mathrm{θ}}\right){}{\mathrm{cos}}{}\left({\mathrm{φ}}\right)& {r}{}{\mathrm{cos}}{}\left({\mathrm{θ}}\right){}{\mathrm{cos}}{}\left({\mathrm{φ}}\right)& {-}{r}{}{\mathrm{sin}}{}\left({\mathrm{φ}}\right)\end{array}\right]$ (3)

define the scale factors in spherical coordinates

 > $h≔\left[1,r,r\mathrm{sin}\left(\mathrm{θ}\right)\right]:$
 > $\mathrm{grad}\left(g,v,h\right)$
 $\left[\begin{array}{ccc}{2}{}{r}{}{\mathrm{sin}}{}\left({\mathrm{θ}}\right){}{\mathrm{cos}}{}\left({\mathrm{φ}}\right)& {r}{}{\mathrm{cos}}{}\left({\mathrm{θ}}\right){}{\mathrm{cos}}{}\left({\mathrm{φ}}\right)& {-}{r}{}{\mathrm{sin}}{}\left({\mathrm{φ}}\right)\end{array}\right]$ (4)
 > $l≔\mathrm{cosh}\left(\mathrm{ξ}\right)\mathrm{cos}\left(\mathrm{η}\right)\mathrm{cos}\left(\mathrm{φ}\right):$$v≔\left[\mathrm{ξ},\mathrm{η},\mathrm{φ}\right]:$
 > $\mathrm{grad}\left(l,v,\mathrm{coords}=\mathrm{prolatespheroidal}\left(1\right)\right)$
 $\left[\begin{array}{ccc}\frac{{\mathrm{sinh}}{}\left({\mathrm{ξ}}\right){}{\mathrm{cos}}{}\left({\mathrm{η}}\right){}{\mathrm{cos}}{}\left({\mathrm{φ}}\right)}{\sqrt{{{\mathrm{sinh}}{}\left({\mathrm{ξ}}\right)}^{{2}}{+}{{\mathrm{sin}}{}\left({\mathrm{η}}\right)}^{{2}}}}& {-}\frac{{\mathrm{cosh}}{}\left({\mathrm{ξ}}\right){}{\mathrm{sin}}{}\left({\mathrm{η}}\right){}{\mathrm{cos}}{}\left({\mathrm{φ}}\right)}{\sqrt{{{\mathrm{sinh}}{}\left({\mathrm{ξ}}\right)}^{{2}}{+}{{\mathrm{sin}}{}\left({\mathrm{η}}\right)}^{{2}}}}& {-}\frac{{\mathrm{cosh}}{}\left({\mathrm{ξ}}\right){}{\mathrm{cos}}{}\left({\mathrm{η}}\right){}{\mathrm{sin}}{}\left({\mathrm{φ}}\right)}{{\mathrm{sinh}}{}\left({\mathrm{ξ}}\right){}{\mathrm{sin}}{}\left({\mathrm{η}}\right)}\end{array}\right]$ (5)

 See Also