Can mathematica perform symbolic vector calculus? Say I want to find

$$\mathbf{v} = \mathbf{a} \exp(\mathbf{b}\cdot\mathbf{x})$$ $$\nabla \cdot \mathbf{v} = \mathbf{b}\cdot \mathbf{v}$$

If I try

v = a Exp[b . x]
Div[v, x]

It doesn't evaluate the divergence. I can find the result I want by doing

v = {a1, a2, a3} Exp[{b1, b2, b3} . {x1, x2, x3}]
Div[v, {x1, x2, x3}]
% == {b1, b2, b3}.v

But this is highly tedious. Is it possible to symbolically find the divergence?

  • 1
    $\begingroup$ The add-on package xAct could do what you want, but it would probably be overkill for this purpose alone. (It's designed for calculations in differential geometry.) $\endgroup$ Aug 26, 2021 at 14:02

1 Answer 1


The divergence cannot be calculated unless one did not explicitly define v as a 3D vector. This, however, can be easily done.

Below I will use the capital letters for vectors, while the small ones I reserve for their projections.

Try the following. Let us first define vectors A, B and X:

Clear[a, b, v, V, A, B];

{A, B, X} = Transpose@Table[j[i], {i, 3}, {j, {a, b, x}}]

(* {{a[1], a[2], a[3]}, {b[1], b[2], b[3]}, {x[1], x[2], x[3]}}  *)

Now let us define the vector V according to your formula:

V = A*Exp[B . X]

(*  {E^(b[1] x[1] + b[2] x[2] + b[3] x[3]) a[1], 
 E^(b[1] x[1] + b[2] x[2] + b[3] x[3]) a[2], 
 E^(b[1] x[1] + b[2] x[2] + b[3] x[3]) a[3]}  *)

After that the divergence calculates automatically:

Div[V, X]

(*  E^(b[1] x[1] + b[2] x[2] + b[3] x[3]) a[1] b[1] + 
 E^(b[1] x[1] + b[2] x[2] + b[3] x[3]) a[2] b[2] + 
 E^(b[1] x[1] + b[2] x[2] + b[3] x[3]) a[3] b[3]  *)

You did not ask about it, however, sometimes people claim that the resulting form is much too clumsy. If you want to transform it to a more usual form it can be done in several ways. For example, this:

Div[V, X] /. z_[k_] -> Subscript[z, k]

yielding the following:

enter image description here

Have fun!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.