(********************************************************************* Adapted from Roman E. Maeder: Programming in Mathematica, Second Edition, Addison-Wesley, 1991. *********************************************************************) BeginPackage["Calculus`VectorCalculus`"] Div::usage = "Div[v, varlist] computes the divergence of the vector field v with respect to the given variables in Cartesian coordinates." Grad::usage = "Grad[s, varlist] computes the gradient of s with respect to the given variables in Cartesian coordinates." Laplacian::usage = "Laplacian[s, varlist] computes the Laplacian of the scalar field s with respect to the given variables in Cartesian coordinates." JacobianMatrix::usage = "JacobianMatrix[flist, varlist] computes the Jacobian of the functions flist with respect to 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[ ]