SlideShare a Scribd company logo
www.engineeringwithsandeep.com| Student Assignment
Assignment No. 04
Solve the set of linear equations
04.04.2021
Shivam Choubey
Student No: CFDB30321004
www.engineeringwithsandeep.com| Student Assignment
Gauss Elimination
% solve Gauss elimination method consider
% 2a+2b-c+d=4
% 4a+3b-c+2d=6
% 8a+5b-3c+4d=12
%3a+3b-2c+2d=6
% checking A^-1*b
A=[2 2 -1 1;4 3 -1 2;8 5 -3 4;3 3 -2 2];
b=[4 6 12 6]';
[n, n] = size(A);
[n, k] = size(b);
x = zeros(n,k); %%initial value
for i = 1:n-1
m = -A(i+1:n,i)/A(i,i);
A(i+1:n,:) = A(i+1:n,:) + m*A(i,:);
b(i+1:n,:) = b(i+1:n,:) + m*b(i,:);
end;
disp("Matrix before back substitution ")
A
% Use back substitution to find unknowns
x(n,:) = b(n,:)/A(n,n);
for i = n-1:-1:1
x(i,:) = (b(i,:) -
A(i,i+1:n)*x(i+1:n,:))/A(i,i);
end
disp("Value of a ,b ,c & d ")
x
disp("Checking result")
disp("inverse of A")
val=inv(A)
disp("Value of a,b,c &d ")
val*b
Ouput
>> Gauss
Matrix before back substitution
A =
2.0000 2.0000 -1.0000 1.0000
0 -1.0000 1.0000 0
0 0 -2.0000 0
0 0 0 0.5000
Value of a ,b ,c & d
x =
1
1
-1
-1
Checking result
inverse of A
val =
0.5000 1.0000 0.2500 -1.0000
0 -1.0000 -0.5000 0
0 0 -0.5000 0
0 0 0 2.0000
Value of a,b,c &d
ans =
1
1
-1
-1
www.engineeringwithsandeep.com| Student Assignment
Gauss Jordan Method
function [x,err]=gauss_jordan_elim(A,b)
A=[2 2 -1 1;4 3 -1 2;8 5 -3 4;3 3 -2 2];
b=[4 6 12 6]';
[n,m]=size(A);
Aa=[A,b];
for i=1:n
[Aa(i:n,i:n+1),err]=gauss_pivot(Aa(i:n,i:n+1));
if err == 0
Aa(1:n,i:n+1)=gauss_jordan_step(Aa(1:n,i:n+1),i);
end
end
x=Aa(:,n+1);
A=0;
www.engineeringwithsandeep.com| Student Assignment
Continue code
function A1=gauss_jordan_step(A,i)
[n,m]=size(A);
A1=A;
s=A1(i,1);
A1(i,:) = A(i,:)/s;
k=[[1:i-1],[i+1:n]];
for j=k
s=A1(j,1);
A1(j,:)=A1(j,:)-A1(i,:)*s;
end % end of for loop
function [A1,err]=gauss_pivot(A)
[n,m]=size(A);
A1=A;
err = 0;
if A1(1,1) == 0
check = logical(1);
i = 1;
end
gauss_jordon
ans =
1
1
-1
-1
Checking
inv(A)
ans =
1.0000 -0.5000 0.5000 -1.0000
1.0000 0.5000 -0.5000 0
-1.0000 1.5000 -0.5000 0
-4.0000 1.5000 -0.5000 2.0000
>> inv(A)*b
ans =
1
1
-1
-1

More Related Content

PDF
Teoría y problemas de Sumas Notables II sn26 ccesa007
PPT
How to factor powerpoint
DOCX
Aval expres
PDF
3.9.1 Dilation, Scale Factor, and Proportion
PPT
Per6 basis_Representations Of Integers
DOCX
Practica productos notables
PDF
Habilidad operativa
PDF
7th PreAlg - L55--Feb3
Teoría y problemas de Sumas Notables II sn26 ccesa007
How to factor powerpoint
Aval expres
3.9.1 Dilation, Scale Factor, and Proportion
Per6 basis_Representations Of Integers
Practica productos notables
Habilidad operativa
7th PreAlg - L55--Feb3

What's hot (19)

PPTX
Algebra 7 Point 5
PDF
No factorization,no complex methods -Simplest method to solve quadratic equa...
PDF
Ch02 22
KEY
Germany population keynote
PPTX
Derivadas ( jesus crespo)
DOC
1.2 expansion and factorization
DOCX
Calculo mental 2019 5 to1
DOCX
How to check if your multiplication is correct
PDF
Productos notables
DOCX
Ninth grade 4th period study guide key
DOCX
Math basic
PDF
CM1.4 Algorithms, python and SAGE
PDF
Lista plantão 05 - 7º ano
PDF
Lista plantão 04 - 7º ano
PPTX
Proofs day 2
PPTX
Mate factorización por binomio - 2º
PPTX
C2 mate factorización por binomio - 5º
PPTX
2 punto medio
PPTX
Real Numbers
Algebra 7 Point 5
No factorization,no complex methods -Simplest method to solve quadratic equa...
Ch02 22
Germany population keynote
Derivadas ( jesus crespo)
1.2 expansion and factorization
Calculo mental 2019 5 to1
How to check if your multiplication is correct
Productos notables
Ninth grade 4th period study guide key
Math basic
CM1.4 Algorithms, python and SAGE
Lista plantão 05 - 7º ano
Lista plantão 04 - 7º ano
Proofs day 2
Mate factorización por binomio - 2º
C2 mate factorización por binomio - 5º
2 punto medio
Real Numbers
Ad

Similar to Solve the set of linear equations (20)

PDF
CBSE - Grade 8 - Mathematics - Exponents and Powers - Multiple Choice Questio...
PDF
Matematicas para ingenieria 4ta edicion - john bird
PPT
Matrices 44.4
DOCX
Diagnostic_Exam_Grade_7_Mathematics.docx
DOCX
Final exam g8 correction
PDF
Sesion de aprendizaje de ecuacion de primer grado algebra pre universitaria c...
PDF
Vector Algebra One Shot #BounceBack.pdf
PPTX
Dynamic Programming Matrix Chain Multiplication
PDF
Algebra 1 week 10 learn it
PDF
Math_150_Final_Review.pdf for college math placement exam
PDF
Solution of matlab chapter 1
PDF
College Algebra and Trigonometry 6th Edition Lial Solutions Manual
PDF
Sect3 7
DOCX
Bca3010 computer oriented numerical methods
PDF
Sesión de Aprendizaje : Ecuación de primer grado Algebra pre-universitaria c...
PDF
Sesión de Aprendizaje Ecuación de Primer Grado Algebra pre-universitaria cc...
PDF
Soal tiu tes cpns 2019 part 1
PPT
Chapter 6 algebraic expressions iii
PDF
Tugas mtk 1.01
PDF
Solucionario c.t. álgebra 5°
CBSE - Grade 8 - Mathematics - Exponents and Powers - Multiple Choice Questio...
Matematicas para ingenieria 4ta edicion - john bird
Matrices 44.4
Diagnostic_Exam_Grade_7_Mathematics.docx
Final exam g8 correction
Sesion de aprendizaje de ecuacion de primer grado algebra pre universitaria c...
Vector Algebra One Shot #BounceBack.pdf
Dynamic Programming Matrix Chain Multiplication
Algebra 1 week 10 learn it
Math_150_Final_Review.pdf for college math placement exam
Solution of matlab chapter 1
College Algebra and Trigonometry 6th Edition Lial Solutions Manual
Sect3 7
Bca3010 computer oriented numerical methods
Sesión de Aprendizaje : Ecuación de primer grado Algebra pre-universitaria c...
Sesión de Aprendizaje Ecuación de Primer Grado Algebra pre-universitaria cc...
Soal tiu tes cpns 2019 part 1
Chapter 6 algebraic expressions iii
Tugas mtk 1.01
Solucionario c.t. álgebra 5°
Ad

More from shivam choubey (10)

PDF
Simulation Investigation of Separated Nozzle Flows
PDF
steady state CFD simulation on basic shapes and calculate Cd value
PDF
External Aerodynamics (Ahmed body)
PDF
Airfoil Analysis(NACA 0012 ) Ansys Fluent
PDF
Couette flow Ansys simulation
PDF
Mixing elbow simulation Ansys
PDF
sin cos & tan (Plot using MATLAB)
PPTX
The Singular Value Decomposition theroy + example
PDF
1-D Steady Heat conduction FDM
PDF
The finite volume method for diffusion problems
Simulation Investigation of Separated Nozzle Flows
steady state CFD simulation on basic shapes and calculate Cd value
External Aerodynamics (Ahmed body)
Airfoil Analysis(NACA 0012 ) Ansys Fluent
Couette flow Ansys simulation
Mixing elbow simulation Ansys
sin cos & tan (Plot using MATLAB)
The Singular Value Decomposition theroy + example
1-D Steady Heat conduction FDM
The finite volume method for diffusion problems

Recently uploaded (20)

PDF
Abrasive, erosive and cavitation wear.pdf
PPTX
Amdahl’s law is explained in the above power point presentations
PPTX
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
Feature types and data preprocessing steps
PPTX
CyberSecurity Mobile and Wireless Devices
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PPTX
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PDF
Improvement effect of pyrolyzed agro-food biochar on the properties of.pdf
PPTX
Management Information system : MIS-e-Business Systems.pptx
PDF
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
737-MAX_SRG.pdf student reference guides
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Abrasive, erosive and cavitation wear.pdf
Amdahl’s law is explained in the above power point presentations
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
III.4.1.2_The_Space_Environment.p pdffdf
Exploratory_Data_Analysis_Fundamentals.pdf
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Feature types and data preprocessing steps
CyberSecurity Mobile and Wireless Devices
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
Improvement effect of pyrolyzed agro-food biochar on the properties of.pdf
Management Information system : MIS-e-Business Systems.pptx
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
737-MAX_SRG.pdf student reference guides
distributed database system" (DDBS) is often used to refer to both the distri...
Information Storage and Retrieval Techniques Unit III
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF

Solve the set of linear equations

  • 1. www.engineeringwithsandeep.com| Student Assignment Assignment No. 04 Solve the set of linear equations 04.04.2021 Shivam Choubey Student No: CFDB30321004
  • 2. www.engineeringwithsandeep.com| Student Assignment Gauss Elimination % solve Gauss elimination method consider % 2a+2b-c+d=4 % 4a+3b-c+2d=6 % 8a+5b-3c+4d=12 %3a+3b-2c+2d=6 % checking A^-1*b A=[2 2 -1 1;4 3 -1 2;8 5 -3 4;3 3 -2 2]; b=[4 6 12 6]'; [n, n] = size(A); [n, k] = size(b); x = zeros(n,k); %%initial value for i = 1:n-1 m = -A(i+1:n,i)/A(i,i); A(i+1:n,:) = A(i+1:n,:) + m*A(i,:); b(i+1:n,:) = b(i+1:n,:) + m*b(i,:); end; disp("Matrix before back substitution ") A % Use back substitution to find unknowns x(n,:) = b(n,:)/A(n,n); for i = n-1:-1:1 x(i,:) = (b(i,:) - A(i,i+1:n)*x(i+1:n,:))/A(i,i); end disp("Value of a ,b ,c & d ") x disp("Checking result") disp("inverse of A") val=inv(A) disp("Value of a,b,c &d ") val*b Ouput >> Gauss Matrix before back substitution A = 2.0000 2.0000 -1.0000 1.0000 0 -1.0000 1.0000 0 0 0 -2.0000 0 0 0 0 0.5000 Value of a ,b ,c & d x = 1 1 -1 -1 Checking result inverse of A val = 0.5000 1.0000 0.2500 -1.0000 0 -1.0000 -0.5000 0 0 0 -0.5000 0 0 0 0 2.0000 Value of a,b,c &d ans = 1 1 -1 -1
  • 3. www.engineeringwithsandeep.com| Student Assignment Gauss Jordan Method function [x,err]=gauss_jordan_elim(A,b) A=[2 2 -1 1;4 3 -1 2;8 5 -3 4;3 3 -2 2]; b=[4 6 12 6]'; [n,m]=size(A); Aa=[A,b]; for i=1:n [Aa(i:n,i:n+1),err]=gauss_pivot(Aa(i:n,i:n+1)); if err == 0 Aa(1:n,i:n+1)=gauss_jordan_step(Aa(1:n,i:n+1),i); end end x=Aa(:,n+1); A=0;
  • 4. www.engineeringwithsandeep.com| Student Assignment Continue code function A1=gauss_jordan_step(A,i) [n,m]=size(A); A1=A; s=A1(i,1); A1(i,:) = A(i,:)/s; k=[[1:i-1],[i+1:n]]; for j=k s=A1(j,1); A1(j,:)=A1(j,:)-A1(i,:)*s; end % end of for loop function [A1,err]=gauss_pivot(A) [n,m]=size(A); A1=A; err = 0; if A1(1,1) == 0 check = logical(1); i = 1; end gauss_jordon ans = 1 1 -1 -1 Checking inv(A) ans = 1.0000 -0.5000 0.5000 -1.0000 1.0000 0.5000 -0.5000 0 -1.0000 1.5000 -0.5000 0 -4.0000 1.5000 -0.5000 2.0000 >> inv(A)*b ans = 1 1 -1 -1