If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

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:
  • i^ is the unit vector in the x-direction
  • j^ is the unit vector in the y-direction
  • 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:
  1. 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 to the object whose movement it represents is just a convention.
  2. 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):
Khan Academy video wrapper
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
f(x,y)=[sin(x)+sin(y)sin(x)sin(y)]=(sin(x)+sin(y))i^+(sin(x)sin(y))j^
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 (π,π2) in the xy-plane?
The x-component is
(you might also think of this as the i^ component)

The y-component is
(you might also think of this as the j^ component)

Therefore, this vector points

Example 1: The identity function

Consider this function:
f(x,y)=[xy]
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
f(x,y)=[0ysin(x)]
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.
f(x,y)=[1y2y]
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 y2y, but what does that look like?
We can take a brief sidestep to get a feel for the expression y2y by looking at the graph of the single-variable function g(y)=y2y. The expression factors as y(y1), 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.
f(x,y)=[1y2y]
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.
Khan Academy video wrapper
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
f(x,y,z)=[y+zx+zx+y]
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.

Want to join the conversation?

  • leaf grey style avatar for user Jian
    I find this article confusing in some way. I need to overlap the real/imaginary coordinates (or i/j coordinates?) and the x/y coordinates in my head to understand the vector plots! Are these coordinates the same and interchangable? Should explain this point better to connect the functions and the graphs.
    (7 votes)
    Default Khan Academy avatar avatar for user
    • female robot amelia style avatar for user Carmen Lee
      The x/y coordinates tell us where the point should be in the xy-plane. The two components of the f(x,y) tell us how the directional vector at that point should look like. For example, f(2,2) = (1,1) means the point at (2,2) has the directional vector of (1,1), that is pointing up right with 45 degree to the x-axis. Hope it helps. :)
      (13 votes)
  • leaf green style avatar for user Jim Winters
    The vector field graph in Example 3 seems wrong to me. The x component of the output should always be 1, but the x component of the arrows varies in the graph. I understand that the arrows are scaled, but the x value 1 (scaled) should be the same for each arrow. Compare this graph to the one in Example 2, where the x component of the output is always zero, and the x component of the arrows is always zero.
    (6 votes)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user Moorpark Tuningmeister
      I also find this vector graph confusing. It contradicts this, at the end of the essay : 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. The arrows near to the horizontal axis should be much shorter, to get the ratio of the lengths correct; just as the original post states.
      (12 votes)
  • purple pi purple style avatar for user Briahnna A
    About midway the page stated, "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! ". I was wondering why does it take 6-D and not 3-D? I thought it would be 3-D because the function has only three variables, up to the Z-th dimension.
    (2 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Thomas Huegerich
      When graphing, each dimension represents either one of the inputs or one of the outputs. For instance, when you graph y=f(x), you have the x-axis for the inputs and the y-axis for the outputs. We need another dimension if we add another input, like z=f(x,y), or if we add another output, as in f(x) = (y,z). Essentially, the number of dimensions a graph needs is the total number of inputs and outputs combined. So in your example, with 3 inputs, there needs to be an axis or dimension for each of those, and with 3 outputs on top of that, there needs to be another axis or dimension for each of those; the graph would need 3 input dimensions and 3 output dimensions, or 6 dimensions (6-D) in total.

      Vector fields use the same amount of input dimensions as a graph, but instead of creating new dimensions for each output like a graph does, they condense the outputs into a single vector. We can re-use the axes/dimensions we already have to draw these vectors at the location of each input. So, continuing with your example, but using a vector field this time: with 3 inputs, you need three dimensions, and with 3 outputs, you'd need three more dimensions if we were graphing; but by writing each output as a 3-dimensional vector instead of a whole new set of 3-D points, we can just graph each output vector at each input point, all in only 3-D. That's what makes vector fields so useful--they effectively halve the amount of dimensions needed to represent a function in space.
      (17 votes)
  • blobby green style avatar for user kMoney
    Do you have suggestions for freeware that can graph multi variable functions and their vector fields like this?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • mr pants teal style avatar for user Anthony Natoli
    In the third paragraph, it says of the example vector field: "For instance, one can tell that the fluid depicted by image above is swirling counterclockwise". After "counterclockwise", the phrase "relative to the view above the xy-plane", since the depiction of the image and the vector field depends on where the observer is viewing the vector field.

    When it comes to vector fields, one must always be aware of the direction of viewing the vector field; that is, the orientation of the observer.

    Just saying "counterclockwise" is vague, and in fact incorrect if the vector field were to be viewed from a different direction relative to the xy-plane. For example, if viewed from "the other side" of the xy-plane, with positive x to the left and positive y still upward, the vector field would be in the clockwise direction relative to that specific view from "the other side" of the xy-plane.

    To use a specific physical example, if the vector field represents a whirlpool on the surface of a body of water, the image shown represents viewing the whirlpool from above the water (for example) and having a counterclockwise swirling. However, a swimmer under the water would view the whirlpool from underneath, and would see a clockwise swirling.
    (2 votes)
    Default Khan Academy avatar avatar for user
  • female robot amelia style avatar for user Shubham
    Why do input space and output space of a vector field have same dimension?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Pedro Vielman
      I'm not completely sure why, but i'll give it a try to answer. The way I think of it, you need to have the same number of dimension in the input/output because of the way we tipically depict things like fluids, and electromagnetic fields. In particular, let's think about a fluid. Imagine a particle of that fluid moving in space (3D space), we can associate a velocity vector to these particle (also in 3D)... as you do so with many many particles of the fluid, you get an intuitive picture of the motion of the fluid. But imagine if you tried to asociate particles of a fluid in 2D to vectors in 3D (in other words a function with 2 inputs and 3 outputs) it would be chaos as you'd try to match points in a plane to vector pointing many directions! Even for particles in 1D to velocity vectors in 2D, it would be really hard to interpret it using a vector field (I don't know if the name still applies). That's what I could come up to, but it's worth nothing i'm not completely sure that's the reason why, interesting question though!
      (2 votes)
  • starky ultimate style avatar for user Can Hicabi Tartanoglu
    I don't understand: "You can think of a vector field as representing a multivariable function whose input and output spaces each have the same dimension."

    What is meant by a space having a direction?
    (1 vote)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user irinabains
    Applications of vector fields?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • aqualine sapling style avatar for user Cosmin Saha
      Vector fields are the language of physics. Like in fluid dynamics (why we say think of vector fields like fluids), electromagnetism, gravity, etc. (Note that there is no "Electromagnetic-fluid" or "Gravity-fluid", we just think just think of a negative charge being attracted to a positive charge, like sink faucet pouring water into a drain.
      (1 vote)
  • leafers ultimate style avatar for user Andy Mainord
    Does each input and output make a dimension?
    If there is an input, but no output, it's a one dimensional thing because there is only one number. But with one input and one output it becomes something like f(x)= x^2, which is a two dimensional function. So if there are two outputs and one input, is that a three dimensional thing? And is two outputs and two inputs a four dimensional thing?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • ohnoes default style avatar for user Tejas
      It is better to think about the input space and output space as two separate spaces, not different dimensions in the same space, especially when you have more than three inputs and outputs. But, yes. If there is one input and one output, then the function is one-dimensional, embedded in two dimensions. If there is one input and two outputs, then the function is one-dimensional, but embedded in three dimensions. If there are two outputs and two inputs, the function is two-dimensional, but embedded in four dimensions.
      (1 vote)
  • starky ultimate style avatar for user Shreya
    Vector fields is very confusing topic. Are there any other sources that will give me a better intuition and understanding of what they are about?
    (1 vote)
    Default Khan Academy avatar avatar for user