# Vector fields

Vector fields represent fluid flow (among many other things). They also offer a way to visualize functions whose input space and output space have the same dimension.

## Background

**Vector notation**:

- $\hat{\textbf{i}}$ is the unit vector in the $x$-direction
- $\hat{\textbf{j}}$ is the unit vector in the $y$-direction
- $\hat{\textbf{k}}$ is the unit vector in the $z$-direction

## What we're building to

- A vector field associates a vector with each point in space.
- Vector field and fluid flow go hand-in-hand together.
- You can think of a vector field as representing a multivariable function whose input and output spaces each have the same dimension.
- The length of arrows drawn in a vector field are usually not to scale, but the ratio of the length of one vector to another should be accurate. Sometimes vector length is communicated using color.

## Warmup: Drawing motion using velocity vectors

How do you draw a moving object? One way, common in math and physics, is to attach the

**velocity vector**describing that object's movement to the drawing.- The length (magnitude) of the vector indicates the speed.
- The direction of the vector indicates which way the object is moving.

For example, suppose you have, oh I don't know, a fox and a whale, each moving to the left. Let's say the fox is moving (or rather being dragged, the way I drew it) $10$ meters per second, and the whale is moving $5$ meters per second. You might depict their motions like this:

There are two important conventions to notice in this example:

- The description of a vector only tells us its magnitude and direction (e.g. $10$ meters per second to the left), but not
*where*to draw the vector. The choice to attach the tail of the vector the object whose movement it represents is just a convention. - The actual lengths of the vectors in our drawing don't really matter, just as long as the vector attached to the fox is twice as long as the one attached to the whale. You can just tell the person looking at the image "whatever the length of the arrow I just drew off the fox,
*that's*what $10$ meters per second should look like."

## Motivating example: Flowing fluids in two dimensions

Now let's kick it up a notch. What instead of depicting the motion of one or two objects, you had a

*fluid*that was flowing in some particular manner. For example, the following animation depicts such a fluid flow by showing the motion of just a few fluid particles (drawn as blue dots):To represent

*this*kind of motion, we need to convey much more information than just a magnitude and a direction. We need to express the velocity of*every individual particle*in the fluid.Actually, when it comes to drawing this motion, we can get away with representing only a sample of the particles. For instance, if you draw a velocity vector on each of the particles shown in the animation, and if you add some coordinate axes to keep track of where everything is, you might get a diagram that looks like this:

If you let your eyes follow the arrows in the image, moving from one to the next, you can get a very good feel for how the fluid it represents flows, even though it is a static image. Particles near each other tend to move at the same speed and direction. Therefore, each arrow not only represents the velocity of the individual particle it is attached to, but it also gives a feel for how the neighborhood of particles around it moves.

A diagram like this is called a

**vector field**.One important thing to mention about the way people typically draw vector fields is that

**vectors are almost never drawn to scale**. For example, if an individual fluid particle was moving at $10$ meters per second, we should technically make the arrow attached to it $10$ units long, but that could span the entire image! If there were really long arrows attached to each point, directed every which way, the diagram could be a real mess.As a result, it's common to scale each vector down so that they all fit cleanly in the image. What's important is not the specific length of any one vector, but how the lengths of different vectors compare to each other.

Another way some graphing software represents relative length is to color each vector. For instance, the following image shows the same vector field using colors: Dark blue arrows should be understood to be "shorter" than light blue arrows, even though technically they are all the same length.

Let's think about what a vector field is mathematically. Each point in two-dimensional space is associated with a two-dimensional vector. We can think of this as a (multivariable) vector-valued function, whose input is a point $(x, y)$ in two-dimensional space, and whose output is a two-dimensional vector.

For example, the function I used to generate the fluid flow and vector field above is

Since both the input and the output of this function have two coordinates, trying to graph it would require four dimensions. But with only a two-dimensional drawing we've represented it almost completely! What's more, this image gives a much better intuition for the swirling fluid it is meant to represent than a graph ever could.

**Concept check**: Given the formula I just gave for $f$, what are the components of a vector attached to the point $\left(\pi, \dfrac{\pi}{2}\right)$ in the $xy$-plane?

## Example 1: The identity function

Consider this function:

This associates a given point in two-dimensional space, like $(3, 4)$, with a vector that has those same coordinates. For example, this is what the vector attached to $(3, 4)$ will look like:

When you do this at many more points in the plane, and scale all the vectors so that they don't get too messy, you get an image like this:

## Example 2: No horizontal component

Next consider the function

The $x$-component of the output is always $0$, so the vectors in our vector field should only point up or down.

The second coordinate of the output tells us how tall each vector should be. Since this has a $y$ factor, arrows should get longer as we walk away form the $x$-axis, and shorter as we walk towards it (why?). There is also a $\sin(x)$ factor, so as we walk from left to right, the height of the vectors will oscillate up and down.

## Example 3: Using graphs for help

Practice makes perfect, so let's look at one more vector-valued function in two dimensions and reason about what the vector field it represents should look like. Thinking this through is a little bit more involved than the previous examples.

Since $x$ does not appear anywhere in the output, the vectors in our field will remain unchanged as we pan left and right (why?).

The first component of all our vectors is always $1$, so all vectors will have the same rightward component. As for the second component of the vectors, they will equal $y^2 - y$, but what does that look like?

We can take a brief sidestep to get a feel for the expression $y^2-y$ by looking at the graph of the single-variable function $g(y) = y^2 - y$. The expression factors as $y(y-1)$, so its roots are at $0$ and $1$. We also know it is an upward facing parabola since it is a quadratic with a positive first term, so we get this graph:

This function is positive outside the range $[0, 1]$, and slightly negative within it.

Now take a look again at our vector field's function.

The $y$-component of each vector will be slightly negative (i.e. they will point down) when $y$ is between $0$ and $1$. As $y$ gets farther away from that range, going either up or down on the plane, the $y$-component of the vector will be increasingly positive, so each vector will point more and more up. Sketching this out, you might get something like this:

## Vector fields in three dimensions

We could do the same thing in three dimensions, perhaps modeling air currents. Analogous to the two-dimensional case, we associate each point in three-dimensional space with a three-dimensional vector and draw only a sample of those vectors.

The following video shows what such a three-dimensional vector field might look like, with colors closer to red indicating longer vectors and colors closer to blue indicating shorter vectors.

This time, our vector field represents a function with a $3$-coordinate input and a $3$-coordinate output, so graphing it would have required $6$ dimensions! The specific function used for this example was

Drawing three-dimensional vector fields can be difficult, and even when we do, perhaps with some graphics software, the vectors can get in each other's way so that it's hard to see what's happening. As a result, this is one of those visualizations that is very useful as a loose idea to hold in your head, but not necessarily useful for precise representations.

## Summary

- A vector field associates a vector with each point in space.
- Vector field and fluid flow go hand-in-hand together.
- You can think of a vector field as representing a multivariable function whose input and output spaces each have the same dimension.
- The length of arrows drawn in a vector field are usually not to scale, but the ratio of the length of one vector to another should be accurate. Sometimes vector length is communicated using color.