The fundamental building blocks of linear algebra are vectors. Vectors are defined as quantities having both direction and magnitude, compared to scalar quantities that only have magnitude. In order to have direction and magnitude, vector quantities consist of two or more elements of data. The dimensionality of a vector is determined by the number of numerical elements in that vector. For example, a vector with four elements would have a dimensionality of four.

Let’s take a look at examples of a scalar versus a vector. A car driving at a speed of 40mph is a scalar quantity. Describing the car driving 40mph to the east would represent a two-dimensional vector quantity since it has a magnitude in both the x and y directions.

Vectors can be represented as a series of numbers enclosed in parentheses, angle brackets, or square brackets. In this lesson, we will use square brackets for consistency. For example, a three-dimensional vector is written as:

v=[xyz]v = \begin{bmatrix} x \\ y \\ z \end{bmatrix}

The magnitude (or length) of a vector, ||v||, can be calculated with the following formula:

v=i=1nvi2||v|| = \sqrt{\sum\limits_{i=1}^{n} v_{i}^2}

This formulates translates to the sum of each vector component squared, which can be also written out as:

v=v12+v22++vn2||v|| = \sqrt{v_{1}^2 + v_{2}^2 + \dots + v_{n}^2}

Let’s look at an example. We are told that a ball is traveling through the air and given the velocities of that ball in its x, y, and z directions in a standard Cartesian coordinate system. The velocity component values are:

  • x = -12
  • y = 8
  • z = -2

Convert the velocities into a vector, and find the total speed of the ball. (Hint: the speed of the ball is the magnitude of the velocity vector!)

Click the dropdown below to check your answers!

The vector form is v = [-12, 8, -2], and the magnitude of the vector is v=14.56.


The applet to the right allows you to play around with the x and y components of a vector. By clicking on the arrowhead of the red vector you can drag it around the xy-plane. You will notice that the magnitude is automatically calculated for you as well. Note that the magnitude is always positive.

Use this applet and/or mathematical calculation to find the magnitudes of the following vectors:

a=[34]a = \begin{bmatrix} 3 \\ - 4\\ \end{bmatrix}
b=[026]b = \begin{bmatrix} 0 \\ 26 \\ \end{bmatrix}
c=[260]c = \begin{bmatrix} 26 \\ 0 \\ \end{bmatrix}
d=[1213]d = \begin{bmatrix} -12 \\ 13 \\ \end{bmatrix}

Note: It may be hard to get to exact values with the applet, but you can use approximations to help verify your mathematical calculations.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?