rate 100% Programming Part: For each programming problem, please submit the code
ID: 2262958 • Letter: R
Question
rate 100%
Programming Part: For each programming problem, please submit the code and the output by pasting them into a word document and attaching them to your homework. 1. Implement the back-substitution algorithm in Matlab to solve Ux b where i j i > j cos(ij), U=[uij]10x10, and b = [balioxi, bil = tan(i) thi = 2. Gauss-Jordan Method: This method is used to solve linear systems as an alternative to Gaussian Elimination. In addition to using pivot element akto eliminate every element below in the kth column, but also use it to eliminate every element above it. This results in the augmented matrix being diagonal and therefore back-substitution is not needed (instead xk =-for k = 1, m) (k-1) b(n-1) 0...0bn-1) (n-1) (n-1) Modify the Gaussian Elimination code to incorporate the Gauss-Jordan Method and re-solve problem 2 (above) to check your work.Explanation / Answer
Program:
% function []=backsubstitution()
clc,clear
% This function solves system of linear equations Ux=b
% where U is upper trianglular matrix and b is constant matrix
%input U and b
% output x
%set Upeer Triangular Matrix
for i=1:10
b(i,1)=tan(i);
for j=1:10
if i>j
U(i,j)=0;
else
U(i,j)=cos(i*j);
end
end
end
x=zeros(10,1);
for i=10:-1:1
x(i)=b(i)/U(i,i);
b(1:i-1)=b(1:i-1)-(U(1:i-1,i)*x(i));
end
Output:
-748.919602967446
-398.474754316029
-207.229883076974
-83.9978506857593
42.8937571027075
-75.7438881957954
51.4967723407501
-17.5075235418190
-0.148602916312626
0.751880595792855
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.