4. Use Cramer’s rule to solve the linear system Ax = b given below. = 3x + 3y + 4z = 2 = x + y + 4z = -2 2x + 5y + 4z = 3 3 3 3 4 A= = 1 1 4 Let 2 5 4 and 2 6 = -2 3 be the coefficient matrix and the right-hand side, respectively. To form the matrix , we need to 1 replace the first column of A with b. To do this, type A1=A A1(:,[2])=b The solution for x is found by typing det(A1)/det(A) You can compute for y and z in the ‘ same manner by typing A2=A A2:,[2])=b det(A2)/det(A) A3=A A3(:,[3])=b det(A3)/det(A) Then, compare your answer with that obtained using rref.

29 0

Get full Expert solution in seconds

$1.97 ONLY

Unlock Answer

EXPERT ANSWER

———————-Matlab Code————————

clc; clear; close all;

A = [3 3 4; 1 1 4; 2 5 4];
b = [2 -2 3]';

% Cramer's Rule
A1 = A;
A1(:,[1])=b;

x=det(A1)/det(A)

A2 = A;
A2(:,[2])=b;

y=det(A2)/det(A)

A3 = A;
A3(:,[3])=b;

z=det(A3)/det(A)

% Comparing answers with rref
rref_mat = rref([A b]);

% Getting the last column from the above matrix
% It contains the values of x, y, z
sol = rref_mat(:,end)

———————-Screenshots————————