- Setting up matrices A and B:
- I created two matrices, A and B, using the
matrix()function in R. - Matrix A contains numbers from 1 to 100, arranged in 10 rows and an unspecified number of columns (automatically calculated).
- Matrix B contains numbers from 1 to 1000, arranged in 10 rows and an unspecified number of columns (automatically calculated).

- Transposing matrices A and B:
- Transposing a matrix involves flipping its rows and columns. I used the
t()function in R to achieve this. - The result of
t(A)will be a matrix where the rows of A become the columns of the result, and vice versa. Similarly for matrix B.

- – 1000
- Creating two vectors (a and b):
- I created two vectors,
aandb, using the:operator to generate sequences of numbers. - Vector
acontains numbers from 1 to the number of columns in matrix A. - Vector
bcontains numbers from 1 to the number of columns in matrix B.

- Multiplying matrices by vectors:
- I performed matrix-vector multiplication using the
%*%operator. A %*% awill multiply matrix A by vectora.B %*% bwill multiply matrix B by vectorb.

- Re-assigning the vectors a and b:
- I re-assigned vectors
aandbto contain a sequence of 1s, with the length of the sequence being equal to the number of rows in matrices A and B, respectively.

- Multiplying the matrices by a matrix:
- I performed matrix-matrix multiplication using the
%*%operator. A %*% Bwill multiply matrix A by matrix B. This operation is only valid if the number of columns in A matches the number of rows in B.

- etc.
- Inversing matrix S and checking its determinant:
- Finally, I created a matrix S using the
matrix()function, containing numbers from 2 to 5 arranged in 2 rows and 2 columns. - I calculated the determinant of matrix S using the
det()function. The determinant of a matrix is a scalar value that can be computed from its elements and is useful for various mathematical operations.

Link to Github Repository: https://github.com/mramalho4/rprog-repo.git
Leave a comment