0% found this document useful (0 votes)
32 views

Scientific Programming Lab Manual

Uploaded by

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

Scientific Programming Lab Manual

Uploaded by

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

Scientific Programming Lab

Manual

University of Engineering and Technology, Lahore


Faisalabad Campus
BS Chemistry (3rd Semester)

Faculty of Basic Sciences and Humanities

Code of subject: Math-203L

Submitted by: Submitted to:


M- Rohaib Rashid Dr. Abdul Rehman
2022-CHY-207 Professor of Mathematic

3.5 KM. Khurrianwala - Makkuana Bypass Road, Faisalabad(Pakistan)


Table of Contents
Lab No 14 Date:14-12-2023 ................................................................................... 3
Gauss Jacobi and sidle Method ..................................................................................................................................... 3
********************Lab working******************** ................................................................................... 4
Lab No 15 Date:21-12-2023 ................................................................................... 8
LU Decomposition and Cholesky method ..................................................................................................................... 8
*******************Lab working******************** ..................................................................................... 9
Lab No 14 Date:14-12-2023
Gauss Jacobi and sidle Method
Objective:
 To generate the code for gauss Jacobi method to solve the problem in MATLAB.
 To generate the code for gauss sidle method to solve the problem in MATLAB.

Introduction:

Linear system of Equation:


In mathematics, the system of linear equations is the set of two or more linear equations involving the same
variables. Here, linear equations can be defined as the equations of the first order, i.e., the highest power of the
variable is 1. Linear equations can have one variable, two variables, or three variables. Thus, we can write linear
equations with n number of variables.

Methods of solving linear system of equation:


The method of solving of linear system of equation ca be classified into two types.

 Direct Method
 Indirect method

There are two more methods are also including in indirect method.

 Gauss Jacobi Method


 Gauss Sidle Method

Gauss Jacobi Method:


Jacobian method or Jacobi method is one the iterative methods for approximating the solution of a system of n
linear equations in n variables. The Jacobi iterative method is considered as an iterative algorithm which is used for
determining the solutions for the system of linear equations in numerical linear algebra, which is diagonally dominant.
In this method, an approximate value is filled in for each diagonal element. Until it converges, the process is iterated.
This algorithm was first called the Jacobi transformation process of matrix diagonalization. Jacobi Method is also
known as the simultaneous displacement method.

Formula:

Where the Gauss-Jacobi method transforms the system into an iterative form:
Gauss Sidle Method:
The Gauss-Seidel method is a improvisation of the Jacobi method. This method is named after
mathematicians Carl Friedrich Gauss (1777–1855) and Philipp L. Seidel (1821–1896). This modification often results
in higher degree of accuracy within fewer iterations.
In Jacobi method the value of the variables is not modified until next iteration, whereas in Gauss-Seidel
method the value of the variables is modified as soon as new value is evaluated. For instance, in Jacobi method the
value of xi(k) is not modified until the (k + 1) iteration but in Gauss-Seidel method the value of xi(k) changes in in kth
iteration only.

Formula:

Where the Gauss-Jacobi method transforms the system into an iterative form:

********************Lab working********************
Coding for Gauss Jacobi Method:
Fig 14.1

Result:

Fig 14.2
Code for Gauss Sidle Method:
Result:
Lab No 15 Date:21-12-2023
LU Decomposition and Cholesky method
Objective:
 To generate the code for LU decomposition method to solve the problem in MATLAB.
 To generate the code for Cholesky method to solve the problem in MATLAB.

Introduction:

Linear system of Equation:


In mathematics, the system of linear equations is the set of two or more linear equations involving the same
variables. Here, linear equations can be defined as the equations of the first order, i.e., the highest power of the
variable is 1. Linear equations can have one variable, two variables, or three variables. Thus, we can write linear
equations with n number of variables.

LU Decomposition:
In linear algebra, LU Decomposition, i.e., lower–upper (LU) decomposition or factorization of a matrix, can be
defined as the product of a lower and an upper triangular matrix. This product sometimes comprises a permutation
matrix as well. We can relate the LU decomposition method with the matrix form of the Gaussian elimination
method of solving a system of linear equations.

Formula:
We know that

AX=b

A=LU
1 0 0 𝑈11 𝑈12 𝑈13
Where L= 𝐿21 1 0 and U= 0 𝑈22 𝑈23
𝐿31 𝐿32 1 0 0 𝑈33
LUX=b

UX=y

LY=b

Cholesky method:
The Cholesky factorization, also known as Cholesky decomposition, is a process of breaking down of a Hermitian,
positive-definite matrix into the product of a lower triangular matrix and its conjugate transpose, which is important
for quick numerical solutions in linear algebra. André-Louis Cholesky discovered it for real matrices, and it was later
published in 1924. For solving systems of linear equations, the Cholesky factorization is generally twice as efficient as
the LU decomposition when it is feasible.

Formula:
LL-1=I

UA-1=L-1

X=A-1b
*******************Lab working********************
Code for LU decomposition:

Fig 15.1

Result:

Fig 15.2
Code for Cholesky method:

Fig 15.3

You might also like