Professional Documents
Culture Documents
Abhishek p4
Abhishek p4
NUMERICAL METHODS
(PRACTICAL)
#ASSIGNMENT-4
(* Qus1 Solve the following system of equations using Gauss Elimination method
2x-2y+3z=2 , x+2y-z=3 , 3x-y+2z=1 *)
In[32]:= MatrixForm[mat]
Out[32]//MatrixForm=
2 -2 3 2
1 2 -1 3
3 -1 2 1
Out[33]=
3
1, - 1, , 1
2
In[34]:= MatrixForm[mat]
Out[34]//MatrixForm=
3
1 -1 1
2
1 2 -1 3
3 -1 2 1
In[37]:= MatrixForm[mat]
Out[37]//MatrixForm=
3
1 -1 1
2
5
0 3 - 2
2
5
0 2 - -2
2
{0, 1, 0, 4}
2
In[39]:= MatrixForm[mat]
Out[39]//MatrixForm=
3
1 -1 1
2
0 1 0 4
5
0 2 - -2
2
In[41]:= MatrixForm[mat]
Out[41]//MatrixForm=
3
1 0 5
2
0 1 0 4
5
0 2 - -2
2
{1, 0, 0, - 1}
In[44]:= MatrixForm[mat]
Out[44]//MatrixForm=
1 0 0 -1
0 1 0 4
5
0 0 - - 10
2
In[46]:= MatrixForm[mat]
Out[46]//MatrixForm=
1 0 0 -1
0 1 0 4
0 0 1 4
In[47]:= Print"The solution is(x,y,z)=(", mat1, 4, ",", mat2, 4, ",", mat3, 4 ")."
In[5]:= MatrixForm[mat]
Out[5]//MatrixForm=
2 4 6 22
3 8 5 27
-1 1 2 2
Out[7]= {0, 2, - 4, - 6}
In[9]:= MatrixForm[mat]
Out[9]//MatrixForm=
1 2 3 11
0 2 -4 -6
0 3 5 13
{1, 0, 7, 17}
In[11]:= MatrixForm[mat]
Out[11]//MatrixForm=
1 0 7 17
0 2 -4 -6
0 3 5 13
{0, 1, - 2, - 3}
In[13]:= MatrixForm[mat]
Out[13]//MatrixForm=
1 0 7 17
0 1 -2 -3
0 3 5 13
2
Out[14]=
{0, 0, 11, 22}
In[15]:= MatrixForm[mat]
Out[15]//MatrixForm=
1 0 7 17
0 1 -2 -3
0 0 11 22
{0, 0, 1, 2}
In[17]:= MatrixForm[mat]
Out[17]//MatrixForm=
1 0 7 17
0 1 -2 -3
0 0 1 2
{1, 0, 0, 3}
Out[19]=
{0, 1, 0, 1}
In[20]:= MatrixForm[mat]
Out[20]//MatrixForm=
1 0 0 3
0 1 0 1
0 0 1 2
In[22]:= Print"The solution is(x,y,z)=(", mat1, 4, ",", mat2, 4, ",", mat3, 4 ")."
(* Qus3 3. Find the inverse of the following matrix using Gauss-Jordan Method:
In[3]:= Det[mat]
Out[3]= - 12
In[50]:= MatrixForm[A]
Out[50]//MatrixForm=
1 1 1 1 0 0
2 -3 4 0 1 0
3 4 5 0 0 1
{0, - 5, 2, - 2, 1, 0}
Out[52]=
{0, 1, 2, - 3, 0, 1}
In[53]:= MatrixForm[A]
Out[53]//MatrixForm=
1 1 1 1 0 0
0 -5 2 -2 1 0
0 1 2 -3 0 1
{1, 0, - 1, 4, 0, - 1}
In[55]:= MatrixForm[A]
Out[55]//MatrixForm=
1 0 -1 4 0 -1
0 -5 2 -2 1 0
0 1 2 -3 0 1
2
In[57]:= MatrixForm[A]
Out[57]//MatrixForm=
1 0 -1 4 0 -1
2 2 1
0 1 - - 0
5 5 5
0 1 2 -3 0 1
In[59]:= MatrixForm[A]
Out[59]//MatrixForm=
1 0 -1 4 0 -1
2 2 1
0 1 - - 0
5 5 5
12 17 1
0 0 - 1
5 5 5
In[61]:= MatrixForm[A]
Out[61]//MatrixForm=
1 0 -1 4 0 -1
2 2 1
0 1 - - 0
5 5 5
17 1 5
0 0 1 -
12 12 12
In[63]:= MatrixForm[A]
Out[63]//MatrixForm=
31 1 7
1 0 0 -
12 12 12
2 2 1
0 1 - - 0
5 5 5
17 1 5
0 0 1 -
12 12 12
3
In[65]:= MatrixForm[A]
Out[65]//MatrixForm=
31 1 7
1 0 0 -
12 12 12
1 1 1
0 1 0 - -
6 6 6
17 1 5
0 0 1 -
12 12 12
In[5]:= (*Find the inverse of the following matrix using Gauss-Jordan Method:
A =0 1 2,1 2 3,3 1 1 *)
In[6]:= Det[mat1]
Out[6]= -2
In[21]:= MatrixForm[A]
Out[21]//MatrixForm=
0 1 2 1 0 0
1 2 3 0 1 0
3 1 1 0 0 1
{0, - 8, - 14, - 3, - 3, 1}
In[25]:= MatrixForm[A]
Out[25]//MatrixForm=
1 3 5 1
1 0
0 -1 -2 -1
0 0
0 - 8 - 14 - 3 - 3 1
Out[26]=
{0, 1, 2, 1, 0, 0}
In[27]:= MatrixForm[A]
Out[27]//MatrixForm=
1 3 5 1 1 0
0 1 2 1 0 0
0 -8 - 14 -3 -3 1
2
{1, 0, - 1, - 2, 1, 0}
Out[29]=
{0, 0, 2, 5, - 3, 1}
In[30]:= MatrixForm[A]
Out[30]//MatrixForm=
1 0 -1 -2 1 0
0 1 2 1 0 0
0 0 2 5 -3 1
In[32]:= MatrixForm[A]
Out[32]//MatrixForm=
1 0 -1 -2 1 0
0 1 2 1 0 0
5 3 1
0 0 1 -
2 2 2
{0, 1, 0, - 4, 3, - 1}
In[35]:= MatrixForm[A]
Out[35]//MatrixForm=
1 1 1
1 0 0 -
2 2 2
0 1 0 -4 3 -1
5 3 1
0 0 1 -
2 2 2