Linear Algebra

Inner Product

  • \(x^Ty\)
  • t(x) %*% y

Norm

  • \(||x||\)
  • norm(x, type = "2")
    • See help for other types

Cosine Angle

  • \(\cos{\theta}=\frac{x^Ty}{||x||_2||y||_2}\)
  • (t(x) %*% y)/(norm(x, "2")*norm(y, "2"))