Bitpath

Lesson 1 · Unit 01

Vectors

Lists of numbers you can add, scale and measure

12 exercisesabout 3 min

What you practise

  • A vector as a point and as an arrow, adding and scaling, length (norm), distance
  • NumPy arrays and element-wise operations

Try a question from this lesson

Pick one

A drone flies 3 km east, then 4 km north. How far is it from its start, in a straight line?

Hint

East and north meet at a right angle. Which school rule links the sides of a right triangle?

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

A vector is a list of numbers

Read [3, 4] as a point (3 east, 4 north) or as the arrow from zero to that point. Both views are useful.

A vector can have any number of entries. A house might be [rooms, floors, age]. A word in a language model is a vector with hundreds of entries.

In NumPy a vector is an array. Its shape says how many entries it has.

Python
import numpy as np

v = np.array([3, 4])
print(v.shape)   # (2,)
print(v[0])      # 3

Concept

Length has a name: the norm

The length of a vector is called its norm. The recipe works for any number of entries: square them all, add, take the square root.

np.linalg.norm does it in one call. The second line below spells out the same recipe, so you can see there is no magic.

Python
import numpy as np

v = np.array([1, 2, 2])
print(np.linalg.norm(v))        # 3.0
print(np.sqrt(np.sum(v ** 2)))  # 3.0

9 more exercises in the app

  • 3× type the answer
  • 2× multiple choice
  • 1× fill the blanks
  • 1× true or false
  • 1× order the lines
  • 1× match the pairs

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy