Previous: 15.2.2 Roots of Algebraic Equations
Up: 15.2 Complex Numbers
Previous Page: 15.2.2 Roots of Algebraic Equations
Next Page: 15.3 Integrals
Another important application of complex numbers is in computing impedances of
electrical circuits.
The basic components of such circuits are resistors,
inductors, and capacitors as shown in Figure 15.17.
These devices can be connected in series or parallel to make
more complex circuits as shown in Figure 15.18 where each
component has an impedance, Z.
In general, the impedance is modeled as a complex quantity depending on
their value and the value of the
angular frequency, , in radians per second, of the electrical
signal for which the impedance is to be computed.
The impedance of a resistor of R ohms is simply R,
that of an inductor of L henrys is ,
and that of a capacitor of C farads is
.
The impedance of a
series or a parallel combination of sub-circuits is defined in terms of the
individual impedances of the sub-circuits.
The impedance of a series combination of impedances, Z1 and Z2
is the sum of the individual impedances, i.e. .
The impedance of a parallel combination of
impedances Z1 and Z2 is the reciprocal of the
reciprocal sum of the individual impedances:
Let us first write a set of circuit utility functions to determine:
The function comp_imped()
determines the impedance of a basic component whose element type
(a character) and value are
passed together with the value of the angular frequency
(we will call w).
The code is shown in Figure 15.19.
The only point to note here is that if w * C is zero, the impedance is
infinite. It is not possible to handle an infinite value in computers, so some
garbage value is returned. The calling program must handle a zero value of
as a special case.
Next, we implement the functions that compute the series
and parallel combination of impedances shown in Figure 15.20.
The function series() merely returns the sum of the two impedances. The function parallel() uses polar coordinates to compute the reciprocals of impedances. It is much easier to compute the reciprocal of a complex number in polar coordinates than in rectangular coordinates; whereas complex numbers are easier to sum in rectangular coordinates. Conversion routines are used to convert polar to rectangular, and vice versa.
*
We are now ready to implement a program to compute the impedance of an
electrical circuit. Let us assume a circuit which is a series combination of
two sub-circuits as shown in Figure 15.21.
The first sub-circuit is a series
combination of resistor R1 and inductor L.
The second sub-circuit is a
parallel combination of resistor R2 and capacitor C.
Figure 15.22 shows the program to
find the impedances of this circuit for different sets of values of
, R2, L, C, and .
The program reads a set of values for R1, R2, L,
, and . It calls series()
to compute the impedance z1 of R1 and L in series.
If
is zero, the
impedance of the capacitor is infinite; so the impedance of the parallel
combination, z2, is just the impedance of R2.
Otherwise, parallel() is called
to compute the impedance z2 of R2 and C in parallel.
In all cases, comp_imped() is used to
compute the impedances of the basic components and series() is called to
compute the impedance of z1 and z2 in series.
The values of these impedances
are printed by print_rect(). A sample run is shown below:
The second circuit values represent a circuit near resonance. Its impedance is almost purely resistive, since the imaginary part is close to zero.