Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 - Gauss Elimination Function Develop a MATLAB function called GaussElimination that solves a given system of linear equations of the form A x

Part 1- Gauss Elimination Function
Develop a MATLAB function called GaussElimination that solves a given system of linear equations of the form Ax=b using the Gauss Elimination method. The function should take three input arguments, which must be listed in this order: the coefficient matrix A, the right-side vector b, and a true/false value. If the third value is true, the function should perform partial pivoting while solving the linear system. If the third value is false, the function should not perform partial pivoting. The function should return the vector x. You must create your own implementation of the Gauss Elimination method; you may not use MATLAB's built-in matrix solvers (e.g., you may not use the left division operator). However, while developing your code, you may want to use the built-in matrix solvers to check the answers your code produces.
Refer to the pseudo code form lecture which shows where partial pivoting is performing during Gauss Elimination. You should place a conditional statement containing the partial pivoting code there. If a value of true is received in the input, the partial pivoting code should be executed, otherwise it should not.
1
gauss(A,b) : Performs Gauss elimination to solve for x in Ax=b
Input:
A= coefficient matrix (nn)
b= right hand side vector
Output:
x= solution vector
Confirm that the coefficient matrix A is square
if A is not square
stop execution and return an error value: NaN
end
setup augmented matrix Ab=[A,b]
Number of columns nc=n+1
2 back substitution
3 forward elimination
initialize solution vector x(set all to zero)
x(n)=ABn,ncAb(n,n)
for k=n-1 down to 1
x(k)=Ab(k,nc)
for j=k+1 to n
for p=1 to n-1,p0 is current pivot row
x(k)=x(k)-Ab(k,j)**x(j)
end
x(k)=xkAb(k,k)
end
% if it is used, partial pivoting goes here
for i=p+1 to n,0@ operate on all rows below pivot
factor =Abi,pAb(p,p)
for c=p to nc
Ab(i,c)=Ab(i,c)-factor ***Ab(p,c);
end
end
end
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Apache Cassandra 3 X An Expert Guide To Improving Database Scalability And Availability Without Compromising Performance

Authors: Aaron Ploetz ,Tejaswi Malepati ,Nishant Neeraj

3rd Edition

1789131499, 978-1789131499

More Books

Students also viewed these Databases questions