#================================================================== # R script to: (a) Solve a system of k equations in k unknowns, # represented by the matrix equation Ax = c, where A is a k X k # matrix c is a k X 1 column vector of constants, and x is a k X 1 # column vector of unknown values. (b) Calculate the inverse of the # matrix A, if an inverse exists. #================================================================== #------------------------------------------------------------------ # Enter rows of matrix A and elements of vector c here. #------------------------------------------------------------------ A=rbind(c(-1,4),c(3,6)) c=c(8,30) #------------------------------------------------------------------ # (a) Solve system of linear equations. #------------------------------------------------------------------ x=solve(A,c) #------------------------------------------------------------------ # (b) Invert matrix A. #------------------------------------------------------------------ Ainv=solve(A) #------------------------------------------------------------------ # Print results to the console. #------------------------------------------------------------------ Ainv Ainv%*%A