Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the following parts of this question, write a MATLAB code to solve a linear system Axb (A is a square nonsingular matrix) using


 image

In the following parts of this question, write a MATLAB code to solve a linear system Axb (A is a square nonsingular matrix) using Jacobi and Gauss-Seidel algorithms. Do not use the built-in MATLAB functions for solving linear systems. (a) Write a MATLAB function called Jacobi that takes a square n x n matrix A, and an n x 1 vector b as input, and uses the Jacobi technique to solve the system Ax = b, starting with the zero vector as the initial guess. Your function should stop when 2-norm of the difference between two successive iterates is less than 10-6, or if your function has performed 1000 iterations without reaching the termination condition. Your function must produce the value of x when the function terminates, along with the number of iterations performed to that point. (b) Write a MATLAB function called GSeidel, which takes the same parameters as the function Jacobi described in part (a), and uses the Gauss-Seidel technique to solve Ax = b. (c) Consider the following n x n system, for values of n > 1: n 1 ... 21 1 n 1 22 = ... n Solve this system using the Jacobi and Gauss-Seidel functions for the values of n equal to 10, 100, and 1000. Note, that exact solution of this system is x = 2n-1,1 = 1, 2,..., n. Produce a table of results, where each row contains the following information: the value of n the relative error in the Jacobi solution x; compared to the exact solution, it;, the number of iterations required by Jacobi, the relative error in the Gauss-Seidel solution x, compared to the exact solution, itg, the number of iterations required by Gauss-Seidel for n

Step by Step Solution

3.42 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

Part A MATLAB SCRIPT function x iterations JacobiA b Initialization n lengthb x zerosn 1 Initial guess zero vector xold x iterations 0 tolerance 1e6 Convergence tolerance maxiterations 1000 Maximum nu... 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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Computer Engineering questions

Question

Distinguish between the upper and lower respiratory tracts.

Answered: 1 week ago