# Matrix Operations Exercises

**R-exercises**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This 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 a**A** 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 **.

**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 about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.