Exercises

Exercises#

Linear Algebra Trivia#

  1. \(A\in\mathbb{R}^{n\times r}\), \(B\in\mathbb{R}^{m\times r}\), which product is well-defined?
    A. \(BA\)
    B. \(A^\top B\)
    C. \(AB^\top\)

  2. \(A\in\mathbb{R}^{n\times r}\), \(B\in\mathbb{R}^{m\times r}\), what is equal to \((AB^\top)^\top ?\)
    A. \(A^\top B\)
    B. \(B^\top A^\top\)
    C. \(BA^\top\)

  3. What is the matrix product computed by \(C_{ji}=\sum_{s=1}^rA_{is}B_{js} ?\)
    A. \(C=AB^\top\)
    B. \(C=B^\top A\)
    C. \(C=BA^\top\)

  4. \(A,B\in\mathbb{R}^{n\times n}\) have an inverse \(A^{-1},B^{-1}\), what is generally not equal to \(AA^{-1}B\)?
    A. \(A^{-1}BA\)
    B. \(B\)
    C. \(BB^{-1}B\)

  5. Let \(v,w\in\mathbb{R}^{d}\), \(\alpha\in\mathbb{R}\), then \(\lVert\alpha v + w\rVert\leq\)
    A. \(\alpha\lVert v+w\rVert\)
    B. \(\lvert\alpha\rvert\lVert v\rVert+\lVert w\rVert\)
    C. \(\alpha\lVert v\rVert+\lVert w\rVert\)

  6. Let \(A,B\in\mathbb{R}^{n\times r}\), \(\alpha\in\mathbb{R}\), then \(\lVert A\rVert\leq\) A. \(\lVert A-B\rVert + \lVert B\rVert\) B. \(\alpha\lVert\frac{1}{\alpha}A\rVert\) C. \(\lVert A\rVert^2\)

  7. Let \(A,B\in\mathbb{R}^{n\times n}\), \(A\) is orthogonal, what is not equal to \(\tr(ABA^\top)\)?
    A. \(\tr(A^\top BA)\)
    B. \(\tr(B)\)
    C. \(\tr(ABA)\)

Exercises#

  1. Compute the matrix product \(AB\) inner-product-wise and outer-product-wise

  2. You have observations of \(5\) symptoms of a disease for three patients represented in the binary matrix

    \[\begin{split} A = \begin{pmatrix} 1 & 0 & 1 & 1 & 0\\ 1 & 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 1\end{pmatrix}\end{split}\]
    Compute the matrix \(AA^\top\) and \(A^\top A\) and interpret the result with regard to the scenario.

  3. Find a matrix/vector notation to compute the vector of average feature values for a matrix \(A\in\mathbb{R}^{n\times d}\), representing \(n\) observations of \(d\) features. Make an example for your computation.

  4. Every system of linear equations can be written as a matrix equation \(A\vvec{x}=\vvec{y}\). Given the following system of linear equations, what would be the matrix \(A\) and vector \(\vvec{y}\) such that the system of linear equations is equivalent to solving \(A\vvec{x}=\vvec{y}\)?

    \[\begin{align*} 2x_1 &+& 3x_2 && &=&4\\ x_1 &-& 2x_2 &+& x_3 &=& 3\\ -x_1 &+& 2x_2 &+& 3x_3 &=& 1. \end{align*}\]

    Can you solve the system of linear equations by using the inverse of \(A\) (np.linalg.inv(A))?

  5. Show that \(\lVert A - B \rVert^2 = -2\tr(AB^\top) + 2n \) for orthogonal matrices \(A,B\in\mathbb{R}^{n\times n}\).

  6. Show that the following norms are orthogonal invariant

    • the vector \(L_2\)-norm

    • the Frobenius norm (matrix \(L_2\)-norm)

    • the operator norm