Vectors and Matrices in Python Solutions

Vectors and Matrices in Python Solutions Exercise 1 : Vectors in $\mathbb{R}^7$ Consider the following vectors: $$ u = (0.5, 0.4, 0.4, 0.5, 0.1, 0.4, 0.1), \quad v = (-1, -2, 1, -2, 3, 1, -5) $$Using Python and NumPy: Check whether $u$ and $v$ are unit vectors. Compute the dot product of $u$ and $v$. Determine if $u$ and $v$ are orthogonal. import numpy as np u = np.array([0.5, 0.4, 0.4, 0.5, 0.1, 0.4, 0.1]) v = np.array([-1, -2, 1, -2, 3, 1, -5]) # 1. Check if u and v are unit vectors norm_u = np.linalg.norm(u) norm_v = np.linalg.norm(v) print(norm_u, norm_v) # 2. Dot product dot_uv = np.dot(u, v) print(dot_uv) # 3. Orthogonality print(np.isclose(dot_uv, 0)) Exercise 2 : Norms and Orthogonality Consider the following vectors in $\mathbb{R}^9$: ...

November 9, 2025 · 1298 wierder

Vectors and Matrices in Python

Vectors and Matrices in Python In this worksheet, you will use Python (NumPy) to perform vector and matrix operations. For each exercise, write Python code to compute the required results and verify them numerically. Exercise 1 : Vectors in $\mathbb{R}^7$ Consider the following vectors: $$ u = (0.5, 0.4, 0.4, 0.5, 0.1, 0.4, 0.1), \quad v = (-1, -2, 1, -2, 3, 1, -5) $$Using Python and NumPy: Check whether $u$ and $v$ are unit vectors. Compute the dot product of $u$ and $v$. Determine if $u$ and $v$ are orthogonal. Exercise 2 : Norms and Orthogonality Consider the following vectors in $\mathbb{R}^9$: ...

November 9, 2025 · 732 wierder