10 Consider the system of equations n 7 d1 a7 d2 a6 d3 a5

10. Consider the system of equations (n = 7) [

[d1 a7]

d2 a6

d3 a5

d4

a3 d5

a2 d6

[ a1 d7]   

For n odd, write and test procedure X Gauss(n, (ai), (di), (bi)) that does the forward elimination phase of Gaussian elimination (without scaled partial pivoting) and procedure X Solve(n, (ai), (di), (bi), (xi)) that does the back substitution for cross-systems of this form

using matlab please show:

(1) the code that solves Ax = b and (2) the code that shows it works.

Solution

function x = GaussPP(A,b) %GaussPP(A,b) solves the n-by-n linear system of equations using partial n = size(A,1); %getting n A = [A,b]; %produces the augmented matrix %elimination process starts for i = 1:n-1 p = i; %comparison to select the pivot for j = i+1:n if abs(A(j,i)) > abs(A(i,i)) U = A(i,:); A(i,:) = A(j,:); A(j,:) = U; end end %cheking for nullity of the pivots while A(p,i)== 0 & p <= n p = p+1; end if p == n+1 disp(\'No unique solution\'); break else if p ~= i T = A(i,:); A(i,:) = A(p,:); A(p,:) = T; end end for j = i+1:n m = A(j,i)/A(i,i); for k = i+1:n+1 A(j,k) = A(j,k) - m*A(i,k); end end end %checking for nonzero of last entry if A(n,n) == 0 disp(\'No unique solution\'); return end %backward substitution x(n) = A(n,n+1)/A(n,n); for i = n - 1:-1:1 sumax = 0; for j = i+1:n sumax = sumax + A(i,j)*x(j); end x(i) = (A(i,n+1) - sumax)/A(i,i); end
10. Consider the system of equations (n = 7) [ [d1 a7] d2 a6 d3 a5 d4 a3 d5 a2 d6 [ a1 d7] For n odd, write and test procedure X Gauss(n, (ai), (di), (bi)) that

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site