SlideShare a Scribd company logo
5/19/2020 Experiment-10.ipynb - Colaboratory
https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 1/6
LAB EXPERIMENT NO. 10 R Programming Language - Asst. Prof. Ashwini Mathur(SET-JAIN)
R Programming Language Lab
1. Use R-function matrix to create the matrices called A and B:
2. Take the inverse of A and the transpose of A.
3. Multiply A with B.
4. Estimate the eigenvalues and eigenvectors of A.
5. For a matrix A, x is an eigenvector, and λ the eigenvalue of a matrix A, if A • x = λ • x. Test it!
6. Create a new matrix, T, which equals P, except for the rst row, where the elements are 0.
7. Now estimate N= (I-T)-1, where I is the identity matrix.
8. Find the root of the equation f(x) = cos(2x)^3 in the interval [0, 8]. And draw the function curve.
Self work ......
9. Solve the equations 1000 = y ∗ (3 + x) ∗ (1 + y)4 for y and with x varying over the range from 1 to
Question:1. Use R-function matrix to create the matrices called A and B.
A
matrix:
3 × 3 of
type
dbl
1 1 -2
-1 2 1
0 1 -1
A
matrix:
3 × 3 of
type
dbl
6 2 0
8 -2 2
4 2 -2
A <- matrix( c(1,1,-2,-1,2,1,0,1,-1), nrow=3, byrow=TRUE)
B <- matrix( c(6, 2, 0,8,-2, 2,4, 2,-2), nrow=3, byrow=TRUE)
A #print matrix A
B #Print matrix B
5/19/2020 Experiment-10.ipynb - Colaboratory
https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 2/6
One of the most widely used kinds of matrix decomposition is called eigendecomposition, in which w
eigenvectors and eigenvalues.
Question:2.Take the inverse of A and the transpose of A.
Need to install the packgae and load the library for inverse of the matrix
Installing package into 'C:/Users/ashwinmathur/Documents/R/win-library/3.6'
(as 'lib' is unspecified)
Warning message:
"package 'matlib' is in use and will not be installed"
install.packages("matlib")
library(matlib)
det(A) != 0, so inverse exists Only non-singular matrices have an inverse
-2
-2
det(A) #Determinant of A
det(t(A))
A matrix: 3 ×
3 of type dbl
1.5 0.5 -2.5
0.5 0.5 -0.5
0.5 0.5 -1.5
AI = inv(A)
AI
A matrix: 3 ×
3 of type dbl
1.5 0.5 0.5
0.5 0.5 0.5
-2.5 -0.5 -1.5
transpose = t(AI) #Transpose of Matrix
transpose
2 · 1 · -1
e = eigen(A)
e$values
Question:3. Multiply A with B
5/19/2020 Experiment-10.ipynb - Colaboratory
https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 3/6
A
matrix:
3 × 3 of
type
dbl
6 2 0
-8 -4 2
0 2 2
Mul = A * B
Mul
Question:4.Estimate the eigenvalues and eigenvectors of A.
eigen() decomposition
$values
[1] 2 1 -1
$vectors
[,1] [,2] [,3]
[1,] 0.3015113 -0.8017837 7.071068e-01
[2,] 0.9045340 -0.5345225 -1.922963e-16
[3,] 0.3015113 -0.2672612 7.071068e-01
ev = eigen(A) #Eigen value of the matrix A
ev
x = ev$values #assign X to eigen values
lamda = ev$vectors #assign lamda to eigen vectors
Question:5. For a matrix A, x is an eigenvector, and λ the eigenvalue of a matrix A, if A • x = λ • x. Test
A matrix: 3 × 3 of type
lgl
FALSE FALSE FALSE
FALSE FALSE FALSE
FALSE FALSE FALSE
A*x == lamda*x
I <- matrix( c(1, 0, 0,0,1, 0,0, 0,1), nrow=3, byrow=TRUE)
A - (lamda*I)
5/19/2020 Experiment-10.ipynb - Colaboratory
https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 4/6
A matrix: 3 × 3 of type dbl
0.6984887 1.000000 -2.000000
-1.0000000 2.534522 1.000000
0.0000000 1.000000 -1.707107
A matrix: 3 × 3 of type dbl
0.6030227 -1.6035675 1.414214e+00
0.9045340 -0.5345225 -1.922963e-16
-0.3015113 0.2672612 -7.071068e-01
lamda*x
A
matrix:
3 × 3 of
type dbl
2 2 -4
-1 2 1
0 -1 1
A*x
Question:6. Create a new matrix, T, which equals P, except for the rst row, where the elements are 0.
T = matrix( c(0,0,0,-1,2,1,0,1,-1), nrow=3, byrow=TRUE)
P = matrix( c(1,1,-2,-1,2,1,0,1,-1), nrow=3, byrow=TRUE)
Question:7. Now estimate N= (I-T)-1, where I is the identity matrix.
A
matrix:
3 × 3
of type
dbl
1 0 0
0 1 0
0 0 1
I = matrix( c(1,0,0,0,1,0,0,0,1), nrow=3, byrow=TRUE)
I
Question:8. Now estimate N= (I-T)-1, where I is the identity matrix.
N = (I - T) - 1
N
5/19/2020 Experiment-10.ipynb - Colaboratory
https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 5/6
A
matrix:
3 × 3 of
type dbl
0 -1 -1
0 -2 -2
-1 -2 1
Question:9. Find the root of the equation f(x) = cos(2x)^3 in the interval [0, 8]. And draw the function c
fun = function (x){ cos(2*x)^3}
curve(fun(x), 0, 8)
abline(h = 0, lty = 3)
uni <- uniroot(fun, c(0, 8))$root
points(uni, 0, pch = 16, cex = 2)
5/19/2020 Experiment-10.ipynb - Colaboratory
https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 6/6

More Related Content

What's hot

Excel macro for integration of a function
Excel macro for integration of a functionExcel macro for integration of a function
Excel macro for integration of a function
Upendra Lele
 
Arithmetic operators
Arithmetic operatorsArithmetic operators
Arithmetic operators
sidneyodingo
 
The TensorFlow dance craze
The TensorFlow dance crazeThe TensorFlow dance craze
The TensorFlow dance craze
Gabriel Hamilton
 
Functions And Graphs Part 1
Functions And Graphs Part 1Functions And Graphs Part 1
Functions And Graphs Part 1
Timmathy
 
simple linear regression
simple linear regressionsimple linear regression
simple linear regression
Akhilesh Joshi
 
U3.stack queue
U3.stack queueU3.stack queue
U3.stack queue
Ssankett Negi
 
decision tree regression
decision tree regressiondecision tree regression
decision tree regression
Akhilesh Joshi
 
The matplotlib Library
The matplotlib LibraryThe matplotlib Library
The matplotlib Library
Haim Michael
 
Matplotlib
MatplotlibMatplotlib
Matplotlib
Amir Shokri
 
random forest regression
random forest regressionrandom forest regression
random forest regression
Akhilesh Joshi
 
this in c#
this in c#this in c#
this in c#
Sireesh K
 
polynomial linear regression
polynomial linear regressionpolynomial linear regression
polynomial linear regression
Akhilesh Joshi
 

What's hot (12)

Excel macro for integration of a function
Excel macro for integration of a functionExcel macro for integration of a function
Excel macro for integration of a function
 
Arithmetic operators
Arithmetic operatorsArithmetic operators
Arithmetic operators
 
The TensorFlow dance craze
The TensorFlow dance crazeThe TensorFlow dance craze
The TensorFlow dance craze
 
Functions And Graphs Part 1
Functions And Graphs Part 1Functions And Graphs Part 1
Functions And Graphs Part 1
 
simple linear regression
simple linear regressionsimple linear regression
simple linear regression
 
U3.stack queue
U3.stack queueU3.stack queue
U3.stack queue
 
decision tree regression
decision tree regressiondecision tree regression
decision tree regression
 
The matplotlib Library
The matplotlib LibraryThe matplotlib Library
The matplotlib Library
 
Matplotlib
MatplotlibMatplotlib
Matplotlib
 
random forest regression
random forest regressionrandom forest regression
random forest regression
 
this in c#
this in c#this in c#
this in c#
 
polynomial linear regression
polynomial linear regressionpolynomial linear regression
polynomial linear regression
 

Similar to Play with matrix in r

Machine Learning Guide maXbox Starter62
Machine Learning Guide maXbox Starter62Machine Learning Guide maXbox Starter62
Machine Learning Guide maXbox Starter62
Max Kleiner
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learning
Max Kleiner
 
Introduction to PyTorch
Introduction to PyTorchIntroduction to PyTorch
Introduction to PyTorch
Jun Young Park
 
Ds lab manual by s.k.rath
Ds lab manual by s.k.rathDs lab manual by s.k.rath
Ds lab manual by s.k.rath
SANTOSH RATH
 
Lab 2: Classification and Regression Prediction Models, training and testing ...
Lab 2: Classification and Regression Prediction Models, training and testing ...Lab 2: Classification and Regression Prediction Models, training and testing ...
Lab 2: Classification and Regression Prediction Models, training and testing ...
Yao Yao
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VII
Max Kleiner
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
Max Kleiner
 
20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdf20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdf
MariaKhan905189
 
Two methods for optimising cognitive model parameters
Two methods for optimising cognitive model parametersTwo methods for optimising cognitive model parameters
Two methods for optimising cognitive model parameters
University of Huddersfield
 
Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPy
Kimikazu Kato
 
Introduction of Feature Hashing
Introduction of Feature HashingIntroduction of Feature Hashing
Introduction of Feature Hashing
Wush Wu
 
Investigación de operaciones 026 programación lineal Solución Simplex con R S...
Investigación de operaciones 026 programación lineal Solución Simplex con R S...Investigación de operaciones 026 programación lineal Solución Simplex con R S...
Investigación de operaciones 026 programación lineal Solución Simplex con R S...
Jorge Pablo Rivas
 
Anomaly Detection with Apache Spark
Anomaly Detection with Apache SparkAnomaly Detection with Apache Spark
Anomaly Detection with Apache Spark
Cloudera, Inc.
 
Matlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingMatlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processing
Dr. Manjunatha. P
 
Artificial Neural Network
Artificial Neural NetworkArtificial Neural Network
Artificial Neural Network
Dessy Amirudin
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
raghav415187
 
Matlab and Python: Basic Operations
Matlab and Python: Basic OperationsMatlab and Python: Basic Operations
Matlab and Python: Basic Operations
Wai Nwe Tun
 
Xgboost
XgboostXgboost
Machine Learning - Simple Linear Regression
Machine Learning - Simple Linear RegressionMachine Learning - Simple Linear Regression
Machine Learning - Simple Linear Regression
Siddharth Shrivastava
 
Lrz kurse: r as superglue
Lrz kurse: r as superglueLrz kurse: r as superglue
Lrz kurse: r as superglue
Ferdinand Jamitzky
 

Similar to Play with matrix in r (20)

Machine Learning Guide maXbox Starter62
Machine Learning Guide maXbox Starter62Machine Learning Guide maXbox Starter62
Machine Learning Guide maXbox Starter62
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learning
 
Introduction to PyTorch
Introduction to PyTorchIntroduction to PyTorch
Introduction to PyTorch
 
Ds lab manual by s.k.rath
Ds lab manual by s.k.rathDs lab manual by s.k.rath
Ds lab manual by s.k.rath
 
Lab 2: Classification and Regression Prediction Models, training and testing ...
Lab 2: Classification and Regression Prediction Models, training and testing ...Lab 2: Classification and Regression Prediction Models, training and testing ...
Lab 2: Classification and Regression Prediction Models, training and testing ...
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VII
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
 
20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdf20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdf
 
Two methods for optimising cognitive model parameters
Two methods for optimising cognitive model parametersTwo methods for optimising cognitive model parameters
Two methods for optimising cognitive model parameters
 
Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPy
 
Introduction of Feature Hashing
Introduction of Feature HashingIntroduction of Feature Hashing
Introduction of Feature Hashing
 
Investigación de operaciones 026 programación lineal Solución Simplex con R S...
Investigación de operaciones 026 programación lineal Solución Simplex con R S...Investigación de operaciones 026 programación lineal Solución Simplex con R S...
Investigación de operaciones 026 programación lineal Solución Simplex con R S...
 
Anomaly Detection with Apache Spark
Anomaly Detection with Apache SparkAnomaly Detection with Apache Spark
Anomaly Detection with Apache Spark
 
Matlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processingMatlab for beginners, Introduction, signal processing
Matlab for beginners, Introduction, signal processing
 
Artificial Neural Network
Artificial Neural NetworkArtificial Neural Network
Artificial Neural Network
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
Matlab and Python: Basic Operations
Matlab and Python: Basic OperationsMatlab and Python: Basic Operations
Matlab and Python: Basic Operations
 
Xgboost
XgboostXgboost
Xgboost
 
Machine Learning - Simple Linear Regression
Machine Learning - Simple Linear RegressionMachine Learning - Simple Linear Regression
Machine Learning - Simple Linear Regression
 
Lrz kurse: r as superglue
Lrz kurse: r as superglueLrz kurse: r as superglue
Lrz kurse: r as superglue
 

More from Ashwini Mathur

S3 classes and s4 classes
S3 classes and s4 classesS3 classes and s4 classes
S3 classes and s4 classes
Ashwini Mathur
 
Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r
Ashwini Mathur
 
Rpy2 demonstration
Rpy2 demonstrationRpy2 demonstration
Rpy2 demonstration
Ashwini Mathur
 
Rpy package
Rpy packageRpy package
Rpy package
Ashwini Mathur
 
R programming lab 3 - jupyter notebook
R programming lab   3 - jupyter notebookR programming lab   3 - jupyter notebook
R programming lab 3 - jupyter notebook
Ashwini Mathur
 
R programming lab 2 - jupyter notebook
R programming lab   2 - jupyter notebookR programming lab   2 - jupyter notebook
R programming lab 2 - jupyter notebook
Ashwini Mathur
 
R for statistics session 1
R for statistics session 1R for statistics session 1
R for statistics session 1
Ashwini Mathur
 
R for statistics 2
R for statistics 2R for statistics 2
R for statistics 2
Ashwini Mathur
 
Object oriented programming in r
Object oriented programming in r Object oriented programming in r
Object oriented programming in r
Ashwini Mathur
 
Linear programming optimization in r
Linear programming optimization in r Linear programming optimization in r
Linear programming optimization in r
Ashwini Mathur
 
Introduction to python along with the comparitive analysis with r
Introduction to python   along with the comparitive analysis with r Introduction to python   along with the comparitive analysis with r
Introduction to python along with the comparitive analysis with r
Ashwini Mathur
 
Example 2 summerization notes for descriptive statistics using r
Example   2    summerization notes for descriptive statistics using r Example   2    summerization notes for descriptive statistics using r
Example 2 summerization notes for descriptive statistics using r
Ashwini Mathur
 
Descriptive statistics assignment
Descriptive statistics assignment Descriptive statistics assignment
Descriptive statistics assignment
Ashwini Mathur
 
Descriptive analytics in r programming language
Descriptive analytics in r programming languageDescriptive analytics in r programming language
Descriptive analytics in r programming language
Ashwini Mathur
 
Data analysis for covid 19
Data analysis for covid 19Data analysis for covid 19
Data analysis for covid 19
Ashwini Mathur
 
Correlation and linear regression
Correlation and linear regression Correlation and linear regression
Correlation and linear regression
Ashwini Mathur
 
Calling c functions from r programming unit 5
Calling c functions from r programming    unit 5Calling c functions from r programming    unit 5
Calling c functions from r programming unit 5
Ashwini Mathur
 
Anova (analysis of variance) test
Anova (analysis of variance) test Anova (analysis of variance) test
Anova (analysis of variance) test
Ashwini Mathur
 

More from Ashwini Mathur (18)

S3 classes and s4 classes
S3 classes and s4 classesS3 classes and s4 classes
S3 classes and s4 classes
 
Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r Summerization notes for descriptive statistics using r
Summerization notes for descriptive statistics using r
 
Rpy2 demonstration
Rpy2 demonstrationRpy2 demonstration
Rpy2 demonstration
 
Rpy package
Rpy packageRpy package
Rpy package
 
R programming lab 3 - jupyter notebook
R programming lab   3 - jupyter notebookR programming lab   3 - jupyter notebook
R programming lab 3 - jupyter notebook
 
R programming lab 2 - jupyter notebook
R programming lab   2 - jupyter notebookR programming lab   2 - jupyter notebook
R programming lab 2 - jupyter notebook
 
R for statistics session 1
R for statistics session 1R for statistics session 1
R for statistics session 1
 
R for statistics 2
R for statistics 2R for statistics 2
R for statistics 2
 
Object oriented programming in r
Object oriented programming in r Object oriented programming in r
Object oriented programming in r
 
Linear programming optimization in r
Linear programming optimization in r Linear programming optimization in r
Linear programming optimization in r
 
Introduction to python along with the comparitive analysis with r
Introduction to python   along with the comparitive analysis with r Introduction to python   along with the comparitive analysis with r
Introduction to python along with the comparitive analysis with r
 
Example 2 summerization notes for descriptive statistics using r
Example   2    summerization notes for descriptive statistics using r Example   2    summerization notes for descriptive statistics using r
Example 2 summerization notes for descriptive statistics using r
 
Descriptive statistics assignment
Descriptive statistics assignment Descriptive statistics assignment
Descriptive statistics assignment
 
Descriptive analytics in r programming language
Descriptive analytics in r programming languageDescriptive analytics in r programming language
Descriptive analytics in r programming language
 
Data analysis for covid 19
Data analysis for covid 19Data analysis for covid 19
Data analysis for covid 19
 
Correlation and linear regression
Correlation and linear regression Correlation and linear regression
Correlation and linear regression
 
Calling c functions from r programming unit 5
Calling c functions from r programming    unit 5Calling c functions from r programming    unit 5
Calling c functions from r programming unit 5
 
Anova (analysis of variance) test
Anova (analysis of variance) test Anova (analysis of variance) test
Anova (analysis of variance) test
 

Recently uploaded

一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
nyvan3
 
saps4hanaandsapanalyticswheretodowhat1565272000538.pdf
saps4hanaandsapanalyticswheretodowhat1565272000538.pdfsaps4hanaandsapanalyticswheretodowhat1565272000538.pdf
saps4hanaandsapanalyticswheretodowhat1565272000538.pdf
newdirectionconsulta
 
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
eudsoh
 
Salesforce AI + Data Community Tour Slides - Canarias
Salesforce AI + Data Community Tour Slides - CanariasSalesforce AI + Data Community Tour Slides - Canarias
Salesforce AI + Data Community Tour Slides - Canarias
davidpietrzykowski1
 
Senior Software Profiles Backend Sample - Sheet1.pdf
Senior Software Profiles  Backend Sample - Sheet1.pdfSenior Software Profiles  Backend Sample - Sheet1.pdf
Senior Software Profiles Backend Sample - Sheet1.pdf
Vineet
 
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
hqfek
 
Call Girls Hyderabad (india) ☎️ +91-7426014248 Hyderabad Call Girl
Call Girls Hyderabad  (india) ☎️ +91-7426014248 Hyderabad  Call GirlCall Girls Hyderabad  (india) ☎️ +91-7426014248 Hyderabad  Call Girl
Call Girls Hyderabad (india) ☎️ +91-7426014248 Hyderabad Call Girl
sapna sharmap11
 
CAP Excel Formulas & Functions July - Copy (4).pdf
CAP Excel Formulas & Functions July - Copy (4).pdfCAP Excel Formulas & Functions July - Copy (4).pdf
CAP Excel Formulas & Functions July - Copy (4).pdf
frp60658
 
Template xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptxTemplate xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptx
TeukuEriSyahputra
 
Data Scientist Machine Learning Profiles .pdf
Data Scientist Machine Learning  Profiles .pdfData Scientist Machine Learning  Profiles .pdf
Data Scientist Machine Learning Profiles .pdf
Vineet
 
Digital Marketing Performance Marketing Sample .pdf
Digital Marketing Performance Marketing  Sample .pdfDigital Marketing Performance Marketing  Sample .pdf
Digital Marketing Performance Marketing Sample .pdf
Vineet
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
Vietnam Cotton & Spinning Association
 
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdfNamma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
22ad0301
 
06-18-2024-Princeton Meetup-Introduction to Milvus
06-18-2024-Princeton Meetup-Introduction to Milvus06-18-2024-Princeton Meetup-Introduction to Milvus
06-18-2024-Princeton Meetup-Introduction to Milvus
Timothy Spann
 
一比一原版南昆士兰大学毕业证如何办理
一比一原版南昆士兰大学毕业证如何办理一比一原版南昆士兰大学毕业证如何办理
一比一原版南昆士兰大学毕业证如何办理
ugydym
 
一比一原版莱斯大学毕业证(rice毕业证)如何办理
一比一原版莱斯大学毕业证(rice毕业证)如何办理一比一原版莱斯大学毕业证(rice毕业证)如何办理
一比一原版莱斯大学毕业证(rice毕业证)如何办理
zsafxbf
 
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
aguty
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
ytypuem
 
Senior Engineering Sample EM DOE - Sheet1.pdf
Senior Engineering Sample EM DOE  - Sheet1.pdfSenior Engineering Sample EM DOE  - Sheet1.pdf
Senior Engineering Sample EM DOE - Sheet1.pdf
Vineet
 
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance PaymentCall Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
prijesh mathew
 

Recently uploaded (20)

一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
一比一原版英国赫特福德大学毕业证(hertfordshire毕业证书)如何办理
 
saps4hanaandsapanalyticswheretodowhat1565272000538.pdf
saps4hanaandsapanalyticswheretodowhat1565272000538.pdfsaps4hanaandsapanalyticswheretodowhat1565272000538.pdf
saps4hanaandsapanalyticswheretodowhat1565272000538.pdf
 
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
 
Salesforce AI + Data Community Tour Slides - Canarias
Salesforce AI + Data Community Tour Slides - CanariasSalesforce AI + Data Community Tour Slides - Canarias
Salesforce AI + Data Community Tour Slides - Canarias
 
Senior Software Profiles Backend Sample - Sheet1.pdf
Senior Software Profiles  Backend Sample - Sheet1.pdfSenior Software Profiles  Backend Sample - Sheet1.pdf
Senior Software Profiles Backend Sample - Sheet1.pdf
 
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
 
Call Girls Hyderabad (india) ☎️ +91-7426014248 Hyderabad Call Girl
Call Girls Hyderabad  (india) ☎️ +91-7426014248 Hyderabad  Call GirlCall Girls Hyderabad  (india) ☎️ +91-7426014248 Hyderabad  Call Girl
Call Girls Hyderabad (india) ☎️ +91-7426014248 Hyderabad Call Girl
 
CAP Excel Formulas & Functions July - Copy (4).pdf
CAP Excel Formulas & Functions July - Copy (4).pdfCAP Excel Formulas & Functions July - Copy (4).pdf
CAP Excel Formulas & Functions July - Copy (4).pdf
 
Template xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptxTemplate xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptx
 
Data Scientist Machine Learning Profiles .pdf
Data Scientist Machine Learning  Profiles .pdfData Scientist Machine Learning  Profiles .pdf
Data Scientist Machine Learning Profiles .pdf
 
Digital Marketing Performance Marketing Sample .pdf
Digital Marketing Performance Marketing  Sample .pdfDigital Marketing Performance Marketing  Sample .pdf
Digital Marketing Performance Marketing Sample .pdf
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
 
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdfNamma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
 
06-18-2024-Princeton Meetup-Introduction to Milvus
06-18-2024-Princeton Meetup-Introduction to Milvus06-18-2024-Princeton Meetup-Introduction to Milvus
06-18-2024-Princeton Meetup-Introduction to Milvus
 
一比一原版南昆士兰大学毕业证如何办理
一比一原版南昆士兰大学毕业证如何办理一比一原版南昆士兰大学毕业证如何办理
一比一原版南昆士兰大学毕业证如何办理
 
一比一原版莱斯大学毕业证(rice毕业证)如何办理
一比一原版莱斯大学毕业证(rice毕业证)如何办理一比一原版莱斯大学毕业证(rice毕业证)如何办理
一比一原版莱斯大学毕业证(rice毕业证)如何办理
 
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
 
Senior Engineering Sample EM DOE - Sheet1.pdf
Senior Engineering Sample EM DOE  - Sheet1.pdfSenior Engineering Sample EM DOE  - Sheet1.pdf
Senior Engineering Sample EM DOE - Sheet1.pdf
 
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance PaymentCall Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
Call Girls Hyderabad ❤️ 7339748667 ❤️ With No Advance Payment
 

Play with matrix in r

  • 1. 5/19/2020 Experiment-10.ipynb - Colaboratory https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 1/6 LAB EXPERIMENT NO. 10 R Programming Language - Asst. Prof. Ashwini Mathur(SET-JAIN) R Programming Language Lab 1. Use R-function matrix to create the matrices called A and B: 2. Take the inverse of A and the transpose of A. 3. Multiply A with B. 4. Estimate the eigenvalues and eigenvectors of A. 5. For a matrix A, x is an eigenvector, and λ the eigenvalue of a matrix A, if A • x = λ • x. Test it! 6. Create a new matrix, T, which equals P, except for the rst row, where the elements are 0. 7. Now estimate N= (I-T)-1, where I is the identity matrix. 8. Find the root of the equation f(x) = cos(2x)^3 in the interval [0, 8]. And draw the function curve. Self work ...... 9. Solve the equations 1000 = y ∗ (3 + x) ∗ (1 + y)4 for y and with x varying over the range from 1 to Question:1. Use R-function matrix to create the matrices called A and B. A matrix: 3 × 3 of type dbl 1 1 -2 -1 2 1 0 1 -1 A matrix: 3 × 3 of type dbl 6 2 0 8 -2 2 4 2 -2 A <- matrix( c(1,1,-2,-1,2,1,0,1,-1), nrow=3, byrow=TRUE) B <- matrix( c(6, 2, 0,8,-2, 2,4, 2,-2), nrow=3, byrow=TRUE) A #print matrix A B #Print matrix B
  • 2. 5/19/2020 Experiment-10.ipynb - Colaboratory https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 2/6 One of the most widely used kinds of matrix decomposition is called eigendecomposition, in which w eigenvectors and eigenvalues. Question:2.Take the inverse of A and the transpose of A. Need to install the packgae and load the library for inverse of the matrix Installing package into 'C:/Users/ashwinmathur/Documents/R/win-library/3.6' (as 'lib' is unspecified) Warning message: "package 'matlib' is in use and will not be installed" install.packages("matlib") library(matlib) det(A) != 0, so inverse exists Only non-singular matrices have an inverse -2 -2 det(A) #Determinant of A det(t(A)) A matrix: 3 × 3 of type dbl 1.5 0.5 -2.5 0.5 0.5 -0.5 0.5 0.5 -1.5 AI = inv(A) AI A matrix: 3 × 3 of type dbl 1.5 0.5 0.5 0.5 0.5 0.5 -2.5 -0.5 -1.5 transpose = t(AI) #Transpose of Matrix transpose 2 · 1 · -1 e = eigen(A) e$values Question:3. Multiply A with B
  • 3. 5/19/2020 Experiment-10.ipynb - Colaboratory https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 3/6 A matrix: 3 × 3 of type dbl 6 2 0 -8 -4 2 0 2 2 Mul = A * B Mul Question:4.Estimate the eigenvalues and eigenvectors of A. eigen() decomposition $values [1] 2 1 -1 $vectors [,1] [,2] [,3] [1,] 0.3015113 -0.8017837 7.071068e-01 [2,] 0.9045340 -0.5345225 -1.922963e-16 [3,] 0.3015113 -0.2672612 7.071068e-01 ev = eigen(A) #Eigen value of the matrix A ev x = ev$values #assign X to eigen values lamda = ev$vectors #assign lamda to eigen vectors Question:5. For a matrix A, x is an eigenvector, and λ the eigenvalue of a matrix A, if A • x = λ • x. Test A matrix: 3 × 3 of type lgl FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE A*x == lamda*x I <- matrix( c(1, 0, 0,0,1, 0,0, 0,1), nrow=3, byrow=TRUE) A - (lamda*I)
  • 4. 5/19/2020 Experiment-10.ipynb - Colaboratory https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 4/6 A matrix: 3 × 3 of type dbl 0.6984887 1.000000 -2.000000 -1.0000000 2.534522 1.000000 0.0000000 1.000000 -1.707107 A matrix: 3 × 3 of type dbl 0.6030227 -1.6035675 1.414214e+00 0.9045340 -0.5345225 -1.922963e-16 -0.3015113 0.2672612 -7.071068e-01 lamda*x A matrix: 3 × 3 of type dbl 2 2 -4 -1 2 1 0 -1 1 A*x Question:6. Create a new matrix, T, which equals P, except for the rst row, where the elements are 0. T = matrix( c(0,0,0,-1,2,1,0,1,-1), nrow=3, byrow=TRUE) P = matrix( c(1,1,-2,-1,2,1,0,1,-1), nrow=3, byrow=TRUE) Question:7. Now estimate N= (I-T)-1, where I is the identity matrix. A matrix: 3 × 3 of type dbl 1 0 0 0 1 0 0 0 1 I = matrix( c(1,0,0,0,1,0,0,0,1), nrow=3, byrow=TRUE) I Question:8. Now estimate N= (I-T)-1, where I is the identity matrix. N = (I - T) - 1 N
  • 5. 5/19/2020 Experiment-10.ipynb - Colaboratory https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 5/6 A matrix: 3 × 3 of type dbl 0 -1 -1 0 -2 -2 -1 -2 1 Question:9. Find the root of the equation f(x) = cos(2x)^3 in the interval [0, 8]. And draw the function c fun = function (x){ cos(2*x)^3} curve(fun(x), 0, 8) abline(h = 0, lty = 3) uni <- uniroot(fun, c(0, 8))$root points(uni, 0, pch = 16, cex = 2)
  • 6. 5/19/2020 Experiment-10.ipynb - Colaboratory https://colab.research.google.com/drive/16ZCdJUKdK1GEwE-u8MACHIOTH_Irp1ft?authuser=3#printMode=true 6/6