Matrix Operations Exercises

August 22, 2016
By

(This article was first published on R-exercises, and kindly contributed to R-bloggers)

MatrixThis set of exercises will help you to learn and test your skill in matrix operations, starting with basic ones like scalar multiplication all the way through eigenvalue and eigenvectors. Before proceeding, it might be helpful to look over the help pages for the diag, t, eigen, and crossprod functions. If you want further documentation also consider chapter 5.7 from “An Introduction to R”.

Answers to the exercises are available here.

If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment.

Exercise 1

Consider A=matrix(c(2,0,1,3), ncol=2) and B=matrix(c(5,2,4,-1), ncol=2).
a) Find A + B
b) Find A B

Exercise 2

Scalar multiplication. Find the solution for aA where a=3 and A is the same as in the previous question.

Exercise 3

Using the the diag function build a diagonal matrix of size 4 with the following values in the diagonal 4,1,2,3.

Exercise 4

Find the solution for Ab, where A is the same as in the previous question and b=c(7,4).

Exercise 5

Find the solution for AB, where B is the same as in question 1.

Exercise 6

Find the transpose matrix of A.

Exercise 7

Find the inverse matrix of A.

Exercise 8

Find the value of x on Ax=b.

Exercise 9

Using the function eigen find the eigenvalue for A.

Exercise 10

Find the eigenvalues and eigenvectors of A’A . Hint: Use crossprod to compute A’A .

To leave a comment for the author, please follow the link and comment on their blog: R-exercises.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)