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

Gauss Jordan Method (Third Practical)

The document solves three systems of linear equations using Gauss-Jordan elimination without partial pivoting. For each system, it sets up the augmented matrix, performs row reduction steps to convert it to row echelon form, extracts the solution vectors, and verifies the solutions satisfy the original systems of equations.

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)
32 views

Gauss Jordan Method (Third Practical)

The document solves three systems of linear equations using Gauss-Jordan elimination without partial pivoting. For each system, it sets up the augmented matrix, performs row reduction steps to convert it to row echelon form, extracts the solution vectors, and verifies the solutions satisfy the original systems of equations.

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

In[48]:=

Gauss Jordan Method;

Q1.Solve the following system of equations without partial pivoting;

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

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


A // MatrixForm
x = {x1, x2, x3};
x // MatrixForm
b = {{1}, {0}, {- 8}};
b // MatrixForm
aug = ArrayFlatten[{{A, b}}];
aug // MatrixForm

Set: Tag Plus in x1 + 2 x2 + 3 x3 is Protected.

Set: Tag Plus in 2 x1 + 6 x2 + 10 x3 is Protected.

Set: Tag Plus in 3 x1 + 14 x2 + 28 x3 is Protected.


Out[54]//MatrixForm=
1 2 3
2 6 10
3 14 28
Out[56]//MatrixForm=
x1
x2
x3
Out[58]//MatrixForm=

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

In[61]:=

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


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

In[64]:= aug〚2〛 = aug〚2〛 * (1 / 2);


aug // MatrixForm
Out[65]//MatrixForm=
1 2 3 1
0 1 2 -1
0 8 19 - 11

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


aug〚3〛 = aug〚3〛 - 8 aug〚2〛;
aug // MatrixForm
Out[68]//MatrixForm=
1 0 -1 3
0 1 2 -1
0 0 3 -3

In[69]:= aug〚3〛 = aug〚3〛 * (1 / 3);


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

In[71]:= aug〚1〛 = aug〚1〛 + aug〚3〛;


aug〚2〛 = aug〚2〛 - 2 aug〚3〛;
aug // MatrixForm
Out[73]//MatrixForm=
1 0 0 2
0 1 0 1
0 0 1 -1

In[74]:= IdentityMatrix[3] = Take[aug, 3, 3];


IdentityMatrix[3] // MatrixForm

Set: Tag IdentityMatrix in IdentityMatrix[3] is Protected.


Out[75]//MatrixForm=
1 0 0
0 1 0
0 0 1
3

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


c // MatrixForm
Out[77]//MatrixForm=
2
1
-1

In[78]:= IdentityMatrix[3].x ⩵ c
Out[78]=

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


4

In[98]:=

ClearAll

Q2.Solve the following system of equations without partial pivoting;

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
aug = ArrayFlatten[{{A, b}}];
aug // MatrixForm
Out[98]=

ClearAll

Set: Tag Plus in 10 x1 + x2 + x3 is Protected.

Set: Tag Plus in 2 x1 + 10 x2 + x3 is Protected.

Set: Tag Plus in x1 + x2 + 5 x3 is Protected.


Out[104]//MatrixForm=
10 1 1
2 10 1
1 1 5
Out[106]//MatrixForm=
x1
x2
x3
Out[108]//MatrixForm=
12
13
7
Out[110]//MatrixForm=
10 1 1 12
2 10 1 13
1 1 5 7
5

In[111]:=

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


aug〚2〛 = aug〚2〛 - 2 aug〚3〛;
aug // MatrixForm
Out[113]//MatrixForm=
1 - 8 - 44 - 51
0 8 -9 -1
1 1 5 7

In[114]:=

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


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

In[116]:=

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


aug // MatrixForm
Out[117]//MatrixForm=
1 - 8 - 44 - 51
0 1 58 59
0 9 49 58

In[118]:=

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


aug // MatrixForm
Out[119]//MatrixForm=
1 - 8 - 44 - 51
0 1 58 59
0 0 - 473 - 473

In[120]:=

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


aug // MatrixForm
Out[121]//MatrixForm=
1 - 8 - 44 - 51
0 1 58 59
0 0 1 1

In[122]:=

aug〚1〛 = aug〚1〛 + 44 aug〚3〛;


aug〚2〛 = aug〚2〛 - 58 aug〚3〛;
aug // MatrixForm
Out[124]//MatrixForm=
1 -8 0 -7
0 1 0 1
0 0 1 1
6

In[125]:=

aug〚1〛 = aug〚1〛 + 8 aug〚2〛;


aug // MatrixForm
Out[126]//MatrixForm=
1 0 0 1
0 1 0 1
0 0 1 1

In[131]:=

IdentityMatrix[3] = Take[aug, 3, 3];


IdentityMatrix[3] // MatrixForm

Set: Tag IdentityMatrix in IdentityMatrix[3] is Protected.


Out[132]//MatrixForm=
1 0 0
0 1 0
0 0 1

In[133]:=

c = Take[aug, 3, - 1];
c // MatrixForm
Out[134]//MatrixForm=
1
1
1

In[136]:=

IdentityMatrix[3].x ⩵ c
Out[136]=

{{x1}, {x2}, {x3}} ⩵ {{1}, {1}, {1}}

In[137]:=

Solve[IdentityMatrix[3].x ⩵ c]
Out[137]=

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

In[334]:=

ClearAll
Out[334]=

ClearAll
7

In[355]:=

Q3.Solve the following system of equations without partial pivoting;

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
x = {{x1}, {x2}, {x3}};
x // MatrixForm
b = {{3}, {7}, {4}};
b // MatrixForm
aug = ArrayFlatten[{{A, b}}];
aug // MatrixForm

Set: Tag Plus in x1 + 10 x2 - x3 is Protected.

Set: Tag Plus in 2 x1 + 3 x2 + 20 x3 is Protected.

Set: Tag Plus in 10 x1 - x2 + 2 x3 is Protected.


Out[360]//MatrixForm=
1 10 - 1
2 3 20
10 - 1 2
Out[362]//MatrixForm=
x1
x2
x3
Out[364]//MatrixForm=
3
7
4
Out[366]//MatrixForm=
1 10 - 1 3
2 3 20 7
10 - 1 2 4
8

In[367]:=

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


aug〚3〛 = aug〚3〛 - 10 aug〚1〛;
aug // MatrixForm

Out[369]//MatrixForm=
1 10 - 1 3
0 - 17 22 1
0 - 101 12 - 26

In[370]:=

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

In[372]:=

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


aug〚3〛 = aug〚3〛 + 101 aug〚2〛;
aug // MatrixForm
Out[374]//MatrixForm=
203 61
1 0 17 17
22 1
0 1 - -
17 17
2018 543
0 0 - -
17 17

In[375]:=

aug〚3〛 = - 17 / 2018 aug〚3〛;


aug // MatrixForm
Out[376]//MatrixForm=
203 61
1 0 17 17
22 1
0 1 - -
17 17
543
0 0 1 2018

In[377]:=

aug〚1〛 = aug〚1〛 - 203 / 17 aug〚3〛;


aug〚2〛 = aug〚2〛 + 22 / 17 aug〚3〛;
aug // MatrixForm
Out[379]//MatrixForm=
757
1 0 0 2018
292
0 1 0 1009
543
0 0 1 2018
9

In[380]:=

IdentityMatrix[3] = Take[aug, 3, 3];


IdentityMatrix[3] // MatrixForm

Set: Tag IdentityMatrix in IdentityMatrix[3] is Protected.


Out[381]//MatrixForm=
1 0 0
0 1 0
0 0 1

In[383]:=

c = Take[aug, 3, - 1];
c // MatrixForm

Out[384]//MatrixForm=
757
2018
292
1009
543
2018

In[385]:=

IdentityMatrix[3].x ⩵ c
Out[385]=
757 292 543
{{x1}, {x2}, {x3}} ⩵  ,  ,  
2018 1009 2018
In[386]:=

Solve[IdentityMatrix[3].x ⩵ c]
Out[386]=
757 292 543
x1 → , x2 → , x3 → 
2018 1009 2018
In[387]:=

ClearAll
Out[387]=

ClearAll

You might also like