0% found this document useful (0 votes)
72 views9 pages

Gauss Elimination Method (Second Practical)

The document discusses solving systems of linear equations using Gauss elimination method. It provides 4 examples of setting up the coefficient matrix A and constant vector b, performing row reduction using elementary row operations to obtain an upper triangular system, and solving for the variables. The solutions found are x1=2, x2=1, x3=-1 for the first system; x1=757/2018, x2=292/1009, x3=543/2018 for the second; and x1=1, x2=1, x3=1 for the fourth system. The third system was found to have no solution.

Uploaded by

Mohit
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)
72 views9 pages

Gauss Elimination Method (Second Practical)

The document discusses solving systems of linear equations using Gauss elimination method. It provides 4 examples of setting up the coefficient matrix A and constant vector b, performing row reduction using elementary row operations to obtain an upper triangular system, and solving for the variables. The solutions found are x1=2, x2=1, x3=-1 for the first system; x1=757/2018, x2=292/1009, x3=543/2018 for the second; and x1=1, x2=1, x3=1 for the fourth system. The third system was found to have no solution.

Uploaded by

Mohit
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/ 9

Gauss Elimination Method;

Q1. Solve the following system of equations;

x1 + 2 x2 + 3 x3 = 1;
2 x1 + 6 x2 + 10 x3 = 0;
3 x1 + 14 x2 + 28 x3 = - 8;

In[116]:=

A = {{1, 2, 3}, {2, 6, 10}, {3, 14, 28}};


A // MatrixForm
Out[117]//MatrixForm=
1 2 3
2 6 10
3 14 28

In[7]:=

X = {x1, x2, x3};


X // MatrixForm
b = {{1}, {0}, {- 8}};
b // MatrixForm
Out[8]//MatrixForm=
x1
x2
x3
Out[10]//MatrixForm=
1
0
-8

In[41]:=

aug = ArrayFlatten[{{A, b}}];


aug // MatrixForm
Out[42]//MatrixForm=
1 2 3 1
2 6 10 0
3 14 28 - 8

In[53]:=
2

In[43]:= aug〚2〛 = aug〚2〛 - 2 aug〚1〛;


aug〚3〛 = aug〚3〛 - 3 aug〚1〛;
aug // MatrixForm
Out[45]//MatrixForm=
1 2 3 1
0 2 4 -2
0 8 19 - 11

In[46]:= aug〚3〛 = aug〚3〛 - 4 aug〚2〛;


aug // MatrixForm
Out[47]//MatrixForm=
1 2 3 1
0 2 4 -2
0 0 3 -3

In[48]:= upper = Take[aug, 3, 3];


upper // MatrixForm
Out[49]//MatrixForm=
1 2 3
0 2 4
0 0 3

In[52]:= c = Take[aug, 3, - 1];


c // MatrixForm
Out[53]//MatrixForm=
1
-2
-3

In[54]:= upper.X ⩵ c
Out[54]=

x1 + 2 x2 + 3 x3, 2 x2 + 4 x3, 3 x3 ⩵ {{1}, {- 2}, {- 3}}

In[55]:= Solve[upper.X ⩵ c]
Out[55]=

{{x1 → 2, x2 → 1, x3 → - 1}}

In[71]:= ClearAll
Out[71]=

ClearAll
3

In[121]:=

Q2.Solve the system of following linear equations by Gauss Elimination Method;

x1 + 10 x2 - x3 = 3;
2 x1 + 3 x2 + 20 x3 = 7;
10 x1 - x2 + 2 x3 = 4;

A = {{1, 10, - 1}, {2, 3, 20}, {10, - 1, 2}};


A // MatrixForm
Out[126]//MatrixForm=
1 10 - 1
2 3 20
10 - 1 2

In[127]:=

X = {{x1}, {x2}, {x3}};


X // MatrixForm
b = {{3}, {7}, {4}};
b // MatrixForm
Out[128]//MatrixForm=
x1
x2
x3
Out[130]//MatrixForm=
3
7
4

In[131]:=

aug = ArrayFlatten[{{A, b}}];


aug // MatrixForm
Out[132]//MatrixForm=
1 10 - 1 3
2 3 20 7
10 - 1 2 4
4

In[133]:=

aug〚2〛 = aug〚2〛 - 2 aug〚1〛;


aug〚3〛 = aug〚3〛 - 10 aug〚1〛;
aug // MatrixForm
Out[135]//MatrixForm=
1 10 - 1 3
0 - 17 22 1
0 - 101 12 - 26

In[136]:=

aug〚3〛 = aug〚3〛 - 101 / 17 aug〚2〛;


aug // MatrixForm
Out[137]//MatrixForm=
1 10 -1 3
0 - 17 22 1
2018 543
0 0 - -
17 17

In[152]:=

upper = Take[aug, 3, 3];


upper // MatrixForm
Out[153]//MatrixForm=
1 10 -1
0 - 17 22
2018
0 0 -
17

In[154]:=

c = Take[aug, 3, - 1];
c // MatrixForm
Out[155]//MatrixForm=
3
1
543
-
17

In[157]:=

upper.X ⩵ c
Out[157]=

2018 x3 543
x1 + 10 x2 - x3, - 17 x2 + 22 x3, -  ⩵ {3}, {1}, - 
17 17
In[158]:=

Solve[upper.X ⩵ c]
Out[158]=
757 292 543
x1 → , x2 → , x3 → 
2018 1009 2018
5

In[159]:=

ClearAll
Out[159]=

ClearAll

In[4]:=

Q3.Solve the system of following linear equations by Gauss Elimination Method;

2 x1 + x2 - 3 x3 = 0;
5 x1 + 8 x3 + x3 = 14;
4 x1 + 13 x2 + 11 x3 = 25;

A = {{2, 1, - 3}, {5, 8, 1}, {4, 13, 11}};


X = {{x1}, {x2}, {x3}};
b = {{0}, {14}, {25}};
A // MatrixForm
X // MatrixForm
b // MatrixForm
Out[11]//MatrixForm=
2 1 -3
5 8 1
4 13 11
Out[12]//MatrixForm=
x1
x2
x3
Out[13]//MatrixForm=
0
14
25

In[17]:=

aug = ArrayFlatten[{{A, b}}];


aug // MatrixForm
Out[18]//MatrixForm=
2 1 -3 0
5 8 1 14
4 13 11 25
6

In[19]:=

aug〚2〛 = aug〚2〛 - 5 / 2 aug〚1〛;


aug〚3〛 = aug〚3〛 - 2 aug〚1〛;
aug // MatrixForm
Out[21]//MatrixForm=
2 1 -3 0
11 17
0 2 2
14
0 11 17 25

In[25]:=

In[30]:=

In[22]:= aug〚3〛 = 1 / 2 aug〚3〛;


aug // MatrixForm
Out[23]//MatrixForm=
2 1 -3 0
11 17
0 2 2
14
11 17 25
0 2 2 2

In[24]:= aug〚3〛 = aug〚3〛 - aug〚2〛;


aug // MatrixForm
Out[25]//MatrixForm=
2 1 -3 0
11 17
0 2 2
14
3
0 0 0 -
2

In[26]:= upper = Take[aug, 3, 3];


upper // MatrixForm
Out[27]//MatrixForm=
2 1 -3
11 17
0 2 2
0 0 0

In[28]:= c = Take[aug, 3, - 1];


c // MatrixForm
Out[29]//MatrixForm=
0
14
3
-
2

In[30]:= upper.X ⩵ c
Out[30]=

False
7

In[31]:= Solve[upper.X ⩵ c]
Out[31]=

{}

In[71]:=

ClearAll
Out[71]=

ClearAll

Q4.Solve the system of following linear equations by Gauss Elimination Method;

In[104]:=

10 x1 + x2 + x3 = 12;
2 x1 + 10 x2 + x3 = 13;
x1 + x2 + 5 x3 = 7;

A = {{10, 1, 1}, {2, 10, 1}, {1, 1, 5}};


A // MatrixForm
X = {{x1}, {x2}, {x3}};
X // MatrixForm
b = {{12}, {13}, {7}};
b // MatrixForm
Out[108]//MatrixForm=
10 1 1
2 10 1
1 1 5
Out[110]//MatrixForm=
x1
x2
x3
Out[112]//MatrixForm=
12
13
7

In[140]:=

aug = ArrayFlatten[{{A, b}}];


In[141]:=

aug // MatrixForm
Out[141]//MatrixForm=
10 1 1 12
2 10 1 13
1 1 5 7
8

In[142]:=

aug〚2〛 = aug〚2〛 - 2 aug〚3〛;


aug // MatrixForm
Out[143]//MatrixForm=
10 1 1 12
0 8 -9 -1
1 1 5 7

In[144]:=

aug〚1〛 = aug〚1〛 - 9 aug〚3〛;


aug // MatrixForm
Out[145]//MatrixForm=
1 - 8 - 44 - 51
0 8 -9 -1
1 1 5 7

In[146]:=

aug〚3〛 = aug〚3〛 - aug〚1〛;


aug // MatrixForm

Out[147]//MatrixForm=
1 - 8 - 44 - 51
0 8 -9 -1
0 9 49 58

In[148]:=

aug〚3〛 = aug〚3〛 - 9 / 8 aug〚2〛;


aug // MatrixForm
Out[149]//MatrixForm=
1 - 8 - 44 - 51
0 8 -9 -1
473 473
0 0 8 8

In[151]:=

upper = Take[aug, 3, 3];


upper // MatrixForm
c = Take[aug, 3, - 1];
Out[152]//MatrixForm=
1 - 8 - 44
0 8 -9
473
0 0 8

In[150]:=

c // MatrixForm
Out[150]//MatrixForm=
0
14
3
-
2
9

In[155]:=

upper.X ⩵ c
Out[155]=

473 x3 473
x1 - 8 x2 - 44 x3, 8 x2 - 9 x3,   ⩵ {- 51}, {- 1},  
8 8
In[156]:=

Solve[upper.X ⩵ c]
Out[156]=

{{x1 → 1, x2 → 1, x3 → 1}}

You might also like