Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Show all work and explain each step please. Try to use example code included at the bottom. Example code %% Gauss Siedel A = [12,6,3,1;12,20,1,5;7,18,30,4;6,7,2,22];

Show all work and explain each step please. Try to use example code included at the bottom.

image text in transcribed

Example code

%% Gauss Siedel

A = [12,6,3,1;12,20,1,5;7,18,30,4;6,7,2,22]; b = [27;30;48;5];

% Jacobi:Solve all equations for a single variable %Define Tolerance tol = 0.1; error=1;% Define some start error bigger than the tolerance to enter the loop; %Define Initial Guesses;

x1=0; x2=0; x3=0; x4=0; % set counter count = 0; while error>tol x1 = (27-6*x2 -3*x3 - 1*x4)/A(1,1); x2 = (30-12*x1 -5*x3 - 7*x4)/A(2,2); x3 = (48-7*x1 - 18*x2 -4*x4)/A(3,3); x4 = (5-6*x1-7*x2-2*x3)/A(4,4); count=count+1; if count>10000 break end x = [x1;x2;x3;x4]; error = abs(max(b - A*x)); end

3. (25%) Write a function in MATLAB that takes as an input a matrix of coefficients for a system of linear equations (A), the solution vector (b), an initial guess for the solution, a tolerance, and a maximum number of iterations. Have your function output the approximate solution of the system using the Gauss Seidel Method. (Hint: first line of your script should be the following: function [result,error,count] = GaussSeidel(A,b,x0,tol) ) a. Test your function on the following system and output the result, final error, and number of iterations used. Use as a measure of error the difference between the last and current estimate. System: 12x+6y+3z+p = 27 12x + 20y +1z+5p = 30 7x + 18y +30z+4p= 48 6x+7y+2z+22p=5 5. System. Thentecos b. Solve the matrix equation Ax=b for an exact solution of the above system. Then compute the absolute and relative error between the gauss siedel estimate and the exact solution for the variable x

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions