Example 1: Kirchoff 's Voltage Law

A circuit contains six nodes lettered A, B, C, D, E, and F. Let (Subscript[V, AB]) be the voltage between nodes A and B with its positive reference at the first named node, here A. Find (Subscript[V, AC]), (Subscript[V, AD, ])(Subscript[V, AE]), and (Subscript[V, AF]) if (Subscript[V, AB])=6V, (Subscript[V, BD])=-3V, (Subscript[V, CF])=-8V, (Subscript[V, EC])=4V, and  (a) (Subscript[V, DE])=1V  (b) (Subscript[V, CD])=1V  (c) (Subscript[V, FE])= 4V. (Dr. M Fogiel, Director, Staff of Research and Education Association, The Electric Circuits Problem Solver Problem 1.19.) (The figure was drawn using Quickroute 4.0.)

In order to find the voltages in the question, you need to write a KVL (Kirchoff's Voltage Law) equation around the loop which contains the unknown voltages. Mathematica can be used to simplify the equations and solve for the unknowns.  The expressions for each element are written in a list as shown below.

eqn1 =  
      {(Subscript[V, AC]) == (Subscript[V, AB]) + (Subscript[V, BD]) + (Subscript[V, DE]) + (Subscript[V, EC]),   (Subscript[V, AB]) == 6  V,  
        (Subscript[V, BD]) == -3 V, (Subscript[V, EC]) == 4  V,  (Subscript[V, DE]) == 1  V}

Solve[eqn1,  (Subscript[V, AC])]

In the above equation we employ the Mathematica function Solve to reduce the equation, solving for the unknown component, (Subscript[V, AC]).  The double equal sign (==) represents a symbolic equation;  it tests whether the left-hand side (lhs) of the equation is equal to the right-hand side of the equation (rhs), and does not cause an explicit action.

eqn2 = 
      {(Subscript[V, AD]) == (Subscript[V, AB]) + (Subscript[V, BD]),  (Subscript[V, AB]) == 6  V,  (Subscript[V, BD]) == -3 V}

v2 = Solve[eqn2, (Subscript[V, AD])]

eqn3 = 
      {(Subscript[V, AE]) == (Subscript[V, AB]) + (Subscript[V, BD]) + (Subscript[V, DE]), (Subscript[V, AB]) == 6 V, (Subscript[V, BD]) == -3 V,  
        (Subscript[V, DE]) == 1  V}

v3 = Solve[eqn3, (Subscript[V, AE])]

eqn4 = 
      {(Subscript[V, AF]) == (Subscript[V, AB]) + (Subscript[V, BD]) + (Subscript[V, DE]) + (Subscript[V, EC]) + (Subscript[V, CF]), (Subscript[V, AB]) == 6 V, 
        (Subscript[V, BD]) == -3 V,  (Subscript[V, DE]) == 1  V, (Subscript[V, EC]) == 4  V, (Subscript[V, CF]) == -8 V}

v4 = Solve[eqn4, (Subscript[V, AF])]

It is possible to do all of the above in just a few less steps, again using the function Solve to obtain results for simultaneous equations, as shown in the following:

eqn1 =  
      {(Subscript[V, AC]) == (Subscript[V, AB]) + (Subscript[V, BD]) + (Subscript[V, DE]) + (Subscript[V, EC]), (Subscript[V, AD]) == (Subscript[V, AB]) + (Subscript[V, BD]),  
        (Subscript[V, AE]) == (Subscript[V, AB]) + (Subscript[V, BD]) + (Subscript[V, DE]), 
        (Subscript[V, AF]) == (Subscript[V, AB]) + (Subscript[V, BD]) + (Subscript[V, DE]) + (Subscript[V, EC]) + (Subscript[V, CF]),  (Subscript[V, AB]) == 6  V,  
        (Subscript[V, BD]) == -3 V, (Subscript[V, EC]) == 4  V,  (Subscript[V, DE]) == 1  V}

Solve[eqn1, {(Subscript[V, AC]), (Subscript[V, AD]), (Subscript[V, AE]), (Subscript[V, AF])}]

The answer is given in the form of a Mathematica rule, these rules are useful in substituting answers into other expressions.  The Mathematica function N can be used to obtain the numerical values for the expressions,  and the Out[%]function  is a global object that is assigned to be the value produced on the n(^th) (last) output line.

N[%]