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:
The magnitude (or length) of a vector, ||v||, can be calculated with the following formula:
This formulates translates to the sum of each vector component squared, which can be also written out as:
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!
Solution
![The vector form is v = [-12, 8, -2], and the magnitude of the vector is v=14.56.](https://static-assets.codecademy.com/skillpaths/ds-math/vector-solution.png)
Instructions
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:
Note: It may be hard to get to exact values with the applet, but you can use approximations to help verify your mathematical calculations.