(*     Module #20:  Circuit Analysis     *)

(*     Ohm's Law     *)

V=2.0; R=4.;
Print["i = ", i=V/R]

(*     A more Complicated Circuit:  Kirchoff's Laws are used to analyze 
Two resistors that are in parallel:
The total current is what must be supplied by the voltage source.  *)

R1=1000.;R2=2000.; V=2.0;
Print["i1 =", i1=V/R1]
Print["i2 =", i2=V/R2]
Print["i3 =", i3=V/R1+V/R2]

(*    Use of the Mathematica Function Solve[ ]   
      to solve simultaneous equations, for the circuit above        *)
      
R1=1000.;R2=2000.;V=2.0;
Solve[{V==I1*R1,V==I2*R2,Ib==I1+I2},{I1,I2,Ib}]

(*     Another example: can you guess what circuit it would describe?     *)

Clear[I1,I2,I3];
V1=15.;V2=5.;R1=60.;R2=40.;R3=30.;
Solve[{V1-I1*R1-I2*R2==0.,
       -V2-I3*R3+I2*R2==0.,
        I1==I2+I3},
       {I1,I2,I3}]