Linear Algebra and the C Language/a04k


Network analysis

We can write:

      Input = Output
A = x1 + x2 = 50
B = 40      = x2 + x3
C = x3 + x4 = 20
D = 30      = x1 + x4

We write x4 = 10

A = x1 + x2 = 50
B = 40      = x2 + x3
C = x3 + 10 = 20
D = 30      = x1 + 10

Let's rectify the system

  x1 + x2  =  50
 -x2 - x3  = -40
  x3       =  20 -10
 -x1       = -30 + 10

Now:

  x1   x2   x3
 +x1  +x2   +0  +0    +50       // A
  +0  -x2  -x3  +0   -40        // B
  +0   +0  +x3  +0   +20 -10    // C
 -x1   +0   +0  +0   -30 +10    // D
 

The code in C language:

double ab[RA*(CA+Cb)]={
//  x1    x2    x3       
    +1,   +1,   +0,   +0,   +50,       // A
    +0,   -1,   -1,   +0,   -40,       // B
    +0,   +0,   +1,   +0,   +20 -10,   // C
    -1,   +0,   +0,   +0,   -30 +10    // D  
};

The solution is given by solving the system:

  x1    x2    x3  
  +1    +0    +0    +0   +20 
  -0    +1    +0    -0   +30 
  +0    +0    +1    +0   +10 
  +0    +0    +0    +0    +0 

 x1 = 20; x2 = 30; x3 = 10;

 With x4 = 10