# potential

Potential of vector field

## Syntax

`potential(V,X)potential(V,X,Y)`

## Description

`potential(V,X)` computes the potential of the vector field `V` with respect to the vector `X` in Cartesian coordinates. The vector field `V` must be a gradient field.

`potential(V,X,Y)` computes the potential of vector field `V` with respect to `X` using `Y` as base point for the integration.

## Input Arguments

 `V` Vector of symbolic expressions or functions. `X` Vector of symbolic variables with respect to which you compute the potential. `Y` Vector of symbolic variables, expressions, or numbers that you want to use as a base point for the integration. If you use this argument, `potential` returns `P(X)` such that `P(Y) = 0`. Otherwise, the potential is only defined up to some additive constant.

## Examples

Compute the potential of this vector field with respect to the vector `[x, y, z]`:

```syms x y z P = potential([x, y, z*exp(z)], [x y z])```
```P = x^2/2 + y^2/2 + exp(z)*(z - 1)```

Use the `gradient` function to verify the result:

`simplify(gradient(P, [x y z]))`
```ans = x y z*exp(z)```

Compute the potential of this vector field specifying the integration base point as `[0 0 0]`:

```syms x y z P = potential([x, y, z*exp(z)], [x y z], [0 0 0])```
```P = x^2/2 + y^2/2 + exp(z)*(z - 1) + 1```

Verify that `P([0 0 0]) = 0`:

`subs(P, [x y z], [0 0 0])`
```ans = 0```

If a vector field is not gradient, `potential` returns `NaN`:

`potential([x*y, y], [x y])`
```ans = NaN```

expand all

### Scalar Potential of Gradient Vector Field

The potential of a gradient vector field V(X) = [v1(x1,x2,...),v2(x1,x2,...),...] is the scalar P(X) such that $V\text{​}\left(X\right)=\nabla P\text{ }\left(X\right)$.

The vector field is gradient if and only if the corresponding Jacobian is symmetrical:

$\left(\frac{\partial {v}_{i}}{\partial {x}_{j}}\right)=\left(\frac{\partial {v}_{j}}{\partial {x}_{i}}\right)$

The `potential` function represents the potential in its integral form:

$P\text{​}\text{ }\left(X\right)=\underset{0}{\overset{1}{\int }}\left(X\text{​}-\text{​}\text{ }Y\right)\text{\hspace{0.17em}}\cdot V\text{​}\left(Y\text{ }+\text{ }\text{\hspace{0.17em}}\lambda \left(X\text{​}-\text{​}\text{ }Y\right)\right)\text{\hspace{0.17em}}d\lambda$

### Tips

• If `potential` cannot verify that `V` is a gradient field, it returns `NaN`.

• Returning `NaN` does not prove that `V` is not a gradient field. For performance reasons, `potential` sometimes does not sufficiently simplify partial derivatives, and therefore, it cannot verify that the field is gradient.

• If `Y` is a scalar, then `potential` expands it into a vector of the same length as `X` with all elements equal to `Y`.