Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So, the question that I am working on is #4. I have written out a matlab code for #4, but its not working in plotting,

image text in transcribed

So, the question that I am working on is #4. I have written out a matlab code for #4, but its not working in plotting, and I do not understand what I am doing wrong. So here is my code so far:

The function file soroperations:

function [x]= soriterations(a,b,c) n=length(b); x=zeros(n,1);

counter=0; e=1;

w=1:0.1:2;

for k=1:11 counter(k)=0; while e>=0.0001 xo=x; for i=1:n x(i)=b(i); for j=1:i-1 x(i)=x(i)-a(i,j)*x(j); end for j=i+1:n x(i)=x(i)-a(i,j)*xo(j); end x(i)=(1-w(k))*xo(i)+w(k)*(x(i)/a(i,i)); end counter(k)= counter(k)+1; e=norm(x-c);

plot(w(k), counter(k)) title('Omega Versus Convergence') xlabel('Omega') ylabel('Number of Iterations to Convergence')

end end

Running the function with the following to solve the system given in #3:

clear all close all clc

format short

a=[7 3 -1 2; 3 8 1 -4; -1 1 4 -1; 2 -4 -1 6]; b=[-1 0 -3 1]'; c=[-1 1 -1 1]';

soriterations(a,b,c);

3. Using the Jacobi, Gauss-Seidel, and the SOR ( = 1.4) iterative methods, write and run code to solve the follow ing linear system to four decimal places of accuracy: 3 8 1-4x2 Compare the number of iterations in each case. Hint: Here, the exact solution is x = (-1, 1,-1,1) 4. (Continuation) Solve the system using the SOR iterative method with values of = 1(0.1)2. Plot the number of iterations for convergence versus the values of o. Which value of resultsin the fastest convergence? 3. Using the Jacobi, Gauss-Seidel, and the SOR ( = 1.4) iterative methods, write and run code to solve the follow ing linear system to four decimal places of accuracy: 3 8 1-4x2 Compare the number of iterations in each case. Hint: Here, the exact solution is x = (-1, 1,-1,1) 4. (Continuation) Solve the system using the SOR iterative method with values of = 1(0.1)2. Plot the number of iterations for convergence versus the values of o. Which value of resultsin the fastest convergence

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

Identify the steps to follow in preparing an oral presentation.

Answered: 1 week ago

Question

Distinguish between hearing and listening.

Answered: 1 week ago