linalg(deprecated)/grad - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


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

linalg(deprecated)

  

grad

  

vector gradient of an expression

 

Calling Sequence

Parameters

Description

Examples

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[1]), diff(expr, v[2]), ...] ).

• 

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[1], v[2], v[3]

with unit vectors a[1], a[2], a[3], and scale factors

h[1], h[2], h[3]:

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

> 

with⁡linalg:

> 

grad⁡3⁢x2+2⁢y⁢z,vector⁡x,y,z

6⁢x2⁢z2⁢y

(1)
> 

f≔r⁢sin⁡θ⁢z2:v≔r,θ,z:

> 

grad⁡f,v,coords=cylindrical

sin⁡θ⁢z2cos⁡θ⁢z22⁢r⁢sin⁡θ⁢z

(2)
> 

g≔r2⁢sin⁡θ⁢cos⁡φ:v≔r,θ,φ:

> 

grad⁡g,v,coords=spherical

2⁢r⁢sin⁡θ⁢cos⁡φr⁢cos⁡θ⁢cos⁡φ−r⁢sin⁡φ

(3)

define the scale factors in spherical coordinates

> 

h≔1,r,r⁢sin⁡θ:

> 

grad⁡g,v,h

2⁢r⁢sin⁡θ⁢cos⁡φr⁢cos⁡θ⁢cos⁡φ−r⁢sin⁡φ

(4)
> 

l≔cosh⁡ξ⁢cos⁡η⁢cos⁡φ:v≔ξ,η,φ:

> 

grad⁡l,v,coords=prolatespheroidal⁡1

sinh⁡ξ⁢cos⁡η⁢cos⁡φsinh⁡ξ2+sin⁡η2−cosh⁡ξ⁢sin⁡η⁢cos⁡φsinh⁡ξ2+sin⁡η2−cosh⁡ξ⁢cos⁡η⁢sin⁡φsinh⁡ξ⁢sin⁡η

(5)

See Also

addcoords

coords

diff

linalg(deprecated)[curl]

linalg(deprecated)[diverge]

linalg(deprecated)[laplacian]

LinearAlgebra

VectorCalculus[Gradient]