0% found this document useful (0 votes)
2 views

Maths Record Output .

The document provides an introduction to R programming, covering package installation, basic arithmetic, and mathematical functions. It includes examples of hypothesis testing using z-tests and t-tests, as well as performing ANOVA tests. Additionally, it outlines the creation of a simple calculator program and provides commands for statistical analysis.

Uploaded by

rr2822129
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Maths Record Output .

The document provides an introduction to R programming, covering package installation, basic arithmetic, and mathematical functions. It includes examples of hypothesis testing using z-tests and t-tests, as well as performing ANOVA tests. Additionally, it outlines the creation of a simple calculator program and provides commands for statistical analysis.

Uploaded by

rr2822129
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Reg.

No:
Name :

Exp. No. 1 Introduction to R DATE: 06.08.2024

Install Packages
>install.packages("package name")

# install package from CRAN

>install.packages("ggplot2")

Loading Packages

# load the package to use in the current R session

>library(packagename)
Reg. No:
Name :

Basics of R Programming

Assignment Operator

# assignment x <- 3
>x <- value
>x = value

Evaluation
# evaluation x
## [1] 3

Case Sensitivity
>x <- 1
>y <- 3
>z <- 4
>x * y * z
[1] 12
>x * Y * z
## Error in eval(expr, envir, enclos): object 'Y' not found

Basic Arithmetic -PEMDAS


>8 + 9 / 5 ^ 2
## [1] 8.36
>8 + 9 / (5 ^ 2)
## [1] 8.36
>8 + (9 / 5) ^ 2
## [1] 11.24
>1 / 7
## [1] 0.1428571
## [1] 0.143
>pi
## [1] 3.141592654
>options(digits = 22) pi
## [1] 3.141592653589793115998
# [1] 10.5
>42 %/% 4 # integer division
## [1] 10
>42 %% 4 # modulo (remainder)
## [1] 2
Reg. No:
Name :

Miscellaneous Mathematical Functions


>x <- 10
>abs(x) # absolute value
>sqrt(x) # square root
>exp(x) # exponential transformation
>log(x) # logarithmic transformation
>cos(x) # cosine and other trigonometric functions

# Program make a simple calculator that can add, subtract, multiply and
divide using functions
add <- function(x, y) {
return(x + y) }
subtract <- function(x, y)
{return(x - y)
}
multiply <- function(x, y) {return(x * y)
}
divide <- function(x, y) {return(x / y)
}
# take input from the user
print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
choice = as.integer(readline(prompt="Enter choice[1/2/3/4]: "))
num1 = as.integer(readline(prompt="Enter first number: "))
num2 = as.integer(readline(prompt="Enter second number: "))
operator <- switch(choice,"+","-","*","/")
result <- switch(choice, add(num1, num2), subtract(num1, num2), multiply(num1, num2),
divide(num1, num2))
print(paste(num1, operator, num2, "=", result)

OUTPUT
[1] "Select operation."
[1] "1.Add"
[1] "2.Subtract"
[1] "3.Multiply"
[1]"4.Divide"
Enter choice[1/2/3/4]: 4
Enter first number: 20
Enter second number: 4
[1] "20 / 4 = 5"
Reg. No:
Name :

Add-on Packages
Install BSDA for Unit I by using the command
install.packages("BSDA")

Install dplyr for ANOVA in Unit II using the command


install.packages("dplyr")

Install qcc package for SQC charts for Unit III


install.packages("qcc")

Install pracma package for unit IV


install.packages(“pracma”)

Note:
Every time before applying the commands of respective program call the library
function by using the command such as library(BSDA), library(dplyr), library(qcc) etc.

Programming using R

Simple Manipulation R command Output


Addition of numbers
Assignment operator

Combine values into a


vector or list
All rows and all
columns in data frame

First row and all


columns in data frame

All rows and first and


third all columns in
data frame
Reg. No:
Name :

Exp.No. 2 Testing of hypothesis using Z Date: 12.08.2024

Problem 2.1:

Compute the z score to test whether the sample data 88, 92, 94, 94, 96, 97, 97,
97, 99,99, 83, 92, 94, 94, 96, 97, 97, 97, 99, 99, 105, 109, 109, 109, 110, 112,94,
96, 97, 97, 97, 99,99, 83, 92, 94, 94, 96, 97, 97, 97, 99, 99, 105, 109, 109, 109,
110, 112, 112, 113, 114, 115 support the administrator’s belief that the mean
intelligence test score for all freshman is greater than 109 with sd 10.33.

R command:

>> library(BSDA)

>> data=c(88, 92, 94, 94, 96, 97, 97, 97, 99,99,

+83, 92, 94, 94, 96, 97, 97, 97, 99, 99, 105,

+109, 109, 109, 110, 112,94, 96, 97, 97, 97,


+99,99, 83, 92, 94, 94, 96, 97, 97, 97, 99, 99,

+105, 109, 109, 109, 110,112, 112, 113, 114, 115)

>> z.test(data, mu=109,alternative="greater", sigma.x = 10.33)

Out Put
One-sample z-Test

data: data z = -6.4758, p-value = 1

alternative hypothesis: true mean is greater than 109

95 percent confidence interval:

97.47738 NA

sample estimates:

mean of x 99.81132
Reg. No:
Name :

Problem 2.2:

Compute the z score to test whether the sample data 101, 103, 112,
102, 98, 97, 93, 105, 100, 97, 107, 93, 94, 97, 97, 100, 110, 106, 110, 103, 99,
93, 98, 106, 100, 112, 105, 100, 114, 97, 110, 102, 98, 112, 99 can be drawn
from a normal population with mean 102 and SD 6.

R command:
>> library(BSDA)

>> data=c(101, 103, 112, 102, 98, 97, 93, 105, 100, 97, 107, 93, 94, 97, 97, 100, 110, 106,

110, 103, 99, 93, 98, 106, 100, 112, 105, 100, 114, 97, 110, 102, 98, 112, 99)

>> z.test(data, mu=102,alternative="two.sided", sigma.x = 6)

Out Put

One-sample z-Test

data: data
z = 0, p-value = 1
alternative hypothesis: true mean is not equal to 102
95 percent confidence interval:
100.0122 103.9878
sample estimates:
mean of x
102
Reg. No:
Name :

Exp.No. 3 Testing of hypothesis using t - test Date:16.08.2024

Problem 3.1:
A random sample of 10 boys had the following I. Q’s: 70,120,110,101,88,83,95,98,107,100.

Do these data support the assumption of a population mean I.Q of 100? Find a reasonable range in

which most of the mean I.Q values of samples of 10 boys lie.

Programming command:

> library(BSDA)

> x=c(70,120,110,101,88,83,95,98,107,100)

> t.test(x, mu=100, conf.level=0.95)

Output:

One Sample t-test

data: x

t = -0.62034, df = 9, p-value = 0.5504


alternative hypothesis: true mean is not equal to 100
95 percent confidence interval:

86.98934 107.41066

sample estimates:
mean of x
97.2
Reg. No:
Name :

Problem 3. 2:

The marks obtained by a group of 9 regular course students and another group of 11
part-time course students in a test are given below.
Regular 56 62 63 54 60 51 67 69 58
Part-time 62 70 71 62 60 56 75 64 72 68 66

Perform a hypothesis test whether the marks obtained by regular students and part-time students differ
significantly at 5%.

Programming command:

> library (BSDA)

> regular<-c (56, 62, 63, 54, 60, 51, 67, 69, 58)

> part.time<-c (62, 70, 71, 62, 60, 56, 75, 64, 72, 68, 66)

> t.test(x=regular,y=part.time,alternative =
"two.sided",conf.level=0.95,var.equal = TRUE)

Two Sample t-test

data: regular and part.time


t = -2.2856, df = 18, p-value = 0.03462
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-11.5151239 -0.4848761

sample estimates:
mean of x mean of y
60 66
Reg. No:
Name :

Exp.No. 4 Perform one way ANOVA test Date: 02.09.2024

Problem 1:
Compute the one way analysis of variance table for the following data

A B C D

20 25 24 23

19 23 20 20

21 21 22 20

Programming command:

> table<-data.frame(b1 = c(20, 19, 21),


b2 =c(25, 23, 21),

b3 = c(24, 20, 22),

b4 = c(23, 20, 20))

> table_stacked<-stack(table[,1:4])

> anova<-aov(values~ind, data=table_stacked)

> summary(anova)

OUTPUT :

Df Sum Sq Mean Sq F value Pr(>F)


ind 3 15 5 1.667 0.25
Residuals 8 24 3
Reg. No:
Name :

Problem 2:
Compute the analysis of variance table to test the difference among the sample means at three
positions are significant.

Position 1 90 82 79 98 83 91

Position 2 105 89 93 104 89 95 86

Position 3 83 89 80 94

Programming command:

> table<-data.frame(p1 = c(90, 82, 79, 98, 83, 91, NA),

p2 = c(105, 89, 93, 104, 89, 95, 86),

p3 = c(83, 89, 80, 94, NA, NA, NA))

> table_stacked<-stack(table[,1:3])

> anova<-aov(values~ind, data=table_stacked)

> summary(anova)

OUTPUT:

Df Sum Sq Mean Sq F value Pr(>F)


ind 2 234.5 117.23 2.333 0.134
Residuals 14 703.5 50.25
Reg. No:
Name :

Exp.No. 5 Perform two way ANOVA test Date:30.09.2024

Problem 1:
Compute the two-way analysis of variance table for the following data
Salesmen
A B C D
Summer 45 40 38 37
Season
Winter 43 41 45 38
Monsoon 39 39 41 41

Programming command:

sales<-c(45,40,38,37,43,41,45,38,39,39,41,41)
season<-c("A","A","A","A","B","B","B","B","C","C","C","C")
class(season)
[1] "character"

season<-factor(season,levels = c("A","B","C","D"))
salesmen<-c("1","2","3","4","1","2","3","4","1","2","3","4")
salesmen<-factor(salesmen,levels = c("1","2","3","4"))
anova2way<-aov(sales~season+salesmen)
summary(anova2way)

OUTPUT:
Df Sum Sq Mean Sq F value Pr(>F)
season 2 8.17 4.083 0.535 0.611
salesmen 3 22.92 7.639 1.000 0.455
Residuals 6 45.83 7.639
Reg. No:
Name :

Problem 2:
Compute the two way analysis of variance table for the following data
Machine type
A B C D
W1 44 38 47 36
Workers
W2 46 40 52 43
W3 34 36 44 32
W4 43 38 46 33
W5 38 42 49 39

Programming command:

Output:
Reg. No:
Name :

Exp. No. 6 ̅ chart for the variable data


Plot 𝑿 Date: 07.10.2024
Problem 1:
̅ chart for the following 12 samples each having 4 units.
Plot 𝑿

Sample No 1 2 3 4 5 6 7 8 9 10 11 12
1 1.4 1.6 2.9 1.7 2.6 2.3 1.9 1.7 1.8 0.8 2.0
Measurements
in (mm)

1.4 2.3 1.0 2.0 3.6 2.8 2.1 1.6 2.2 2.0 1.5 2.5
1.3 2.8 1.5 0.5 2.5 3.2 2.1 1.8 1.9 1.5 2.1 1.6
1 2.7 2.0 2.2 1.8 1.5 1.7 1.4 1.2 2.0 0.9 1.8

Programming command:

library(qcc)
chartdata2<-read.table(header=FALSE,text="
+1 1.4 1.3 1
+1.4 2.3 2.8 2.7
+1.6 1 1.5 2
+2.9 2 0.5 2.2
+1.7 3.6 2.5 1.8
+2.6 2.8 3.2 1.5
+2.3 2.1 2.1 1.7
+1.9 1.6 1.8 1.4
+1.7 2.2 1.9 1.2
+1.8 2 1.5 2
+0.8 1.5 2.1 0.9
+2 2.5 1.6 1.8")
xbar_chart2<-qcc(data=chartdata2, type="xbar",sizes=4,title="X-Bar Chart",
digits=2, plot=TRUE)
OUTPUT
> library(qcc)
> chartdata2<-read.table(header=FALSE,text="
+ +10 10.2 11.3 12.4
+ +10.3 10.9 10.7 11.7
+ +11.5 10.7 11.4 12.4
+ +11 11.1 10.7 11.4
+ +11.3 11.6 11.9 12.1
+ +10.7 11.4 10.7 11
+ +11.3 11.4 11.1 10.3
+ +12.3 12.1 12.7 10.7
+ +11 13.1 13.1 12.4
+ +11.3 12.1 10.7 11.5
+ +12.5 11.9 11.8 11.3
+ +11.9 12.1 11.6 11.4
Reg. No:
Name :

+ +12.1 11.1 12.1 11.7


+ +11.9 12.1 13.1 12
+ +10.6 11.9 11.7 12.1")
> R_chart2<-qcc(data=chartdata2, type="R",sizes=4,title="R-Chart",
+ digits=4, plot=TRUE)
> library(qcc)
> chartdata2<-read.table(header=FALSE,text="
+ +1 1.4 1.3 1
+ +1.4 2.3 2.8 2.7
+ +1.6 1 1.5 2
+ +2.9 2 0.5 2.2
+ +1.7 3.6 2.5 1.8
+ +2.6 2.8 3.2 1.5
+ +2.3 2.1 2.1 1.7
+ +1.9 1.6 1.8 1.4
+ +1.7 2.2 1.9 1.2
+ +1.8 2 1.5 2
+ +0.8 1.5 2.1 0.9
+ +2 2.5 1.6 1.8")
> xbar_chart2<-qcc(data=chartdata2, type="xbar",sizes=4,title="X-Bar Chart
",
+ digits=2, plot=TRUE)
> xbar_chart2
List of 11
$ call : language qcc(data = chartdata2, type = "xbar", sizes = 4, p
lot = TRUE, title = "X-Bar Chart", digits = 2)
$ type : chr "xbar"
$ data.name : chr "chartdata2"
$ data : num [1:12, 1:4] 1 1.4 1.6 2.9 1.7 2.6 2.3 1.9 1.7 1.8 ...
..- attr(*, "dimnames")=List of 2
$ statistics: Named num [1:12] 1.18 2.3 1.52 1.9 2.4 ...
..- attr(*, "names")= chr [1:12] "1" "2" "3" "4" ...
$ sizes : num [1:12] 4 4 4 4 4 4 4 4 4 4 ...
$ center : num 1.87
$ std.dev : num 0.55
$ nsigmas : num 3
$ limits : num [1, 1:2] 1.04 2.69
..- attr(*, "dimnames")=List of 2
$ violations:List of 2
- attr(*, "class")= chr "qcc"
Reg. No:
Name :

Problem 2:

Plot 𝑋̅ chart for the following weights of 15 samples of 4 boxes drawn randomly.

Sample No 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Box 1 10.0 10.3 11.5 11.0 11.3 10.7 11.3 12.3 11.0 11.3 12.5 11.9 12.1 11.9 10.6
Box 2 10.2 10.9 10.7 11.1 11.6 11.4 11.4 12.1 13.1 12.1 11.9 12.1 11.1 12.1 11.9
Box 3 11.3 10.7 11.4 10.7 11.9 10.7 11.1 12.7 13.1 10.7 11.8 11.6 12.1 13.1 11.7

Box 4 12.4 11.7 12.4 11.4 12.1 11.0 10.3 10.7 12.4 11.5 11.3 11.4 11.7 12.0 12.1

Programming command:

library(qcc)
chartdata<-read.table(header=FALSE,text="
+10 10.2 11.3 12.4
+10.3 10.9 10.7 11.7
+11.5 10.7 11.4 12.4
+11 11.1 10.7 11.4
+11.3 11.6 11.9 12.1
+10.7 11.4 10.7 11
+11.3 11.4 11.1 10.3
+12.3 12.1 12.7 10.7
+11 13.1 13.1 12.4
+11.3 12.1 10.7 11.5
+12.5 11.9 11.8 11.3
+11.9 12.1 11.6 11.4
+12.1 11.1 12.1 11.7
+11.9 12.1 13.1 12
+10.6 11.9 11.7 12.1")
xbar_chart2<-qcc(data=chartdata, type="xbar",sizes=4,title="X-Bar Chart",
digits=4, plot=TRUE)
xbar_chart2
OUTPUT
> library(qcc)
> chartdata<-read.table(header=FALSE,text="
+ +10 10.2 11.3 12.4
+ +10.3 10.9 10.7 11.7
Reg. No:
Name :

+ +11.5 10.7 11.4 12.4


+ +11 11.1 10.7 11.4
+ +11.3 11.6 11.9 12.1
+ +10.7 11.4 10.7 11
+ +11.3 11.4 11.1 10.3
+ +12.3 12.1 12.7 10.7
+ +11 13.1 13.1 12.4
+ +11.3 12.1 10.7 11.5
+ +12.5 11.9 11.8 11.3
+ +11.9 12.1 11.6 11.4
+ +12.1 11.1 12.1 11.7
+ +11.9 12.1 13.1 12
+ +10.6 11.9 11.7 12.1")
> xbar_chart2<-qcc(data=chartdata, type="xbar",sizes=4,title="X-Bar Chart"
,
+ digits=4, plot=TRUE)
> xbar_chart2
List of 11
$ call : language qcc(data = chartdata, type = "xbar", sizes = 4, pl
ot = TRUE, title = "X-Bar Chart", digits = 4)
$ type : chr "xbar"
$ data.name : chr "chartdata"
$ data : num [1:15, 1:4] 10 10.3 11.5 11 11.3 10.7 11.3 12.3 11 11.3
...
..- attr(*, "dimnames")=List of 2
$ statistics: Named num [1:15] 11 10.9 11.5 11.1 11.7 ...
..- attr(*, "names")= chr [1:15] "1" "2" "3" "4" ...
$ sizes : num [1:15] 4 4 4 4 4 4 4 4 4 4 ...
$ center : num 11.5
$ std.dev : num 0.644
$ nsigmas : num 3
$ limits : num [1, 1:2] 10.6 12.5
..- attr(*, "dimnames")=List of 2
$ violations:List of 2
- attr(*, "class")= chr "qcc"
Reg. No:
Name :

Exp.No. 7 Plot R chart for the variable data Date:15.10.2024

Problem 1:
Plot R chart for the following weights of 15 samples of 4 boxes drawn randomly.

Sample No 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Box 1 10.0 10.3 11.5 11.0 11.3 10.7 11.3 12.3 11.0 11.3 12.5 11.9 12.1 11.9 10.6

Box 2 10.2 10.9 10.7 11.1 11.6 11.4 11.4 12.1 13.1 12.1 11.9 12.1 11.1 12.1 11.9

Box 3 11.3 10.7 11.4 10.7 11.9 10.7 11.1 12.7 13.1 10.7 11.8 11.6 12.1 13.1 11.7

Box 4 12.4 11.7 12.4 11.4 12.1 11.0 10.3 10.7 12.4 11.5 11.3 11.4 11.7 12.0 12.1

Programming command:

library(qcc)
chartdata<-read.table(header=FALSE,text="
+10 10.2 11.3 12.4
+10.3 10.9 10.7 11.7
+11.5 10.7 11.4 12.4
+11 11.1 10.7 11.4
+11.3 11.6 11.9 12.1
+10.7 11.4 10.7 11
+11.3 11.4 11.1 10.3
+12.3 12.1 12.7 10.7
+11 13.1 13.1 12.4
+11.3 12.1 10.7 11.5
+12.5 11.9 11.8 11.3
+11.9 12.1 11.6 11.4
+12.1 11.1 12.1 11.7
+11.9 12.1 13.1 12
+10.6 11.9 11.7 12.1")
R_chart<-qcc(data=chartdata, type="R",sizes=4,title="R-Chart",
digits=4, plot=TRUE)
R_chart
Reg. No:
Name :

OUTPUT
> library(qcc)
> chartdata<-read.table(header=FALSE,text="
+ +10 10.2 11.3 12.4
+ +10.3 10.9 10.7 11.7
+ +11.5 10.7 11.4 12.4
+ +11 11.1 10.7 11.4
+ +11.3 11.6 11.9 12.1
+ +10.7 11.4 10.7 11
+ +11.3 11.4 11.1 10.3
+ +12.3 12.1 12.7 10.7
+ +11 13.1 13.1 12.4
+ +11.3 12.1 10.7 11.5
+ +12.5 11.9 11.8 11.3
+ +11.9 12.1 11.6 11.4
+ +12.1 11.1 12.1 11.7
+ +11.9 12.1 13.1 12
+ +10.6 11.9 11.7 12.1")
> R_chart<-qcc(data=chartdata, type="R",sizes=4,title="R-Chart",
+ digits=4, plot=TRUE)
> R_chart
List of 11
$ call : language qcc(data = chartdata, type = "R", sizes = 4, plot
= TRUE, title = "R-Chart", digits = 4)
$ type : chr "R"
$ data.name : chr "chartdata"
$ data : num [1:15, 1:4] 10 10.3 11.5 11 11.3 10.7 11.3 12.3 11 11.3
...
..- attr(*, "dimnames")=List of 2
$ statistics: Named num [1:15] 2.4 1.4 1.7 0.7 0.8 ...
..- attr(*, "names")= chr [1:15] "1" "2" "3" "4" ...
$ sizes : num [1:15] 4 4 4 4 4 4 4 4 4 4 ...
$ center : num 1.33
$ std.dev : num 0.644
$ nsigmas : num 3
$ limits : num [1, 1:2] 0 3.03
..- attr(*, "dimnames")=List of 2
$ violations:List of 2
- attr(*, "class")= chr "qcc"
Reg. No:
Name :

Problem 2:

Plot R chart for the following 12 samples each having 4 units.

Sample No 1 2 3 4 5 6 7 8 9 10 11 12
1 1.4 1.6 2.9 1.7 2.6 2.3 1.9 1.7 1.8 0.8 2.0
Measurements
in (mm)

1.4 2.3 1.0 2.0 3.6 2.8 2.1 1.6 2.2 2.0 1.5 2.5
1.3 2.8 1.5 0.5 2.5 3.2 2.1 1.8 1.9 1.5 2.1 1.6
1 2.7 2.0 2.2 1.8 1.5 1.7 1.4 1.2 2.0 0.9 1.8

Programming command:

library(qcc)
chartdata<-read.table(header=FALSE,text="
+1 1.4 1.3 1
+1.4 2.3 2.8 2.7
+1.6 1 1.5 2
+2.9 2 0.5 2.2
+1.7 3.6 2.5 1.8
+2.6 2.8 3.2 1.5
+2.3 2.1 2.1 1.7
+1.9 1.6 1.8 1.4
+1.7 2.2 1.9 1.2
+1.8 2 1.5 2
+0.8 1.5 2.1 0.9
+2 2.5 1.6 1.8 ")
R_chart<-qcc(data=chartdata, type="R",sizes=4,title="R-Chart",
digits=2, plot=TRUE)
R_chart
OUTPUT
> library(qcc)
> chartdata<-read.table(header=FALSE,text="
+ +1 1.4 1.3 1
+ +1.4 2.3 2.8 2.7
+ +1.6 1 1.5 2
+ +2.9 2 0.5 2.2
+ +1.7 3.6 2.5 1.8
+ +2.6 2.8 3.2 1.5
+ +2.3 2.1 2.1 1.7
+ +1.9 1.6 1.8 1.4
+ +1.7 2.2 1.9 1.2
+ +1.8 2 1.5 2
+ +0.8 1.5 2.1 0.9
Reg. No:
Name :

+ +2 2.5 1.6 1.8 ")


> R_chart<-qcc(data=chartdata, type="R",sizes=4,title="R-Chart",
+ digits=2, plot=TRUE)
> R_chart
List of 11
$ call : language qcc(data = chartdata, type = "R", sizes = 4, plot
= TRUE, title = "R-Chart", digits = 2)
$ type : chr "R"
$ data.name : chr "chartdata"
$ data : num [1:12, 1:4] 1 1.4 1.6 2.9 1.7 2.6 2.3 1.9 1.7 1.8 ...
..- attr(*, "dimnames")=List of 2
$ statistics: Named num [1:12] 0.4 1.4 1 2.4 1.9 1.7 0.6 0.5 1 0.5 ...
..- attr(*, "names")= chr [1:12] "1" "2" "3" "4" ...
$ sizes : num [1:12] 4 4 4 4 4 4 4 4 4 4 ...
$ center : num 1.13
$ std.dev : num 0.55
$ nsigmas : num 3
$ limits : num [1, 1:2] 0 2.59
..- attr(*, "dimnames")=List of 2
$ violations:List of 2
- attr(*, "class")= chr "qcc"
Reg. No:
Name :

Exp.No. 8 Compute the null space of a linear transformation Date:21.10.2024

Problem 1:

Let 𝑇: 𝑇2 → 𝑇3 be defined by (𝑇, 𝑇) = (2𝑇 − 𝑇, 3𝑇 + 4𝑇, 𝑇). Compute the null space of
𝟐 −𝟏
the matrix 𝑻 = [𝟑 𝟒]
𝟏 𝟎

Programming command:

library(pracma)

T<-matrix(c(2,-1,3,4,1,0),nrow=3,ncol=2,byrow=TRUE)

N<-nullspace(T)

OUTPUT
> library(pracma)
> T<-matrix(c(2,-1,3,4,1,0),nrow=3,ncol=2,byrow=TRUE)
> T
[,1] [,2]
[1,] 2 -1
[2,] 3 4
[3,] 1 0
> N<-nullspace(T)
> N
NULL
Reg. No:
Name :

Problem 2:

Let 𝑇: 𝑅3 → 𝑅3 be defined by (𝑥, 𝑦, 𝑧) = (𝑎, 𝑏, 0). Compute the null space of the matrix 𝑇 =
1 0 0
[0 1 0]
0 0 0

Programming command:

library(pracma)

T<-matrix(c(1,0,0,0,1,0,0,0,0),nrow=3,ncol=3,byrow=TRUE)

N<-nullspace(T)

OUTPUT

> library(pracma)
> T<-matrix(c(1,0,0,0,1,0,0,0,0),nrow=3,ncol=3,byrow=TRUE)
> T
[,1] [,2] [,3]
[1,] 1 0 0
[2,] 0 1 0
[3,] 0 0 0
> N<-nullspace(T)
> N
[,1]
[1,] 0
[2,] 0
[3,] 1
Reg. No:
Name :

Exp.No. 9 Eigenvalue and eigenvector of linear transformation Date:25.10.2024


Problem 1:
3 −4 4
Compute the eigenvalue and eigen vector of the linear transformation 𝑇 = [1 −2 4]
1 −1 3

Programming command:

library(pracma)

A<-matrix(c(3,-4,4,1,-2,4,1,-1,3),nrow=3,ncol=3)

Eigen.Values.Vectors<-eigen(A)

Eigen.Values.Vectors

OUTPUT
> library(pracma)
> A<-matrix(c(3,-4,4,1,-2,4,1,-1,3),nrow=3,ncol=3)
> A
[,1] [,2] [,3]
[1,] 3 1 1
[2,] -4 -2 -1
[3,] 4 4 3
> Eigen.Values.Vectors<-eigen(A)
> Eigen.Values.Vectors
eigen() decomposition
$values
[1] 3 2 -1

$vectors
[,1] [,2] [,3]
[1,] 0.5773503 -7.071068e-01 -6.409876e-17
[2,] -0.5773503 7.071068e-01 -7.071068e-01
[3,] 0.5773503 -5.551115e-17 7.071068e-01
Reg. No:
Name :

Problem 2:
2 2 −7
Compute the eigenvalue and eigen vector of the linear transformation 𝑇 = [2 1 2 ]
0 1 −3

Programming command:

library(pracma)

A<-matrix (c (2,2, -7,2,1,2,0,1, -3), nrow=3, ncol=3)

Eigen.Values.Vectors<-eigen(A)

Eigen.Values.Vectors

OUTPUT

> library(pracma)
> A<-matrix(c(2,2,-7,2,1,2,0,1,-3),nrow=3,ncol=3)
> A
[,1] [,2] [,3]
[1,] 2 2 0
[2,] 2 1 1
[3,] -7 2 -3
> Eigen.Values.Vectors<-eigen(A)
> Eigen.Values.Vectors
eigen() decomposition
$values
[1] -4 3 1
$vectors
[,1] [,2] [,3]
[1,] 0.07474351 -0.6666667 -0.4364358
[2,] -0.22423053 -0.3333333 0.2182179
[3,] 0.97166562 0.6666667 0.8728716

You might also like