Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A.) function x = Tridiag(e,f,g,r) % Tridiag: Tridiagonal equation solver banded system % x = Tridiag(e,f,g,r): Tridiagonal system solver. % input: % e = subdiagonal

image text in transcribed

A.)

function x = Tridiag(e,f,g,r) % Tridiag: Tridiagonal equation solver banded system % x = Tridiag(e,f,g,r): Tridiagonal system solver. % input: % e = subdiagonal vector % f = diagonal vector % g = superdiagonal vector % r = right hand side vector % output: % x = solution vector n=length(f); % forward elimination for k = 2:n factor = e(k)/f(k-1); f(k) = f(k) - factor*g(k-1); r(k) = r(k) - factor*r(k-1); end % back substitution x(n) = r(n)/f(n); for k = n-1:-1:1 x(k) = (r(k)-g(k)*x(k+1))/f(k); end

B.)

function x = GaussPivot(A,b) % GaussPivot: Gauss elimination pivoting % x = GaussPivot(A,b): Gauss elimination with pivoting. % input: % A = coefficient matrix % b = right hand side vector % output: % x = solution vector [m,n]=size(A); if m~=n, error('Matrix A must be square'); end nb=n+1; Aug=[A b]; % forward elimination for k = 1:n-1 % partial pivoting [big,i]=max(abs(Aug(k:n,k))); ipr=i+k-1; if ipr~=k Aug([k,ipr],:)=Aug([ipr,k],:); end for i = k+1:n factor=Aug(i,k)/Aug(k,k); Aug(i,k:nb)=Aug(i,k:nb)-factor*Aug(k,k:nb); end end % back substitution x=zeros(n,1); x(n)=Aug(n,nb)/Aug(n,n); for i = n-1:-1:1 x(i)=(Aug(i,nb)-Aug(i,i+1:n)*x(i+1:n))/Aug(i,i); end

(1) (2 points) Consider the following system of equations: 0.8x1-0.4x2-41 0.4x1+0.8x2-0.4x3 = 25 -0.4x2 + 0.8x3 = 105 (a) Use MATLAB TriDiag function to solve this system (See Section 9.5 for an example on how to use this function) (b) Use MATLAB GaussPivot function and MATLAB "" operator to verity your results from part (a)

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

Database Theory And Application Bio Science And Bio Technology International Conferences DTA And BSBT 2011 Held As Part Of The Future Generation In Computer And Information Science 258

Authors: Tai-hoon Kim ,Hojjat Adeli ,Alfredo Cuzzocrea ,Tughrul Arslan ,Yanchun Zhang ,Jianhua Ma ,Kyo-il Chung ,Siti Mariyam ,Xiaofeng Song

2011th Edition

ISBN: 3642271561, 978-3642271564

More Books

Students also viewed these Databases questions

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago