SlideShare a Scribd company logo
1 of 9
PRACTICAL
Name- Saloni Singhal
M.Sc. (Statistics) II-Sem.
Roll No: 2046398
Course- MATH-409 L
Numerical Analysis Lab
Submitted To: Dr. S.C. Pandey
OBJECTIVE
• To write an m-file to implement Gauss
elimination method with partial pivoting for
solving system of linear equations.
• To write both script and function files for the
same program.
Theory
In partial pivoting in Gaussian elimination, the algorithm selects the entry
with largest absolute value from the column of the matrix that is currently
being considered as the pivot element.
b. Interchange the rows such that the pivot comes to the first row.
c. Divide the first row by the pivot to make it 1.
d. Use elementary row operations (row only) to reduce the other elements
in the column of this pivot to 0 (with the pivot still being held at 1).
These four steps together is called a pass. (First Pass)
Now ignoring the column and row of the pivot and considering co-factor
submatrix of the pivot, repeat the pivot operations. Repeat these process.
At the end of the two passes, the full matrix would be in the row echelon
form and by back substitution, we determine the values of the unknowns
Advantage:
Partial pivoting is generally sufficient to adequately reduce round-off error
and save time/ storage space in sparse matrix.
Script File
function x =guass_ppivot(A,b)
[m n]=size(A);
if m~=n
fprintf("incorrect size")
exit
end
aug=[A b]
for i=1:m-1 %choosing pivot element and row exchange
[val pos] = max(aug(i:n,i)); %value and position
pos=pos+i-1;
temp=aug(i,:); %storing matrix for swapping
aug(i,:)=aug(pos,:);
aug(pos,:)=temp;
for j=i+1:m %forward elimination
a=aug(j,i)/aug(i,i);
aug(j,:)=aug(j,:)-a*aug(i,:);
end
end
x(n)=aug(n,n+1)/aug(n,n);
for i=n-1:-1:1 %backward substitution
x(i)=(aug(i,n+1)-dot(aug(i,i+1:n),x(i+1:n)))/aug(i,i);
end
end
Function File
function x =guass_script(A,b)
[m n]=size(A);
if m~=n
fprintf("incorrect size")
exit
aug=[A b]
for i=1:m-1 %choosing pivot element and row exchange
[val pos] = max(aug(i:n,i)) %value and position
pos=pos+i-1
temp=aug(i,:)
aug(i,:)=aug(pos,:)
aug(pos,:)=temp
for j=i+1:m %forward elimination
a=aug(j,i)/aug(i,i)
aug(j,:)=aug(j,:)-a*aug(i,:)
end
end
x(n)=aug(n,n+1)/aug(n,n)
for i=n-1:-1:1 %backward substitution
x(i)=(aug(i,n+1)-dot(aug(i,i+1:n),x(i+1:n)))/aug(i,i)
end
end
Cases/Example
1.System with unique soln 2. System with no soln 3. System with
infinite soln
Time Complexity
7
For the given program it is calculated as:
For i=1 T(j)= Σ(n+2-1)
For i=2 T(j)= T((2n3+n2-3n)/2) =O(n3)
T(n)=(n+2)(n-1)-n(n-1)/2= O(n2)
For calculating maximum= O(n)
on summation since in square matrix m=n, =O(n3)
Which the dominant value of all the calculated time
complexities.
Big O notation is the most common metric for calculating time complexity. It
describes the execution time of a task in relation to the number of steps
required to complete it.
We calculate the
no of operations in
two respective
loops.
Big ‘O’ notation
takes its dominant
value
Conclusion
Gaussian elimination provides algorithm that
calculate exact arithmetic and computes the solution
with finite number of elementary operations,
however linear system of equation represents an
exceptional case as it is hardly possible to solve
general system using only finite number of
elementary operations such as the irrational
numbers. Thus, we need iterative methods to solve
system of linear equations.
Caveats
Using partial pivoting has a little bit fewer
options of what to choose from, so it can yield
inferior solutions in some cases. Partial pivoting
adds row permutation (or equation permutation)
and full pivoting will add row
and column permutation (column permutation
corresponds to variable or solution vector
permutation) so it gives more stable solutions.

More Related Content

Similar to Gauss Elimination (With Partial Pivot)

Mapreduce: Theory and implementation
Mapreduce: Theory and implementationMapreduce: Theory and implementation
Mapreduce: Theory and implementationSri Prasanna
 
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdfMATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdfCentral university of Haryana
 
Project management
Project managementProject management
Project managementAvay Minni
 
Map reduce (from Google)
Map reduce (from Google)Map reduce (from Google)
Map reduce (from Google)Sri Prasanna
 
MARLAB codes for Gauss Seidel
MARLAB codes for Gauss SeidelMARLAB codes for Gauss Seidel
MARLAB codes for Gauss SeidelSaloni Singhal
 
Matlab Create a function called polygon that draws a polygon in a pola.docx
Matlab Create a function called polygon that draws a polygon in a pola.docxMatlab Create a function called polygon that draws a polygon in a pola.docx
Matlab Create a function called polygon that draws a polygon in a pola.docxsngyun4t79
 
Cgo2007 P3 3 Birkbeck
Cgo2007 P3 3 BirkbeckCgo2007 P3 3 Birkbeck
Cgo2007 P3 3 BirkbeckaiQUANT
 
A Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in MatlabA Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in MatlabaiQUANT
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c languageTanmay Modi
 
Lagrange Interpolation
Lagrange InterpolationLagrange Interpolation
Lagrange InterpolationSaloni Singhal
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsAbdullah Al-hazmy
 
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docxLab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docxsmile790243
 
2. Linear regression with one variable.pptx
2. Linear regression with one variable.pptx2. Linear regression with one variable.pptx
2. Linear regression with one variable.pptxEmad Nabil
 

Similar to Gauss Elimination (With Partial Pivot) (20)

Mapreduce: Theory and implementation
Mapreduce: Theory and implementationMapreduce: Theory and implementation
Mapreduce: Theory and implementation
 
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdfMATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
MATLAB-Cheat-Sheet-for-Data-Science_LondonSchoolofEconomics (1).pdf
 
Project management
Project managementProject management
Project management
 
Map reduce (from Google)
Map reduce (from Google)Map reduce (from Google)
Map reduce (from Google)
 
MARLAB codes for Gauss Seidel
MARLAB codes for Gauss SeidelMARLAB codes for Gauss Seidel
MARLAB codes for Gauss Seidel
 
Matlab Create a function called polygon that draws a polygon in a pola.docx
Matlab Create a function called polygon that draws a polygon in a pola.docxMatlab Create a function called polygon that draws a polygon in a pola.docx
Matlab Create a function called polygon that draws a polygon in a pola.docx
 
6. function
6. function6. function
6. function
 
Ann a Algorithms notes
Ann a Algorithms notesAnn a Algorithms notes
Ann a Algorithms notes
 
Cgo2007 P3 3 Birkbeck
Cgo2007 P3 3 BirkbeckCgo2007 P3 3 Birkbeck
Cgo2007 P3 3 Birkbeck
 
A Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in MatlabA Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in Matlab
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
Lagrange Interpolation
Lagrange InterpolationLagrange Interpolation
Lagrange Interpolation
 
Data Structures- Part2 analysis tools
Data Structures- Part2 analysis toolsData Structures- Part2 analysis tools
Data Structures- Part2 analysis tools
 
Matlab1
Matlab1Matlab1
Matlab1
 
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docxLab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
 
2. Linear regression with one variable.pptx
2. Linear regression with one variable.pptx2. Linear regression with one variable.pptx
2. Linear regression with one variable.pptx
 

More from Saloni Singhal

More from Saloni Singhal (20)

Finite Difference Method
Finite Difference MethodFinite Difference Method
Finite Difference Method
 
Runge Kutta Method
Runge Kutta MethodRunge Kutta Method
Runge Kutta Method
 
Euler Method
Euler MethodEuler Method
Euler Method
 
Simpson's Three-Eighth Method
Simpson's Three-Eighth MethodSimpson's Three-Eighth Method
Simpson's Three-Eighth Method
 
Trapezoidal Rule
Trapezoidal RuleTrapezoidal Rule
Trapezoidal Rule
 
Simpson One-Third
Simpson One-ThirdSimpson One-Third
Simpson One-Third
 
Newton Forward Interpolation
Newton Forward InterpolationNewton Forward Interpolation
Newton Forward Interpolation
 
Newton Backward Interpolation
Newton Backward InterpolationNewton Backward Interpolation
Newton Backward Interpolation
 
Forward & Backward Differenece Table
Forward & Backward Differenece TableForward & Backward Differenece Table
Forward & Backward Differenece Table
 
Bisection Method
Bisection MethodBisection Method
Bisection Method
 
Newton's Raphson method
Newton's Raphson methodNewton's Raphson method
Newton's Raphson method
 
Fixed Point Interation
Fixed Point InterationFixed Point Interation
Fixed Point Interation
 
Power Method
Power MethodPower Method
Power Method
 
Eigen Show
Eigen ShowEigen Show
Eigen Show
 
Inverse Power Method
 Inverse Power Method Inverse Power Method
Inverse Power Method
 
Convergence Analysis
Convergence AnalysisConvergence Analysis
Convergence Analysis
 
L-U Decomposition
L-U DecompositionL-U Decomposition
L-U Decomposition
 
Error analysis
Error analysisError analysis
Error analysis
 
Flow of control
Flow of controlFlow of control
Flow of control
 
Matlab Files
Matlab FilesMatlab Files
Matlab Files
 

Recently uploaded

Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxolyaivanovalion
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 

Recently uploaded (20)

Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptx
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 

Gauss Elimination (With Partial Pivot)

  • 1. PRACTICAL Name- Saloni Singhal M.Sc. (Statistics) II-Sem. Roll No: 2046398 Course- MATH-409 L Numerical Analysis Lab Submitted To: Dr. S.C. Pandey
  • 2. OBJECTIVE • To write an m-file to implement Gauss elimination method with partial pivoting for solving system of linear equations. • To write both script and function files for the same program.
  • 3. Theory In partial pivoting in Gaussian elimination, the algorithm selects the entry with largest absolute value from the column of the matrix that is currently being considered as the pivot element. b. Interchange the rows such that the pivot comes to the first row. c. Divide the first row by the pivot to make it 1. d. Use elementary row operations (row only) to reduce the other elements in the column of this pivot to 0 (with the pivot still being held at 1). These four steps together is called a pass. (First Pass) Now ignoring the column and row of the pivot and considering co-factor submatrix of the pivot, repeat the pivot operations. Repeat these process. At the end of the two passes, the full matrix would be in the row echelon form and by back substitution, we determine the values of the unknowns Advantage: Partial pivoting is generally sufficient to adequately reduce round-off error and save time/ storage space in sparse matrix.
  • 4. Script File function x =guass_ppivot(A,b) [m n]=size(A); if m~=n fprintf("incorrect size") exit end aug=[A b] for i=1:m-1 %choosing pivot element and row exchange [val pos] = max(aug(i:n,i)); %value and position pos=pos+i-1; temp=aug(i,:); %storing matrix for swapping aug(i,:)=aug(pos,:); aug(pos,:)=temp; for j=i+1:m %forward elimination a=aug(j,i)/aug(i,i); aug(j,:)=aug(j,:)-a*aug(i,:); end end x(n)=aug(n,n+1)/aug(n,n); for i=n-1:-1:1 %backward substitution x(i)=(aug(i,n+1)-dot(aug(i,i+1:n),x(i+1:n)))/aug(i,i); end end
  • 5. Function File function x =guass_script(A,b) [m n]=size(A); if m~=n fprintf("incorrect size") exit aug=[A b] for i=1:m-1 %choosing pivot element and row exchange [val pos] = max(aug(i:n,i)) %value and position pos=pos+i-1 temp=aug(i,:) aug(i,:)=aug(pos,:) aug(pos,:)=temp for j=i+1:m %forward elimination a=aug(j,i)/aug(i,i) aug(j,:)=aug(j,:)-a*aug(i,:) end end x(n)=aug(n,n+1)/aug(n,n) for i=n-1:-1:1 %backward substitution x(i)=(aug(i,n+1)-dot(aug(i,i+1:n),x(i+1:n)))/aug(i,i) end end
  • 6. Cases/Example 1.System with unique soln 2. System with no soln 3. System with infinite soln
  • 7. Time Complexity 7 For the given program it is calculated as: For i=1 T(j)= Σ(n+2-1) For i=2 T(j)= T((2n3+n2-3n)/2) =O(n3) T(n)=(n+2)(n-1)-n(n-1)/2= O(n2) For calculating maximum= O(n) on summation since in square matrix m=n, =O(n3) Which the dominant value of all the calculated time complexities. Big O notation is the most common metric for calculating time complexity. It describes the execution time of a task in relation to the number of steps required to complete it. We calculate the no of operations in two respective loops. Big ‘O’ notation takes its dominant value
  • 8. Conclusion Gaussian elimination provides algorithm that calculate exact arithmetic and computes the solution with finite number of elementary operations, however linear system of equation represents an exceptional case as it is hardly possible to solve general system using only finite number of elementary operations such as the irrational numbers. Thus, we need iterative methods to solve system of linear equations.
  • 9. Caveats Using partial pivoting has a little bit fewer options of what to choose from, so it can yield inferior solutions in some cases. Partial pivoting adds row permutation (or equation permutation) and full pivoting will add row and column permutation (column permutation corresponds to variable or solution vector permutation) so it gives more stable solutions.