Write a program using MATLAB or Python for the system below

Write a program using MATLAB or Python for the system below using Gaussian elimination. For each system below, have the program compute the solution to the system Ax = b. A = [0 3 2 1 4 0 7 5 8 2 7 5 0 2 0 2 0 1 2 0], b = [-3 2 -2 -5] A = [0 2 6 1 2 2 0 3 2 4 9 5 0 3 5 4 8 4 0 8 1 0 0 4 0], b = [7 -13 7 -4 -8]

Solution

function x = GaussianElimination(A, b)

% Solve linear system Ax = b

% using Gaussian elimination without pivoting

% A is an n by n matrix

% b is an n by k matrix (k copies of n-vectors)

% x is an n by k matrix (k copies of solution vectors)

[n, n] = size(A); % Find size of matrix A

[n, k] = size(b); % Find size of matrix b

x = zeros(n,k); % Initialize x

for i = 1:n-1

m = -A(i+1:n,i)/A(i,i); % multipliers

A(i+1:n,:) = A(i+1:n,:) + m*A(i,:);

b(i+1:n,:) = b(i+1:n,:) + m*b(i,:);

end;

% Use back substitution to find unknowns

x(n,:) = b(n,:)/A(n,n);

for i = n-1:-1:1

x(i,:) = (b(i,:) - A(i,i+1:n)*x(i+1:n,:))/A(i,i);

end

[1]
% A= [0 3 2 1;4 0 7 5 ;8 2 0 2;0 1 2 0]
% b = [-3;2;-2;-5];

SOL :
x =
   NaN
   NaN
   NaN
   NaN
  
[2]
%A = [0 2 6 1 2; 2 0 3 2 4;9 5 0 3 5;4 8 4 0 8;1 0 0 4 0]
%b =[7;-13;7;-4;-8]  
SOL :
x =
   NaN
   NaN
   NaN
   NaN
   NaN

 Write a program using MATLAB or Python for the system below using Gaussian elimination. For each system below, have the program compute the solution to the sys
 Write a program using MATLAB or Python for the system below using Gaussian elimination. For each system below, have the program compute the solution to the sys

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site