Vector Spaces: Exercises


2. Normality. A vector, a, is normal if its Euclidean norm is 1:

$$||a|| = \sqrt{a \cdot a} = \sqrt{\sum_{i=1}^{N}a_{i}^{2}} = 1$$

In the previous exercise, you computed the dot product of vectors. We can compute the Euclidean norm by taking the dot product of a vector with itself, and then taking the square root of the resulting quantity. You can use %*% to compute the dot product and sqrt() to compute the square root.

Check whether each pair of vectors in the set {a, b, c} is normal. Note that each vector has been defined for you.


a <- c(1,0,0) b <- c(0,1,0) c <- c(0,0,1) # Compute the norm of a. norm_a <- sqrt(a ___ a) # Compute the norm of b. norm_b <- sqrt(___ %*% ___) # Compute the norm of c. norm_c <- ___ # Print the dot products. print(c(norm_a, norm_b, norm_c)) # Compute the norm of a. norm_a <- sqrt(a %*% a) # Compute the norm of b. norm_b <- sqrt(b %*% b) # Compute the norm of c. norm_c <- sqrt(c %*% c) # Print the dot products. print(c(norm_a, norm_b, norm_c)) test_error() test_object("norm_a", incorrect_msg="Did you use the `%*%` operator and `sqrt()` function?") test_object("norm_b", incorrect_msg="Did you use the `%*%` operator and `sqrt()` function?") test_object("norm_c", incorrect_msg="Did you use the `%*%` operator and `sqrt()` function?") success_msg("Excellent work. Is each pair of vectors orthogonal?")
Remember to use the %*% operator and `sqrt()` function to compute the norm.

Previous Exercise Next Exercise