0% found this document useful (0 votes)
7 views4 pages

Sample Lab Report PSA 3

The document outlines a lab report on the Gauss-Seidel method for solving linear equations using MATLAB. It details objectives, theoretical background, MATLAB code implementations for both single and two-variable equations, and results from the experiments. The lab concludes with lessons learned about the method's principles, convergence criteria, and the impact of initial guesses on the solution.

Uploaded by

abdul786786q
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Sample Lab Report PSA 3

The document outlines a lab report on the Gauss-Seidel method for solving linear equations using MATLAB. It details objectives, theoretical background, MATLAB code implementations for both single and two-variable equations, and results from the experiments. The lab concludes with lessons learned about the method's principles, convergence criteria, and the impact of initial guesses on the solution.

Uploaded by

abdul786786q
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Power System Analysis Lab

Regd. No. 22-EE-44


Name Abdul Qadir Abbasi
Section B1
Lab # 03
Study and Implementation of Gauss Seidel Method for solution of
Equations using MATLAB.
1. Objectives
1. To analyze the convergence criteria and conditions under which the method is effective.
2. To analyze the effect of different initial guesses on the convergence of the solution.
3. Implement Gauss-Seidel for one and two variables in MATLAB.

2. Theoretical Background
2.1. Gauss Seidel Method
The Gauss-Seidel method is an iterative numerical technique used to solve a system of
linear equations. It updates the solution by using the most recent values, allowing for faster
convergence compared to methods like Jacobi. This technique is particularly effective for
diagonally dominant or symmetric positive definite matrices, ensuring reliable results.

2.2. Mathematical modeling:


Given a general set of n equations and n unknowns, we have

Solve for xi the diagonal term in terms of the other variables:

Page 1 of 4
Power System Analysis Lab

The general formula for is:

Start with an initial guess for the solution vector:

Update each variable xi iteratively using the formula until the solution converges.
Convergence is determined by checking whether the change in the solution is below a given
tolerance:

where ϵ is the specified tolerance, and ∥⋅∥ represents a suitable norm (e.g., Euclidean or
maximum norm).

3. Activity 1:Code Gauss Seidel Method for single variable and test an
equation
F(x)=x^3-6x^2+9x-4
3.1. MATLAB Code
clc
clear all
close all
x(1)=2;
errorrate=1;y=1;
while errorrate>0.001
x_new=(-1/9*x(y)^3+(6/9)*x(y)^2+4/9);
errorrate=abs(x_new-x(y));
disp(['root of iteration',num2str(y),'=',num2str(x_new)]);
y=y+1;x(y)=x_new;
end
disp(['root of equation is ',num2str(x(y))])

3.2. Results/Output
The output of the code is given by

Page 2 of 4
Power System Analysis Lab

4. Activity 2:Code Gauss Seidel Method for two variables and test on
system.
x1+x1x2=10
x1+x2=6

i. x = (1,1) , ii. x = (1,2)


4.1. MATLAB Code (part i)
clc
clear all
close all
x1(1)=1;
x2(1)=1;
y=1;
a1=1;
a2=1;
while abs(a1)>0.001 && abs(a2)>0.001
x1(y+1)=10/(1+x2(y));
x2(y+1)=6-x1(y+1);
a1= x1(y+1)-x1(y);
a2=x2(y+1)-x2(y);
disp(['the roots of itration ',num2str(y),' x1=
',num2str(x1(y+1)),' x2= ',num2str(x2(y+1))])
y=y+1;
end

4.2. Results/Output

4.3. MATLAB Code (part ii)


clc
clear all
close all
x1(1)=1;
x2(1)=2;
y=1;
a1=1;
a2=1;
while abs(a1)>0.001 && abs(a2)>0.001
x1(y+1)=10/(1+x2(y));
x2(y+1)=6-x1(y+1);
a1= x1(y+1)-x1(y);
a2=x2(y+1)-x2(y);

Page 3 of 4
Power System Analysis Lab

disp(['the roots of itration ',num2str(y),' x1=


',num2str(x1(y+1)),' x2= ',num2str(x2(y+1))])
y=y+1;
end

4.4. Results/Output

6. Lesson Learnt
Learned the fundamental principles of the Gauss-Seidel method, including its iterative nature
and convergence criteria for solving linear systems.Gained hands-on experience in
implementing the Gauss-Seidel algorithm in MATLAB.developed an understanding of the
importance of initial guesses, error tolerance on convergence.

Page 4 of 4

You might also like