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

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

The solution is given by solving the system:
I1 I2 I3 +1 +0 +0 +0 +1 +0 +1 +0 +0 +2 -0 -0 +1 -0 +3 +0 +0 +0 +0 +0 I1 = 1A; I2 = 2A; I3 = 3A;