C17 † Page 42

Book: Beezer: A First Course in Linear Algebra

Exercise

Find all solutions to the system of linear equations. Use your favorite computing device to row-reduce the augmented matrices for the systems, and write the solutions as a set, using correct set notation.

\(-x_1 + 5x_2 = -8\)

\(-2x_1 + 5x_2 + 5x_3 + 2x_4 = 9\)

\(-3x_1 - x_2 + 3x_3 + x_4 = 3\)

\(7x_1 + 6x_2 + 5x_3 + x_4 = 30\)

Preparation

In oder to solve this linear system, we need to set up our square matrix by taking the left side values from the equal sign and I will call it \(C\); our right side values of the equal sign will be represented in a vector, I will call it \(d\).

C = matrix(data = c(-1,-2,-3,7,5,5,-1,6,0,5,3,5,0,2,1,1), nrow=4, ncol = 4)
d = c(-8,9,3,30)

Matrix \(C\).

\[ C = \begin{pmatrix} -1.00 & 5.00 & 0.00 & 0.00 \\ -2.00 & 5.00 & 5.00 & 2.00 \\ -3.00 & -1.00 & 3.00 & 1.00 \\ 7.00 & 6.00 & 5.00 & 1.00 \\ \end{pmatrix} \]

Vector \(d\).

\[ d = \begin{pmatrix} -8.00 \\ 9.00 \\ 3.00 \\ 30.00 \\ \end{pmatrix} \]

Solving in R using ‘solve’

We can solve this equation by using the following command.

S = solve(C,d)

\[ S = \begin{pmatrix} 3.00 \\ -1.00 \\ 2.00 \\ 5.00 \\ \end{pmatrix} \]

Answer

\[ S = \{(x_1 = 3, x_2 = -1, x_3 = 2, x_4 = 5)\}\]

Solving in R using ‘Row Reduction’ (Gauss-Jordan Elimination)

For this, we need to use the package ‘pracma’.

#install.packages("pracma")
library("pracma")

Setup into a single matrix, I will call it \(G\).

G = matrix(data = c(-1,-2,-3,7,5,5,-1,6,0,5,3,5,0,2,1,1,-8,9,3,30), nrow=4, ncol = 5)

Representation of matrix \(G\).

\[ G = \begin{pmatrix} -1.00 & 5.00 & 0.00 & 0.00 & -8.00 \\ -2.00 & 5.00 & 5.00 & 2.00 & 9.00 \\ -3.00 & -1.00 & 3.00 & 1.00 & 3.00 \\ 7.00 & 6.00 & 5.00 & 1.00 & 30.00 \\ \end{pmatrix} \]

We can solve this equation by using the following command ‘rref’.

G1 <- rref(G)

\[ G1 = \begin{pmatrix} 1.00 & 0.00 & 0.00 & 0.00 & 3.00 \\ 0.00 & 1.00 & 0.00 & 0.00 & -1.00 \\ 0.00 & 0.00 & 1.00 & 0.00 & 2.00 \\ 0.00 & 0.00 & 0.00 & 1.00 & 5.00 \\ \end{pmatrix} \]

Answer

\[ S = \{(x_1 = 3, x_2 = -1, x_3 = 2, x_4 = 5)\}\]

Mat2Tex

The above matrix representations were obtained thanks to Mat2Tex.

The documentation can be found here: http://markheckmann.github.io/mat2tex/