﻿ VectorField – Algosim documentation
Algosim documentation: VectorField

# VectorField

Creates a planar vector field plot.

## Syntax

• `VectorField(f, ❨xmin, xmax[, δx]❩, ❨ymin, ymax[, δy]❩)`

• `f` is a function D → ℝ² where D ⊂ ℝ²

• `xmin`, `xmax`, `ymin`, and `ymax` are real numbers

• `δx` and `δy` are non-negative real numbers

## Description

The `VectorField` function creates a plot of the vector field `f` in the rectangular region `[xmin, xmax] × [ymin, ymax]` with a sampling distance of `δx` in the first dimension and `δy` in the second dimension. The sampling distance is the distance between arrows. If omitted, a reasonable default value is used (typically producing a plot with about 20 arrows along each direction).

The plot is shown in the current diagram and a reference to the plot is returned.

## Examples

```D ≔ diagram("vector field");
sf ≔ heatmap((x, y) ↦ x^2 + y^2, ❨−10, 10❩, ❨−10, 10❩, '("white", "red"));
vf ≔ VectorField((x, y) ↦ ❨2⋅x, 2⋅y❩, ❨−10, 10❩, ❨−10, 10❩)
``` 