Scientific computing with R (DSE course)

This course is designed for the 4th Semester undergraduate students, who are pursuing Mathematics as major subject from the University of Calcutta. The construction of the course is totally designed on the mathematical computation in Sagemath/R software. But, here I will teach only the R software due to its popularity throughout the world. Researchers are very much flexible with this software and easily available from internet. A brief introduction is outlined below. Note that, the mode of the examination is theoretical, i.e., students have to write all codes in their copy during the examination hall. No electronic support except the calculator is there. But, the ability of any software will be gained only if he/she practice in the virtual platform. That's why beside the theoretical input, hands-on-training is equally important. 

Here I will attach the theoretical input as an attachment and the codes will be displayed just below the attachment. 

I must mention the credit of one of my student, Mr. Srijan Das, who helped me to find out an online platform for the execution of the R codes. Click on the link and grab the R platform to execute the codes. 

I also indebted to Ms. Nabeela Jahan, who has documented the entire note for the course along with the solutions of university question papers. You can also the access the handwritten notes by the PDF document.

Acknowledgement:

I would like to thank Prof. Sabyasachi Bhattacharya (PhD supervisor), and Dr. Nanda Das for giving such an opportunity to take these classes. 

Introduction with R software:

It was begun in the 1990s by Robert Gentleman and Ross Ihaka of the Statistics Department of the University of Auckland. Nearly 20 senior statisticians provide the core development group of the R language, including the primary developer of the original §language, John Chambers, of Bell Labs. It contains a large, coherent, integrated collection of intermediate tools for data analysis. The software is FREE and can be downloaded from  http://www.r-project.org/  or you can download from R software . The versatility of this software is that it can be used in every domain and the coding structure in this software is quite easy rather than the others. Moreover, R software is used not only for coding purpose, you can also prepare any manuscript or prepare any sorts of presentation in this software. R markdown will help in this case. The major yardstick of the software is the R packages. Basically, Packages are collections of R functions, data, and compiled code in a well-defined format. The directory where packages are stored is called the library. Currently, the CRAN package repository features 10964 available packages.https://cran.r-project.org/web/packages/. To install packages type install.packages(pkgs, dependencies=TRUE) in the console.

In most of my research work i have used this software. Moreover, for any sorts of discrepancy do not hesitate to contact me. The contact details is provided in my home page. Don't worry this page will be update as per your needs. 

References:

Day 1 : 21st March 2023 (2.30 p.m. - 4.30 p.m. )

Fundamental Matrix operations

# Matrix operations 

# Question 2

## Execute the codes line by line or click on "Ctrl+Enter".

e1 = c(2, 4, 6, 5, 5, 3, 3, 2, 4) # Space is not necessary

A = matrix(e1, ncol = 3, nrow = 3, byrow = F)

A

e2 = c(3, 6, 2, 2, 1, 3, 5, 2, 4)

B = matrix(e2, ncol = 3, nrow = 3, byrow = F)

B

C = A+B

C

## Question 3 (Component wise multiplication)


e1 = c(2, 4, 6, 5, 5, 3, 3, 2, 4) # Space is not necessary

A = matrix(e1, ncol = 3, nrow = 3, byrow = F)

A

e2 = c(3, 6, 2, 2, 1, 3, 5, 2, 4)

B = matrix(e2, ncol = 3, nrow = 3, byrow = F)

B

C = A*B

C


## Question 3 (Row-by-column wise multiplication)

e1 = c(2, 4, 6, 5, 5, 3, 3, 2, 4) # Space is not necessary

A = matrix(e1, ncol = 3, nrow = 3, byrow = F)

A

e2 = c(3, 6, 2, 2, 1, 3, 5, 2, 4)

B = matrix(e2, ncol = 3, nrow = 3, byrow = F)

B

C = A%*%B

C


## Question 4

dim(A)

### Transpose of a matrix

A

t(A)

## Determinant

det(A)

### Diagonal Matrix

e3 = c(1, 2) ## First define the vector 

diag(e3) ## Execute the command


## Inverse of a matrix

solve(A)


## Trace of a matrix

e4 = diag(A); e4

sum(e4)


## Solution of system of equation

a1 = c(4, 2, -1, 7, 3, -1, 1, 1, 12)

A = matrix(a1, ncol = 3, nrow = 3, byrow = F)

A

a2 = c(3, 19, 31)

B = matrix(a2, ncol = 1, nrow = 3, byrow = F)

B

solve(A, B)


## Rank of matrix 

v = qr(A)

v$rank

### Verify the rank by enumerating det(A)

## Since det(A) is not equal to zero, so the rank is 3


## Eigen values

temp = eigen(A)

temp$values ## Eigen values

temp$vectors ## Eigen vectors