(ML Coursera) (3Blue1Brown) (Code Implementation) A vector is a matrix with only 1 column

refers to the element in the row of the vector.

import numpy as np
x = np.array([2,5,6])
 
# in Sage
x = vector(QQ, [2,5,6])

(3Blue1Brown: Geometric Intuition) They are both considered as vectors = objects that can be added together and multiplied with a scalar, and live in vector space.

  • When we say geometric vectors, we care more about its representation in the coordinate system. A geometric vector at any other coordinates is just the same, so we can assume its tail (initial point) has the coordinate (0,0) and let its head (endpoint/tip) determine magnitude and direction.
  • When we say algebraic vector, we care more about its representation as numbers.
 

Geometric component

geometric vector

(Minerva Uni) (3Blue1Brown) An object that has both magnitude/length and direction. In space, it’s visualized as a directed line segment.

A vector has these following properties:

  • : tail, coordinate
  • – head, coordinate
  • magnitude/length: can be calculated using Pythagorean theorem or dot product of itself
  • direction: , the angle between AB and the horizontal -axis

  • When we say algebraic vector, we care more about its representation as numbers.
Link to original

Fundamental Operations

Given two vectors and

Addition

It’s the same as adding two algebraic vectors. We say addition of vectors is commutative.

Scalar Multiplication

Multiplying by a scalar changes the length of a vector but NOT its direction (=scales the vector)

If the scalar is negative, the vectors change to the opposite direction. dot product is a scalar, so

Angle between two vectors

See dot product

Dot product

dot product

dot product of two vectors is an operation that takes two equal-length sequences of numbers (vector and ) and returns a single number

  • = ith component of vector
  • = ith component of vector
  • : dimension of the vector space or number of components of either vector

Properties

Aside

A dot product can be written as the product of the transpose vector with the other vector

Distributivity & Associativity

dot product is distributive

and associative

Relationship with 2D vector

(3Blue1Brown) Intuitively, dot product linearly transform one of the vector

Find the magnitude of a vector

The magnitude of a vector is equal to the square root of the dot product of itself

Find the angle between vectors

The angle between two vectors and is computed by their dot product over the product of vector lengths

Prove orthogonal

Two vectors are orthogonal/perpendicular if and only if their dot product is 0.

Link to original

Example

(The Organic Chemistry Tutor) Given two vectors , and

Link to original

Algebraic component

Transpose

Like a transpose matrix, a transposed vector switches row and column indices

import numpy as np
v = np.array([0,1,2],
			[3,4,5])
v.transpose()

Fundamental Operations

Addition

Given two vectors and

It’s the same process as adding two geometric vectors

import numpy as np
v = np.random.randint(-2, 3, size = 5)
w = np.random.randint(-5,6, size = 5)
v + w == w + v

Scalar Multiplication

Given a vector and a scalar

import numpy as np
v = np.random.randint(-2, 3, size = 5)
k = 5
k * v