Common Mistakes

Week 3 - Array Operations

1. Counting

Counting the array of elements starts with 0 (zero) in Python, so the first element is the 0th from the perspective of this language.

 

2. Incorrect norm definition

Norm, or the magnitude of a vector, is defined as the square root of the sum of the squares of each component of a vector (eq 1).

Norm of a vector with two components such as v⃗ =[3,−4] can be calculated like in eq. 2.

However, for arrays with higher dimensions, this might be non-intuitive.
Therefore, it might be easier to follow the algorithm on the right.

3. Incorrect unit vector definition

A unit vector is defined as the division of a vector by its norm, eq. 3; see also 'norm'.

If your definition of the unit vector is incorrect, the most likely reason is the incorrect definition of the norm.