Vectors#
A vector is a special matrix with just one row or one column. Vectors are the building blocks of matrix operations.
Column Vectors#
A column vector is a matrix with one column:
This is a 3-element column vector. We often use bold lowercase letters for vectors.
Row Vectors#
A row vector is a matrix with one row:
Vectors in Python#
Python Example
Create vectors and inspect their shape
Click Run to execute the example.
What Do Vectors Represent?#
Vectors have many interpretations:
Points in space: A 2D vector \([x, y]\) represents a point or position
Directions: Vectors show direction and magnitude (like velocity or force)
Data samples: A list of measurements (temperatures, prices, sensor readings)
Features: In machine learning, a vector can represent features of an object
Engineering and Science Examples#
Vectors can be used to represent quanties that posses both magnitude and direction. (It’s really hard not think about Despicable Me! whilst writing this).
Lets think of some real examples of quantities that could be reprented by vectors:
Velocity: Speed in a specific direction
Wind speed & direction
Car speed & direction
Acceleration: The rate and direction of a change in velocity
Rocket
Forces
Gravity
Weight
Torque
Electicity & Magnetism
Electic / Magnetic Field
The list goes on!!
Geometric Intuition#
A 2D vector \(\mathbf{v} = [3, 2]\) can be visualized as an arrow from the origin to the point \((3, 2)\):
Python Example
Draw a 2D vector
Click Run to execute the example.
This vector could represent the speed and direction of a moving vehicle or windspeed!!
Vector Operations#
Just like numbers, we can add, subtract, and scale vectors:
Python Example
Add and scale vectors
Click Run to execute the example.
Why Vectors Matter#
Vectors are everywhere in matrix mathematics:
Matrices can be thought of as collections of column or row vectors
Matrix multiplication combines vectors in powerful ways
Many transformations act on vectors to produce new vectors
Understanding vectors is essential for understanding what matrices do.
Try It#
In the vector plot, change v = np.array([3, 2]) to a few different vectors:
[-2, 3][4, -1][0, 3]
Before running each one, predict the direction of the arrow.
Key Takeaways#
A vector is a one-dimensional list of values.
Vectors can represent points, directions, measurements, or features.
Adding vectors combines their components.
Scaling a vector changes its length without changing its basic direction, unless the scale is negative.
Next Steps#
Now let’s look at Matrix Shape and Size to understand how matrices are sized and structured.