Previous: 15.2 Complex Numbers
Up: 15.2 Complex Numbers
Next: 15.2.2 Roots of Algebraic Equations
Previous Page: 15.2 Complex Numbers
Next Page: 15.2.2 Roots of Algebraic Equations
It is also possible to represent a point on a two dimensional plane in terms of polar coordinates. Polar coordinates are given in terms of:
Thus, a complex number, represented by the pair in polar
coordinates, can be written in rectangular coordinates as:
Thus,
the real and imaginary parts, and
, in terms of
and
are:
Since,
can also be written as:
As we shall soon see, this exponential form is convenient for multiplication
and division.
Given rectangular coordinates and
, we can determine
and
as follows. We know:
so,
Observe that the length, , is the
square root of
.
The length
is called the magnitude of the vector, and
the angle
is called the angle or phase angle of the vector.
As we have seen, addition and subtraction of complex numbers is easy to perform in rectangular coordinates. On the other hand, multiplication and division of two complex numbers in rectangular coordinates is not so easy. Conversely, it is easy to perform multiplication and division in polar coordinates. Given that two numbers are:
It is easy to see that:
From this analysis,
we can implement complex numbers in polar coordinates as
shown in Figure 15.11 together with
functions for
multiplication and division in polar coordinates.
It is also important to be able to convert
back and forth between rectangular and
polar coordinates. It is easy to write the necessary conversion routines to
convert complex numbers in rectangular coordinates to polar coordinates, and
vice versa - they are shown in Figure 15.12.
The function
polar_to_rect() is quite straight forward;
rect_to_polar() uses the
arc tangent function atan() defined in the standard library.
This function
returns an angle in the range to
,
thus we need to adjust the angle when
the real part is zero and when it is negative.
If the real part is zero, the
angle is
if the imaginary part is positive,
and
if it is negative.
Next, if the real part is negative, the angle must be incremented by
.
Since we use many standard library trigonometric functions, the file
math.h
must be included at the head of computil.c and we must link
the math library when the program is compiled.
These functions provide a useful library for processing with complex numbers. Let us now make use of them in two application programs.