Loading editor...

Vector Field I: Gradient of a Scalar Function

A vector field can be derived from a scalar function by computing its gradient. In this example, we define a scalar function:

Let's visualize this vector field and see how changing the parameter affects it.


Visualizing the vector field

Now we can visualize the vector field using gm.vector_field, which automatically computes the gradient at each point:


Reactivity

Try changing the value of a to see how the vector field transforms.

Set , or .