Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a computer program to solve the following system of equations ( employ initial guesses of 0 . 0 for all unknowns ) : -

Develop a computer program to solve the following system of equations
(
employ initial guesses of
0.0
for all
unknowns
)
:
-
j
-
2
k
+
4
l
-
2
m
=
97.54
j
-
3
k
+
2
l
-
n
=
79.75
2
k
-
3
l
+
6
m
=
102.28
3
j
+
l
-
2
m
+
7
n
=
84.49
-
3
j
-
k
+
m
-
2
n
=
102.37
using the following two methods:
(
a
)
Gauss
-
Seidel
(
b
)
Jacobi
Perform iterations until the approximation error is
<
0.00001
and then comment on the obtained results.
Please follow the below given details and i need the exact solution of the problem.
IMP Note:
For this problem, it is mandatory to use MatLab. However, you are not allowed to use any built in functions in MatLab that are not available in the other compilers.
Below is the code given to me but not getting the output. resolve it.
% Given system of equations
A =[-1-24-20;
1-32-10;
02-360;
31-270;
-3-110-2];
b =[97.54; 79.75; 102.28; 84.49; 102.37];
% Initial guess
x0=[0; 0; 0; 0; 0];
% Gauss-Seidel Method
disp('Gauss-Seidel Method:');
[x_gs, iterations_gs]= gaussSeidel(A, b, x0,0.000001);
disp(['Solution after ', num2str(iterations_gs),' iterations:']);
disp(x_gs);
% Jacobi Method
disp('Jacobi Method:');
[x_jacobi, iterations_jacobi]= jacobi(A, b, x0,0.000001);
disp(['Solution after ', num2str(iterations_jacobi),' iterations:']);
disp(x_jacobi);
% Gauss-Seidel method function
function [x, iterations]= gaussSeidel(A, b, x0, tolerance)
n = length(b);
x = x0;
x_prev = x0+2*tolerance; % to enter the while loop
iterations =0;
while norm(x - x_prev, inf)> tolerance
x_prev = x;
for i =1:n
x(i)=(b(i)- A(i,1:i-1)*x(1:i-1)- A(i,i+1:n)*x_prev(i+1:n))/ A(i,i);
end
iterations = iterations +1;
end
end
% Jacobi method function
function [x, iterations]= jacobi(A, b, x0, tolerance)
n = length(b);
x = x0;
x_prev = x0+2*tolerance; % to enter the while loop
iterations =0;
while norm(x - x_prev, inf)> tolerance
x_prev = x;
for i =1:n
x(i)=(b(i)- A(i,:)* x_prev + A(i,i)* x_prev(i))/ A(i,i);
end
iterations = iterations +1;
end
end.
MIMP : Gauss-Seidel Method:
Unrecognized function or variable 'gaussSeidel'. I want the solution of this error and give me proper code along eith proper iterations showing each and every steps.

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

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

Show that var(Y 1 ) = 1 .

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago