Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Simultaneous Equation With Matrices

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

SOLUATION OF SIMULTANEOUS

EQUATION WITH MATRICES


Consider the relation

𝑎11 𝑥1 + 𝑎12 𝑥2 + 𝑎13 𝑥3 = 𝑏1


{𝑎21 𝑥1 + 𝑎22 𝑥2 + 𝑎23 𝑥3 = 𝑏2 }
𝑎31 𝑥1 + 𝑎32 𝑥2 + 𝑎33 𝑥3 = 𝑏3

𝐴𝑋 = 𝐵

Where A and B are matrices whose elements are known, and X is a


matrix (a column vector) whose elements are the unknowns. We assume
that A and X are conformable for multiplication.

𝑎11 𝑎12 𝑎13 𝑥1 𝑏1


𝐴 = [𝑎21 𝑎22 𝑎23 ] , 𝑋 = [𝑥2 ] , 𝐵 = [𝑏2 ]
𝑎31 𝑎32 𝑎33 𝑥3 𝑏3

There are two methods to solve the simultaneous equations with matrices,
we use in this lecture:

1- Inverse Matrix Method

Multiplication of both sides of expression below by A-1 yields:

𝐴−1 𝐴𝑋 = 𝐴−1 𝐵 = 𝐼𝑋 = 𝐴−1 𝐵

𝑋 = 𝐴−1 𝐵

𝑥1 𝑎11 𝑎12 𝑎13 −1 𝑏1


[𝑥2 ] = [𝑎21 𝑎22 𝑎23 ] [𝑏2 ]
𝑥3 𝑎31 𝑎32 𝑎33 𝑏3

1
Therefore, we can use formula above to solve any set of
simultaneous equations that have solutions. We will refer to this method
as the inverse matrix method of solution of simultaneous equations.

In MATLAB, we could use the following syntax:

𝐴 = [𝑎11 𝑎12 𝑎13 ; 𝑎21 𝑎22 𝑎23 ; 𝑎31 𝑎32 𝑎33 ];


𝐵 = [𝑏1 ; 𝑏2 ; 𝑏3 ];
𝑋 = 𝑖𝑛𝑣(𝐴) ∗ 𝐵
or
𝑋 = 𝐴\𝐵

Ex.1\ Given the system of equations

2𝑥1 + 3𝑥2 + 𝑥3 = 9
{𝑥1 + 2𝑥2 + 3𝑥3 = 6}
3𝑥1 + 𝑥2 + 2𝑥3 = 8

Compute the unknowns x1, x2 and x3 using the inverse matrix method.

Solution:

2 3 1 𝑥1 9
𝐴 = [1 2 3] , 𝑋 = [𝑥2 ] , 𝐵 = [ 6]
3 1 2 𝑥3 8

Then,

𝑋 = 𝐴−1 𝐵

𝑥1 2 3 1 −1 9
[𝑥2 ] = [1 2 3] [6]
𝑥3 3 1 2 8

In MATLAB

2
A=[231;123;312];
B=[9;6;8];
X = A\ B
or
X = inv (A) * B
Ex.2\ For the electric circuit of Figure below, the mesh equations are:
10𝐼1 − 9𝐼2 = 100
−9𝐼1 + 20𝐼2 − 9𝐼3 = 0

−9𝐼2 + 15𝐼3 = 0

Use the inverse matrix method to compute the values of the currents I1, I2

and I3.

Solution:

For this example, the matrix equation is R I = V, where

10 −9 0 100 𝐼1
𝑅 = [−9 20 −9] , 𝑉 = [ 0 ], 𝐼 = [𝐼2 ]
0 −9 15 0 𝐼3

Then,

𝐼 = 𝑅−1 𝑉

3
𝐼1 10 −9 0 −1 100
[𝐼2 ] = [−9 20 −9] [ 0 ]
𝐼3 0 −9 15 0

In MATLAB

R = [ 10 -9 0 ; -9 20 -9 ; 0 -9 15 ] ;
V = [ 100 ; 0 ; 0 ] ;
I = R\V
or
I =inv (R) * V

2- Cramer’s Rule Method

Let us consider the systems of the three equations below

𝑎11 𝑥 + 𝑎12 𝑦 + 𝑎13 𝑧 = 𝐴


{𝑎21 𝑥 + 𝑎22 𝑦 + 𝑎23 𝑧 = 𝐵}
𝑎31 𝑥 + 𝑎32 𝑦 + 𝑎33 𝑧 = 𝐶

and let

𝑎11 𝑎12 𝑎13 𝐴 𝑎12 𝑎13 𝑎11 𝐴 𝑎13


𝑎
∆= [ 21 𝑎22 𝑎23 ] 𝐷1 = [𝐵 𝑎22 𝑎23 ] 𝐷2 = [𝑎21 𝐵 𝑎23 ] 𝐷3
𝑎31 𝑎32 𝑎33 𝐶 𝑎32 𝑎33 𝑎31 𝐶 𝑎33
𝑎11 𝑎12 𝐴
= [𝑎21 𝑎22 𝐵]
𝑎31 𝑎32 𝐶

Cramer’s rule states that the unknowns x, y and z can be found from the
relations

|𝐷1 | |𝐷2 | |𝐷3 |


𝑥= 𝑦= 𝑧=
|∆| |∆| |∆|

In MATLAB, we could use the following syntax:

𝑑𝑒𝑙𝑡𝑎 = [𝑎11 𝑎12 𝑎13 ; 𝑎21 𝑎22 𝑎23 ; 𝑎31 𝑎32 𝑎33 ];

4
𝐷1 = [𝐴 𝑎12 𝑎13 ; 𝐵 𝑎22 𝑎23 ; 𝐶 𝑎32 𝑎33 ];
𝐷2 = [𝑎11 𝐴 𝑎13 ; 𝑎21 𝐵 𝑎23 ; 𝑎31 𝐶 𝑎33 ];
𝐷3 = [𝑎11 𝑎12 𝐴; 𝑎21 𝑎22 𝐵; 𝑎31 𝑎32 𝐶];
𝑥 = det(𝐷1 ) /det(𝑑𝑒𝑙𝑡𝑎)
𝑦 = det(𝐷2 ) /det(𝑑𝑒𝑙𝑡𝑎)
𝑧 = det(𝐷3 ) /det(𝑑𝑒𝑙𝑡𝑎)

Ex.3\ Use Cramer’s rule to find v1, v2 and v3 for the following equation
system:

2𝑣1 − 5 − 𝑣2 + 3𝑣3 = 0
−2𝑣3 − 3𝑣2 − 4𝑣1 = 8
𝑣2 + 3𝑣1 − 4 − 𝑣3 = 0

Solution:

Rearranging the unknowns v, and transferring known values to the right


side, we obtain

2𝑣1 − 𝑣2 + 3𝑣3 = 5
−4𝑣1 − 3𝑣2 − 2𝑣3 = 8
3𝑣1 + 𝑣2 − 𝑣3 = 4

2 −1 3 5 −1 3 2 5 3
∆= [−4 −3 −2] 𝐷1 = [8 −3 −2] 𝐷2 = [−4 8 −2] 𝐷3
3 1 −1 4 1 −1 3 4 −1

2 −1 5
= [−4 −3 8]
3 1 4

|𝐷1 | |𝐷2 | |𝐷3 |


𝑣1 = 𝑣2 = 𝑣3 =
|∆| |∆| |∆|

5
In MATLAB

delta = [ 2 -1 3 ; -4 -3 -2 ; 3 1 -1 ] ;
D1 = [ 5 -1 3 ; 8 -3 -2 ; 4 1 -1 ] ;
D2 = [ 2 5 3 ; -4 8 -2 ; 3 4 -1 ] ;
D3 = [ 2 -1 5 ; -4 -3 8 ; 3 1 4 ] ;
v1 = det (D1) / det (delta)
v2 = det (D2) / det (delta)
v3 = det (D3) / det (delta)

Homework

INPUT / OUTPUT COMMAND

1- Input Commands:

6
These commands used to identify the values of variable in the

program.

 Identify Variable:

𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒_𝑛𝑎𝑚𝑒 = 𝑣𝑎𝑙𝑢𝑒

Ex.1\ N = 4

B = 25.77

Na =’MATLAB’

 Identify Vector data:

𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒_𝑛𝑎𝑚𝑒 = 𝑓𝑖𝑟𝑠𝑡: 𝑠𝑡𝑒𝑝: 𝑙𝑎𝑠𝑡

Ex.2\ A = 1:5

C = 2:-1:-3

 (Input) Command:

𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒_𝑛𝑎𝑚𝑒 = 𝑖𝑛𝑝𝑢𝑡(′𝑡𝑒𝑥𝑡 ′ )

Ex.3\ Find the value R from the following equation:

𝑅 = √𝑎2 + 𝑏 + sin(𝜋) ; 𝑎 = 3 & 𝑏 = 15

solution:

a=input('value of a ?');

b=input('value of b ?');

7
R=sqrt(a^2+b)+sin(pi)
value of a ?30

value of b ?15

R=

30.2490

2- Output Commands:

 (Display) Command:

𝑑𝑖𝑠𝑝(′𝑡𝑒𝑥𝑡 ′ )

𝑑𝑖𝑠𝑝(𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒)

Ex.4\ Find the value of y from the following equation with explanatory
words print about result.

𝑦 = 𝑏 2 − 2𝑎𝑐 𝑖𝑓 𝑏 = 3, 𝑎 = 3 & 𝑐 = 1

solution:

a=input('value of a ?');
b=input('value of b ?');
c=input('value of c ?');
y=b^2-2*a*c;
disp('Result of y is'),disp(y)
value of a ?3

value of b ?3

value of c ?1

Result of y is

You might also like