EAT 2016F IcaEngineering httpsallspringboarduakronedud2Melco

EAT 2016F Ica-Engineering httpsallspringboard.uakronedu/d2Melcontent/409108ANiewContent/3891650MMew 1. Given the system of equations x, 2x. 5x1-2x2 2 (a) Compute the determinant. x\'s. (c) Use Gauss elimination to solve for the x\'s. (d) Substitute your results back into the original equations to check your solution. MacBook Pro

Solution

% matlab program to solve the system of equations
% -3x2+7x3 = 2
% x1+2x2-x3 = 3
% 5x1-2x2 = 2

A = [0 -3 7
1 2 -1
5 -2 0];
B = [2 3 2]\';
disp(\'Solution using MATLAB:\');
X = inv(A)*B

detterminant = det(A)

%% Now solving using Cramer\'s rule
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A = [0 -3 7
1 2 -1
5 -2 0];
B = [2 3 2]\';

Ax1 = [2 -3 7
3 2 -1
2 -2 0];

Ax2 = [0 2 7
1 3 -1
5 2 0];

Ax3 = [0 -3 2
1 2 3
5 -2 2];

detA = det(A);
detAx1 = det(Ax1);
detAx2 = det(Ax2);
detAx3 = det(Ax3);

x1 = detAx1/detA;
x2 = detAx2/detA;
x3 = detAx3/detA;
disp(\'Solution from Cramers rule:\');
x1
x2
x3

%% Now solving using Gauss elimination
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a= [0 -3 7 2;1 2 -1 3;5 -2 0 2];
[m,n]=size(a);
for j=1:m-1
for z=2:m
if a(j,j)==0
t=a(j,:);a(j,:)=a(z,:);
a(z,:)=t;
end
end
for i=j+1:m
a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j));
end
end
x=zeros(1,m);
for s=m:-1:1
c=0;
for k=2:m
c=c+a(s,k)*x(k);
end
x(s)=(a(s,n)-c)/a(s,s);
end
disp(\' Solution from Gauss elimination method:\');
x\'
% Program ends here


After running the above program you will get the following output

OUTPUT:

Solution using MATLAB:

X =

0.9855
1.4638
0.9130


detterminant =

-69

Solution from Cramers rule:

x1 =

0.9855


x2 =

1.4638


x3 =

0.9130

Solution from Gauss elimination method:

ans =

0.9855
1.4638
0.9130

 EAT 2016F Ica-Engineering httpsallspringboard.uakronedu/d2Melcontent/409108ANiewContent/3891650MMew 1. Given the system of equations x, 2x. 5x1-2x2 2 (a) Compu
 EAT 2016F Ica-Engineering httpsallspringboard.uakronedu/d2Melcontent/409108ANiewContent/3891650MMew 1. Given the system of equations x, 2x. 5x1-2x2 2 (a) Compu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site