Linear Algebra and the C Language/a04p
Analysis of an electrical circuit

Studying the circuit in a clockwise direction, we can write:
At node A:
Input = Output
I2 + I3 = I1
At node B :
Input = Output
I4 = I3 + I5
At node C :
Input = Output I6 + I5 = I4
At node D :
Input = Output
I1 = I6 + I2
Then:
a) -I1 +I2 +I3 = 0
-I3 +I4 -I5 = 0
-I4 +I5 +I6 = 0
+I1 -I2 -I6 = 0
Left part of the circuit:
-90 +I1 R1 + I2 R2 = 0 b) +I1 R1 + I2 R2 = +90
Central part of the circuit:
-I2 R2 + I3 R3 + I4 R4 + I6 R6 = 0 c) -I2 R2 + I3 R3 + I4 R4 + I6 R6 = 0
Right part of the circuit:
90 - I5 R5 - I4 R4 = 0 d) -I4 R4 -I5 R5 = -90
External part of the circuit:
-90 + I1 R1 + I3 R3 + 90 - I5 R5 + I6 R6 = 0 e) +I1 R1 + I3 R3 - I5 R5 + I6 R6 = 0
Then:
a) -I1 +I2 +I3 = +0
-I3 +I4 -I5 = +0
-I4 +I5 +I6 = +0
+I1 -I2 -I6 = +0
b) +I1 R1 +I2 R2 = +90
c) -I2 R2 +I3 R3 +I4 R4 +I6 R6 = +0
d) -I4 R4 -I5 R5 = -90
e) +I1 R1 +I3 R3 -I5 R5 +I6 R6 = +0
With R1 = 15, R2 = 60, R3 = 15, R4 = 15, R5 = 60, R6 = 15
a) -I1 +I2 +I3 = +0
-I3 +I4 -I5 = +0
-I4 +I5 +I6 = +0
+I1 -I2 -I6 = +0
b) +I1 15 +I2 60 = +90
c) -I2 60 +I3 15 +I4 15 +I6 15 = +0
d) -I4 15 -I5 60 = -90
e) +I1 15 +I3 15 -I5 60 +I6 15 = +0
Let's rectify the system:
I1 I2 I3 I4 I5 I6
a) -1 +1 +1 +0 +0 +0 +0
+0 +0 -1 +1 -1 +0 +0
+0 +0 +0 -1 +1 +1 +0
+1 -1 +0 +0 +0 -1 +0
b) +15 +60 +0 +0 +0 +0 +90
c) +0 -60 +15 +15 +0 +15 +0
d) +0 +0 +0 -15 -60 +0 -90
e) +15 +0 +15 +0 -60 +15 +0
The code in C language:
double ab[RA*(CA+Cb)]={
// I1 I2 I3 I4 I5 I6
-1, +1, +1, +0, +0, +0, +0, +0, +0,
+0, +0, -1, +1, -1, +0, +0, +0, +0,
+0, +0, +0, -1, +1, +1, +0, +0, +0,
+1, -1, +0, +0, +0, -1, +0, +0, +0,
+15, +60, +0, +0, +0, +0, +0, +0, +90,
+0, -60, +15, +15, +0, +15, +0, +0, +0,
+0, +0, +0, -15, -60, +0, +0, +0, -90,
+15, +0, +15, +0, -60, +15, +0, +0, +0
};

The solution is given by solving the system:
I1 I2 I3 I4 I5 I6 +1.00 -0.00 -0.00 +0.00 -0.00 +0.00 -0.00 -0.00 +2.00 +0.00 +1.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +1.00 +0.00 +0.00 +1.00 +0.00 +0.00 +0.00 +0.00 +0.00 +1.00 +0.00 +0.00 +0.00 +1.00 +0.00 +0.00 +0.00 +0.00 +2.00 +0.00 +0.00 +0.00 +0.00 +1.00 +0.00 +0.00 +0.00 +1.00 +0.00 +0.00 +0.00 +0.00 +0.00 +1.00 +0.00 +0.00 +1.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 I1 = 2, I2 = 1, I3 = 1, I4 = 2, I5 = 1, I6 = 1,