Linear Algebra and the C Language/a04i
Network analysis
.png)
We can write:
Input = Output A = x1 = x2 + x3 B = x2 + x4 = x5 C = x5 + x6 = x7 D = x3 + x7 = x8 E = x8 = x1 + x4 + x6
We write: x1 = 50; x3 = 20; x5 = 60; x8 = 90;
A = 50 = x2 + 20 B = x2 + x4 = 60 C = 60 + x6 = x7 D = 20 + x7 = 90 E = 90 = 50 + x4 + x6
Let's rectify the system
-x2 = +20 -50 +x2 +x4 = +60 +x6 -x7 = -60 +x7 = +90 -20 -x4 -x6 = +50 -90
Now:
x2 x4 x6 x7 -x2 +0 +0 +0 +0 = +20 -50 +x2 +x4 +0 +0 +0 = +60 +0 +0 +x6 -x7 +0 = -60 +0 +0 +0 +x7 +0 = +90 -20 +0 -x4 -x6 +0 +0 = +50 -90
The code in C language:
double ab[RA*(CA+Cb)]={
// x2 x4 x6 x7
-1, +0, +0, +0, +0, +20 -50,
+1, +1, +0, +0, +0, +60,
+0, +0, +1, -1, +0, -60,
+0, +0, +0, +1, +0, +90 -20,
+0, -1, -1, +0, +0, +50 -90
};
.png)
The solution is given by solving the system:
x2 x4 x6 x7 +1 +0 +0 +0 +0 +30 +0 +1 +0 +0 +0 +30 +0 +0 +1 +0 +0 +10 +0 +0 +0 +1 +0 +70 +0 +0 +0 +0 +0 +0
x2 = +30; x4 = +20; x6 = +10; x7 = +70; et x1 = 50; x3 = 20; x5 = 60; x8 = 90;