Vector Calculus in Cartesian Coordinates

This example comes from subsections 4.6.3 and 4.6.4.

Copyright Notice

Copyright 1989 by Roman Maeder.
	
	Adapted from	Roman E. Maeder: Programming in Mathematica, Addison-Wesley, 1989.
	
	Permission is hereby granted to make copies of	this file for any purpose other than direct profit,	or as part of a commercial product, provided this copyright notice is left intact.	Sale, other than for the cost of media, is prohibited.
	
	Permission is hereby granted to reproduce part or all of this file provided that the source is acknowledged.

Examples

A symbolic Laplacian

This example is from page 103

Laplacian[ v[x, y], {x, y} ]

The Graviational of Electrical Force Field

Components of the central force field

e = { x, y, z } / (x^2 + y^2 + z^2)^(3/2)

Its divergence should be 0.

Div[ e, {x, y, z} ]

It needs to be simplified to see that the result is correct.

Together[ % ]

The Jacobian Matrix

This example is from page 6.

JacobianMatrix[ {f[x, y, z], g[x, y, z]}, {x, y, z} ] //
	MatrixForm

Implementation

BeginPackage["RMPackages`VectorCalculus`"]

Div::usage = "Div[v, varlist] computes the divergence of
	the vectorfield v w.r.t. the given variables in Cartesian coordinates."

Laplacian::usage = "Laplacian[s, varlist] computes the Laplacian of
	the scalar field s w.r.t. the given variables in Cartesian coordinates."

Grad::usage = "Grad[s, varlist] computes the gradient of s
	w.r.t. the given variables in Cartesian coordinates."

JacobianMatrix::usage = "JacobianMatrix[flist, varlist] computes the Jacobian of
	the functions flist w.r.t. the given variables."

Begin["`Private`"]

Div[v_List, var_List] := Inner[D, v, var, Plus]

Grad[s_, var_List] := D[s, #]& /@ var

Laplacian[s_, var_List] := Div[ Grad[s, var], var]

JacobianMatrix[f_List, var_List] := Outer[D, f, var]

End[]

Protect[ Div, Laplacian, Grad, JacobianMatrix ]

EndPackage[]