Assignment 1: Problem Set 2

Set up a system of equations with 3 variables and 3 constraints and solve for x. Please write a function in Octave that will take two variables (matrix A & constraint vector b) and solve using elimination. Your function should produce the right answer for the system of equations for any 3-variable, 3-equation system. You don’t have to worry about degenerate cases and can safely assume that the function will only be tested with a system of equations that has a solution. Please note that you do have to worry about zero pivots, though. Please test it with the system below (given) and it should produce a solution x = [-1.55, -0.33, 0.95].

A <- matrix(c(1, 2, -1, 1, -1, -2, 3, 5, 4), nrow=3, ncol=3)
A
##      [,1] [,2] [,3]
## [1,]    1    1    3
## [2,]    2   -1    5
## [3,]   -1   -2    4
b <- matrix(c(1, 2, 6), nrow=3, ncol=1)
b
##      [,1]
## [1,]    1
## [2,]    2
## [3,]    6
solve(A,b)
##            [,1]
## [1,] -1.5454545
## [2,] -0.3181818
## [3,]  0.9545455