The answersDownload the PDF
Worksheet

A3.7 Vectors

Data structures · A level · AQA 7517 4.2.1.4 · about 25 min

BugBotLab
NameClassDate

What this lesson is about

Vectors as lists, functions and arrows; addition, scaling, dot product and convex combination, on the robot's position.

Questions 6 marks in all

  1. [1 mark]What is the dot product of [2, -1, 3] and [4, 5, 1]?

  2. [1 mark]What does this program print?

    u = [2, 5]
    v = [6, 1]
    w = [0.5 * u[i] + 0.5 * v[i] for i in range(2)]
    print(w)
    
  3. [1 mark]For αu + βv to be a convex combination of u and v, which conditions must hold?

    1. Aα ≥ 0, β ≥ 0 and α + β = 1
    2. Bα + β = 0
    3. Cα = β
    4. Dα > 1 and β > 1
  4. [1 mark]The dot product of two non-zero vectors is 0. What does that tell you?

    1. AThey are perpendicular
    2. BThey point in the same direction
    3. CThey have the same magnitude
    4. DOne of them is the zero vector
  5. [1 mark]The vector [2.0, 3.5, -1.0] is a member of which set?

    1. Aℝ³
    2. Bℝ²
    3. Cℕ³
    4. Dℝ¹
  6. [1 mark]What is the angle, in degrees, between the vectors [1, 0] and [1, 1]?

The task: meet on the line

Two beacons are at u = [40, 20] and v = [-20, 60], in cm from the robot's start (x to the right, y forward). Write these three functions yourself, for vectors of any length, without numpy: - add(a, b): returns a new list, the vector sum of a and b. - scale(k, a): returns a new list, the number k times the vector a. - dot(a, b): returns the dot product of a and b, a single number. Then print, in this order: 1. u.v = <dot product>, which is a whole number. 2. angle = <angle> degrees, the angle between u and v rounded to a whole number with round(). You will need math.acos, math.degrees and math.sqrt. 3. w = <w>, where w = 0.25u + 0.75v, built with scale and add, printed as a Python list, for example w = [1.0, 2.0]. Finally drive to w: slide sideways by its x component (left if it is negative) and then forward by its y component.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
import math

u = [40, 20]
v = [-20, 60]

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/a3-7-vectors/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Is w really on the segment between the beacons? Check that w - u is a positive scalar multiple of v - u.
  2. Find two different whole-number vectors whose dot product with [3, 4] is zero. What do they have in common?
  3. Rewrite dot so it takes two vectors stored as dictionaries, where missing indexes mean zero.