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

Vectors and Matrices

Vectors and Matrices Exercise 1 Consider the following vectors in $ \mathbb{R}^7 $: $$ u = (0.5, 0.4, 0.4, 0.5, 0.1, 0.4, 0.1), \quad v = (-1, -2, 1, -2, 3, 1, -5) $$ Check if $ u $ and $ v $ are unit vectors. Calculate the dot product of the vectors $ u $ and $ v $. Are $ u $ and $ v $ orthogonal? Exercise 2 Consider the following vectors in $ \mathbb{R}^9 $: ...

November 6, 2025 · 742 wierder

Mathematics for Machine Learning

Mathematics for Machine Learning Exercise 1 : Basic vector operations Let $$ \mathbf{u} = (1,2,-1)^\top, \quad \mathbf{v} = (0,1,3)^\top. $$ Compute: ⟨u, v⟩ \( \| \mathbf{u} \|_2 \) and \( \| \mathbf{v} \|_2 \) Projection of u onto v. Exercise 2 : Linear system Solve: $$ A = \begin{pmatrix} 2 & -1 & 0 \\ 1 & 1 & 1 \\ 0 & 2 & -1 \end{pmatrix}, \quad \mathbf{b} = \begin{pmatrix} 1 \\ 3 \\ -1 \end{pmatrix}, \quad A\mathbf{x} = \mathbf{b}. $$Exercise 3 : Data interpretation Given points (1,2), (2,3), (3,5), form the design matrix X for ...

Oktober 30, 2025 · 409 wierder

Polynomial Division Theorem

Polynomial Division Theorem Exercise 1 : Polynomial Long Division Divide using polynomial long division. $(x^2 + 5x + 6) \div (x + 2)$ $(2x^2 - 7x + 3) \div (x - 3)$ $(x^3 - 8) \div (x - 2)$ $(3x^3 - 2x^2 + 4x - 1) \div (x^2 - x + 1)$ $(x^4 - 16) \div (x^2 + 4)$ $(2x^4 - 3x^3 + x^2 - 5x + 2) \div (x^2 - 2x + 1)$ ...

September 28, 2025 · 655 wierder

Null Spaces and Ranges

Null Spaces and Ranges Exercise 1 Give an example of a linear map \( T \) such that \(\dim \text{null} \, T = 3\) and \(\dim \text{range} \, T = 2\). Exercise 2 Suppose \( V \) is a vector space and \( S, T \in \mathcal{L}(V, V) \) are such that \[\text{range} \, S \subset \text{null} \, T.\] Prove that \((ST)^2 = 0\). Exercise 3 Suppose \( v_1, \ldots, v_m \) is a list of vectors in \( V \). Define \( T \in \mathcal{L}(\mathbb{F}^m, V) \) by ...

September 9, 2025 · 1274 wierder

Vector Space of Linear Maps

Vector Space of Linear Maps Exercise 1 Suppose \( b, c \in \mathbb{R} \). Define \( T: \mathbb{R}^3 \to \mathbb{R}^2 \) by \[T(x, y, z) = (2x - 4y + 3z + b, 6x + cxyz).\] Show that \( T \) is linear if and only if \( b = c = 0 \). Exercise 2 Suppose \( b, c \in \mathbb{R} \). Define \( T: \mathcal{P}(\mathbb{R}) \to \mathbb{R}^2 \) by ...

September 9, 2025 · 476 wierder

Dimension

Dimension Exercise 1 Suppose \( V \) is finite-dimensional and \( U \) is a subspace of \( V \) such that \[\dim U = \dim V \] Prove that \( U = V \) Exercise 2 Show that the subspaces of \( \mathbb{R}^2 \) are precisely \(\{0\}, \mathbb{R}^2\), and all lines in \( \mathbb{R}^2 \) through the origin. Exercise 3 Show that the subspaces of \( \mathbb{R}^3 \) are precisely \(\{0\}, \mathbb{R}^3\), all lines in \( \mathbb{R}^3 \) through the origin, and all planes in \( \mathbb{R}^3 \) through the origin. ...

September 9, 2025 · 685 wierder

Bases

Bases Exercise 1 Find all vector spaces that have exactly one basis. Exercise 2 Verify all the assertions: The list \((1,0,\ldots,0), (0,1,0,\ldots,0), \ldots, (0,\ldots,0,1)\) is a basis of \(\mathbb{F}^n\), called the standard basis of \(\mathbb{F}^n\). The list \((1,2), (3,5)\) is a basis of \(\mathbb{F}^2\). The list \((1,2,-4), (7,-5,6)\) is linearly independent in \(\mathbb{F}^3\) but is not a basis of \(\mathbb{F}^3\) because it does not span \(\mathbb{F}^3\). The list \((1,2), (3,5), (4,13)\) spans \(\mathbb{F}^2\) but is not a basis of \(\mathbb{F}^2\) because it is not linearly independent. ...

September 9, 2025 · 477 wierder

Subspaces

Subspaces Exercise 1 For each of the following subsets of $\mathbb{F}^3$, determine whether it is a subspace of $\mathbb{F}^3$: ${(x_1, x_2, x_3) \in \mathbb{F}^3 : x_1 + 2x_2 + 3x_3 = 0}$ ${(x_1, x_2, x_3) \in \mathbb{F}^3 : x_1 + 2x_2 + 3x_3 = 4}$ ${(x_1, x_2, x_3) \in \mathbb{F}^3 : x_1 x_2 x_3 = 0}$ ${(x_1, x_2, x_3) \in \mathbb{F}^3 : x_1 = 5x_3}$ Exercise 2 Show that the set of differentiable real-valued functions $f$ on the interval $(-4, 4)$ such that $f’( -1) = 3f(2)$ is a subspace of $\mathbb{R}^{(-4, 4)}$. ...

September 9, 2025 · 887 wierder