(Last Mod: 09 June 2015 11:42:03 )
Chapter 1 - Integer and Modulo Division
Chapter 2 - Exponentials and Logarithms
In the age of calculators, many people have either not been sufficiently exposed to the basics of integer and modulo division or they have allowed those skills to atrophy. These concepts are central to many fields of engineering, particularly electrical engineering and computer science and their applications range from optimizing digital circuits and software programs to forming some of the core foundations of digital cryptography
It is somewhat surprising that integer and modulo division present the difficulties that they do since they are the original types of division most people learned in elementary school. They weren't given the names "integer division" or "modulo division" - it was simply "division" because it was the only type of "division" that you then knew, so there was no reason to categorize it further. Perhaps this is part of the problem - because it now has an unfamiliar name, there is an instinctive belief that it has to be something unfamiliar and more difficult than anything seen before. Hopefully this review will dispel any such notions.
If you are restricted to working with integers, then you can't say that seven divided by two is three and a half, because there is no such integer. Instead, you need to be able to express this result using only integers. One method used to do this is the same one used when you first learned division - namely indicating the result as two pieces. The first piece is the number of whole times the divisor goes into the dividend and the other piece is the remainder that is left over. Hence seven divided by two is three with a remainder of one. If you understand this, then you understand the fundamentals of both integer and modulo division.
What we will call "elementary school division" involves dividing one integer (the divisor) into another (the dividend) and expressing the result as an integer quotient and an integer remainder. The quotient is the whole number of times that the divisor goes into the dividend
Terms
Quotient r Remainder
Divisor )Dividend
Example
4 r 3
5 )23
Integer division is simply the quotient portion from Elementary School Division. It is the whole number of times that the divisor goes into the dividend. In the case of the example above:
23/5 = 4
In the C programming language, the integer division operator is the same one used for floating point division, namely the forward slash character, '/'. The compiler uses the operands to decide which type of division to use and integer division occurs anytime that both the dividend (numerator) and the divisor (denominator) are of an integer data type. It is important to understand the distinction between an operand being of an integer data type and an operand having an integer value. If a variable is declared as being one of the floating point data types, then it is still a floating point data type even it it's value happens to presently be equal to an integer - it's the data type that matters, not the value.
Another way of thinking of integer division is that the real number quotient (the "algebraic quotient) that you later learned about and are now more comfortable with (4.6 in the above example) is converted to an integer by truncating the fractional part. Truncation involves no rounding, it is simply removed. Hence 4.0001 and 4.9999 both become 4 when they are truncated.
A word of caution is in order about negative operands - namely that the result of integer division can be interpreted one of two common ways and not all languages choose the same interpretations. One common interpretation is that truncation always results in the largest integer value that is not greater than the algebraic quotient. Under this rule, 4.6 truncates to 4, but -4.6 truncated to -5. This is known as "truncation towards negative infinity." The other interpretation is known as "truncation towards zero" in which the fractional part of the algebraic quotient is discarded. Under this rule, 4.6 still truncates to 4, but now -4.6 truncates to -4. Both interpretations have advantages and disadvantages. While the C language standard.dictates the use of truncation toward zero, many C programmers (who frequently program in other languages and also have to convert programs from one language to another on occasion) will avoid integer division if there is any chance of either operand being negative.
Modulo division is simply the remainder portion from Elementary School Division. It is what is left over after the maximum number of times the divisor is subtracted from the dividend without going negative. In the case of the example above:
23%5 = 3
In the C programming language, the modulo division operator is the percent sign, '%'. Modulo division is only defined for cases where both operands are of an integer data type. Most compilers cannot compile code where this is not the case, although some might define a compiler-specific extension to the concept of modulo division since the concept does lend itself to such an extension.
As with integer division, the behavior of modulo division has no clear and consistent definition if either operand is negative. For consistency, the C language standard (and most other languages, as well) require that:
(a/b)*b + (a%b) = a
which means that the modulo operator is required to produce the result given by:
a%b = a - (a/b)*b
As can be seen, the result will be different under the two truncation rules if one of the operands is negative. As before, many C programmers therefore go to some lengths to avoid invoking modulo division under such circumstances.
Many people, because they are intimidated by integer and modular division, do not take the time to practice with it or to explore its many useful applications. Instead, they opt to "play it safe" and always use floating point variables even in places where they are either highly inefficient or even inappropriate. In addition, because they have not allowed themselves to become comfortable with integer division, they tend to be more likely to improperly invoke it when working with integer variables or constants and tend to have a much greater time tracking down these logic errors.
Furthermore, because they actively avoid using it, they frequently end up spending an enormous amount of time trying to figure out how to brute force a solution when a simple and elegant solution is directly available via integer and/or modulo division. Consider the following examples.
In C and most other high level programming languages, a two dimensional array is stored "row major" meaning that rows are stored in a contiguous block of memory and successive rows are concatenated after the preceding row. Hence each element of the array would be stored at the following offsets from the first element:
#define ROWS (3)
#define COLS (4)
int array[ROWS][COLS];
0 | 1 | 2 | 3 | |
0 | 0 | 1 | 2 | 3 |
1 | 4 | 5 | 6 | 7 |
2 | 8 | 9 | 10 | 11 |
The left column contains the row indices, the top row contains the column indices, and the rest of the boxes contain the memory offset of that element from the beginning of the array. It's pretty easy to see that the offset can be calculated from the row and column numbers according to the following formula:
offset = row*COLS + column;
But what above determining the row and column numbers given an offset? This is easily accomplished using integer and modulo division:
row = offset / COLS;
column = offset % COLS;
Imagine you have a 10x10 array and, given a specific cell location (i.e., row and column) you wanted to determine the sum of the contents of the eight surrounding cells. In addition, the cells on the left side of the array are to be considered adjacent to the cells on the right side of the array (just as if they were wrapped around a tube) and, likewise, the cells along the top of the array are adjacent to the cells on the bottom of the array. Hence the cells that surround each of the cells with a '*' are indicated by the cells with the same number in the following table:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
0 | 4 | 4 | 2 | 2 | 2 | 4 | ||||
1 | ||||||||||
2 | 1 | 1 | 1 | |||||||
3 | 3 | 1 | * | 1 | 3 | 3 | ||||
4 | 3 | 1 | 1 | 1 | 3 | * | ||||
5 | 3 | 3 | 3 | |||||||
6 | ||||||||||
7 | ||||||||||
8 | 4 | 4 | 2 | 2 | 2 | 4 | ||||
9 | * | 4 | 2 | * | 2 | 4 |
For the cell not located along any of the edges, the code is very straightforward:
#define ROWS (10)
#define COLS (10)
int array[ROWS][COLS];
int r, c;
int i, j;
int sum;
....
sum = -array[r][c]; // Initialize to the negative of the center
for(i = -1; i <= 1; i++)
for(j = -1; i <= 1; j++)
sum += array[r+i][c+j]; // Add all nine, including center
Notice the sleight-of-hand used to obtain a sum that only included the values of the surrounding neighbors without including the center cell. At first, this might seem to require some brute force code to skip over the center cell. But since adding up all nine is so easily done with a simply nested loop, we can use that and then subtract off the value of the center cell that was incorrectly included in the sum. We can do this either before or after the loop that sums all nine - we can even include it as part of the initialization segment of the first for() loop.
But the above code would not be able to deal properly with cells located along any of the edges. A brute force approach to overcome this would be to explicitly check if either of the cell's coordinates is located along an edge and then to select specific code fragments that deal with each case. But a far more elegant approach is to employ the intrinsic wraparound behavior of modulo division and change the last line of code to:
sum += array[(ROWS+r+i)%ROWS][(COLS+c+j)%COLS];
Since r could be zero and i could be negative, the numerator will occasionally be negativeo. To avoid having to even examine whether the truncation-toward-zero rule for integer division will yield correct results, we simply add ROWS to the numerator as this has no effect on the result beyond guaranteeing that the numerator is always positive. The same is, of course, true for the column index calculation as well.
Exponentials and logarithms are far more than just functions that appear in formulas that tell you to hit certain buttons on your calculator - they are extremely important and powerful mathematical tools. Like all tools, they are only useful to the extent that the person using them possess the knowledge and skill to use them effectively.
While students who have completed their first semester in calculus should have become quite proficient with these functions, experience has shown that this is frequently not the case. This appendix has been provided to touch on the key points as they relate to this course. Students are also encouraged to explore their own math texts for further and deeper coverage.
Beginning with the basic concept of exponentiation being a means of indicating repeated multiplication of a number by itself, we have:
A2 = A x A
A3 = A x A x A
An = A x A x A x .... x A (n factors of A for n>0)
We refer to the value An as being an "exponentiated number". The value A is the base of the number and the value n is the exponent. We will restrict the discussion to values of A being strictly greater than zero. For the moment, it appears we have placed this same restriction on n, but we will progressively remove that restriction.
Most of the basic properties of exponentials can be developed from this simple concept of repeated multiplication by the base.
When multiplying two exponentiated numbers that have the same base:
A3 x A2 = (A x A x A) x (A x A) = A(3+2) = A5
Hence
Am x An = A(m + n)
When dividing two exponentiated numbers that have the same base:
A3 / A2 = (A x A x A) / (A x A) = A(3-2) = A1
Hence
Am / An = A(m - n)
This last property immediately gives rise to a couple of other important concepts, namely what is meant by an exponent of zero and what is meant by a negative exponent
1 = An / An = A(n - n) = A0
Hence
A0 = 1
and
1 / An = A0 / An = A(0-n) = A-n
Hence
A-n = 1 / An
Just as important as it is to understand when and how exponents add, it is even more important to understand when they don't. In order to add exponents, the bases involved must be the same. An examination of any of the above examples should convince you that this is the case. Hence:
An x Am = A(n+m)
but
An x Bm ≠ (A x B)(n+m)
For similar reasons, the bases can only be combined if the exponents are the same. In other words:
An x Bn ≠ (A x B)n
but
An x Bm ≠ (A x B)(n+m)
It is a good exercise to verify that, if both the base and the exponents are the same, that the same result is obtained regardless of whether the bases are combined using the common exponent or the exponents are combined using the same base.
What is the base itself is an exponentiated number:
(A2)3 = (A x A) x (A x A) x (A x A) = A(2x3) = A6
Hence
(Am)n = A(m x n)
This also gives rise to an important concept, namely how exponentiation relates to the nth root of a number:
B is the nth root of A if
A = Bn
But we know the following:
B = B1
B = B(n x (1/n))
B = (Bn)(1/n)
B = A(1/n)
Hence
A(1/n) is the nth root of A
But this raises an interesting twist - we have only defined exponentiation for integral exponents but the quantity (1/n) is not an integer unless n happens to be equal to 1 - a rather uninteresting case. We therefore need to extend our concept of exponents to non-integer exponents, which we'll denote as Ax where x is any real number (positive, negative, or zero).
Let's say that A = 2.3 and x = 3.57. What does it mean to multiply 2.3 by itself 3.57 times? Based on just our definition of exponentiation being a way of indicating repeated multiplication, we can't answer this question. But what happens if we were to plot the values obtained from 2.3n for several values of n both above and below 3.57 and then connect them with a smooth curve. We now have constructed a graphical representation of a functional relationship for f(x) = 2.3x that could be used to determine, at least approximately, what 2.33.57 is. Similarly, it is possible to construct other ways of representing this functional relationship, such as with a power series, that would permit us to determine what this value is to any arbitrary degree of accuracy. Such constructions are well beyond the scope of this material - for our purposes it is sufficient to understand and accept that they exist.
Just as it was important to know what rules for addition of exponents were not valid, so to is it important to understand what multiplication of exponents does not represent. The most common mistake made in this regard is to ignore the the fact that exponentiation is not associative. In other words:
(A^m)^n ≠ A^(m^n) (the ^ operator means exponentiation)
For example, (23)2 is 82 which is 64 (the same as 26) while 2^(32) is 29 which is 512.
Virtually all modern scientific calculators permit you to compute the result of raising a nonnegative real number base to a real number exponent. Some of them will also let you use a negative real number as the base but only under the special circumstances that the exponent happens to be an integer. This function is usually indicated as xy on the keypad and requires you to enter both the base and the exponent. There happen to be two bases that are used so frequently that virtually all scientific calculators dedicate a key to each one. The first is when the base is ten, with the label usually being 10x, and the other is when the base is the "exponential constant" also known as e. This button will usually be labeled ex. The value of e, which is irrational, is approximately 2.718. There is nothing special about the behavior of exponentiation for these two specific bases - having these dedicated buttons is purely a work saving feature.
Aside: The symbol e doesn't stand for exponential, but instead honors the Swiss mathematician Leonhard Euler for his pioneering work in this and many other fields of mathematics as well as the physical sciences. However, e is not called Euler's constant - this is a different constant from a different area of mathematics.
Aside: The numerical value of e results in numerous interesting properties, any one of which could serve as its definition (with all of the other properties being consequences of that definition). Perhaps the most common defining property is that e is defined to be the positive real number greater than one such that the area above the x-axis and underneath the hyperbolic curve f(x) = 1/x and between 1 and e is exactly equal to one.
The basic concept of a logarithm is fundamentally tied to the concept of exponentiation - it is the inverse process.
We have seen above that, given a strictly positive real number x and any real number y, that the value of z determined by the relation z = xy is very well defined.
But what if, in the above relation, we know what z and x are and we are interested in finding the corresponding value of y? This is a sufficiently common quest that a specific nomenclature is used aid in communicating this relationship - we say that y is the logarithm of z to the base-x or, equivalently, that y is the base-x logarithm of z. That's really all that the word "logarithm" implies - it is the exponent to which a specific value (base) must be raised (exponentiated) in order to yield the value that we are taking the logarithm of. This relationship is generally written as:
y = logx(z)
As before, when the base in question is either ten or the exponential constant, we frequently omit the indication of the base. But if we do that, we still need to distinguish between them. Unfortunately, there are two commonly accepted ways and they are in conflict. Most students, calculators, and lower level textbooks use log(x) to mean the base-10 logarithm, also known as the "common logarithm" and ln(x) to mean the base-e logarithm, also known as the "natural logarithm". But most mathematicians and higher level texts only treat the natural log as being deserving of its own function name and use log(x) for it; when the common log is needed it is indicated explicitly just like the logarithm in any other base. Therefore, whenever you encounter the function log(x) you will need to be careful. In most situations, it will probably mean the natural log and you can generally tell from the context of its use when the common log is intended. In the remainder of this material, we will use log(x) for the natural log.
Not surprisingly, the main properties of logarithms follow directly from the properties of exponentials. For instance:
log(xy) = log( elog(x) ? elog(y) )
log(xy) = log( elog(x)+log(y) )
log(xy) = log(x) + log(y)
Similarly:
log(x/y) = log(x) - log(y)
log(1) = 0
log(xy) = y log(x)
log(1/x) = - log(x)
As with exponentiation, it is important to know what rules are NOT valid. Common mistakes include:
log(x+y) ≠ log(x) + log(y)
log(x/y) ≠ log(x) / log(y)
log(0) ≠ 0 (log(0) is undefined but is -∞ in the limit)
log(0) ≠ 1 (same comment as above)
log(-x) ≠ - log(x)
Another common point of confusion is the fact that, while logarithms can be negative, you cannot take the logarithm of a negative number. This is a direct consequence of the fact that noninteger exponents are only defined for positive bases and a positive number raised to any power, positive or negative, is a positive number.
Most scientific calculators have dedicated keys for both the natural log and the common log. However, unlike exponentiation to an arbitrary base, few calculators directly support taking a logarithm in an arbitrary base. Fortunately, if we understand fundamentally what a logarithm is, this is not much of a hindrance. To find the base-b logarithm of x, we only need to recall that, by definition, this means:
x = by
where y is the value we are trying to find.
By taking the logarithms of both side (to any base, as long as we use the same base on both sides), we obtain:
log(x) = y log(b)
Solving for our unknown immediately yields:
y = log(x) / log(b)
Let's assume that the only exponentiation/logarithm functions that our calculator supports are base-e (or any other single base). How could we compute the value of xy under those conditions?
Many people immediately want to multiply x by itself y times but, remember, we moved past that limited concept of exponentiation almost immediately. The value of y could be negative and/or it could be nonintegral. Such a repeated multiplication approach will not work under those conditions. But following back on our knowledge of how exponentials and logarithms are related provides the key for a very simple solution.
We are looking for the value z such that:
z = xy
Taking the logarithms of both sides yields:
ln(z) = y ln(x)
We can compute the right hand side of the equation and, if we know the logarithm of z, then we only have to exponentiate the base in which we took the logarithm by that logarithm to recover z:
z = ey ln(x)
If given a specific (positive) integer, it is a simple matter to count the number of digits. But what if we want a generic way to determine the number of digits in a value without knowing the specific number in advance. Or perhaps we want to know how many digits are required to represent a value in a number base other than the one it is written down in. We can get at the means of doing this by noting the relationship between the number of digits and the logarithm of the value in question. Consider the following base-10 example:
log10(100) <= log10(any three digit integer) < log10(1000)
2.0 <= log10(any three digit value) < 3.0
So if we take the integer portion of the base-10 log of a number, we will get a result that is one less than the number of digits in the number (when written in base-10). The nearest integer less than (or equal to) the number is frequently called the floor of the number and, conversely, the nearest integer greater than (or equal to) the number is called the ceiling of the number. In C, the functions that perform these operations are floor() and ceil() respectively. The function that returns the base-10 logarithm if log10(). So a C statement that would calculate the number of digits in a base-10 positive integer is:
digits = floor(log10(number)) + 1;
It might appear that we could simply use the ceil() function and avoid having to add one. Look carefully at the relationship and see if you can explain why this isn't so.
One of the glaring deficiencies of the set of real numbers is the inability to represent the exponentials and logarithms of negative numbers. That's an entire half of the number line for which these important and powerful functions have difficulties. We might actually be satisfied to live with this situation, just as we live with the problems associated with division by zero, if these concepts fundamentally never had meaning for any negative arguments. But while (-2.1)4.1 is undefined, (-2.1)4.0 is. And while (-27)1/2 is undefined, (-27)1/3 is. This speckling of defined values is highly troubling and provides a strong impetus for extending the set of real numbers to a broader set that doesn't exhibit this troublesome behavior.
So what would it take to be able to overcome these shortcomings? Noting the fact that we have no problem for positive values, we can use the rules of exponents to focus our attention on what the key shortcoming of the set of real numbers is:
z = xy for (x>0)
is well defined for any real number exponent y.
z = (-x)y
is only well defined for integers values of y and selected fractions (such as 1/3).
Using the power of exponents, this can be written as:
z = (-1)y * xy
If we can define the value of -1 raised to any real exponent, we are done. Let's call this quantity w.
w = (-1)y
ln(w) = y ln(-1)
So, in order to make the exponential function (and, by direct extension, the logarithmic function) defined for all real arguments, it turns out that we only have to define one new quantity - namely the natural logarithm of negative one. While we can't write down what its "value" is in terms of real numbers - since we knew from the start that it wasn't part of the set of real numbers - we can describe its properties with respect to real numbers.
The first properly is obvious and the second property is required by the definition of the logarithm function.
Just as we do with other useful constants, such as the ratio of the circumference of a plane circle to its diameter (i.e., π) and the exponential constant itself (i.e., e), we can assign a symbol to represent this constant value and use that symbol in equations. We then learn how that constant behaves with respect to various operations, just as we learned how π relates to the area of a circle and how to take the derivative of e raised to a variable.
It turns out that, while we could use ln(-1) as our single constant value outside the set of real numbers, we actually use a different value. The distinction is one of convenience only, just as π could have been defined as the ratio of the circumference to the radius of a circle.
It turns out to be extremely convenient to define our one fundamental non-real number to be that value that, when squared, yields a value of negative one. The symbol we have decided to use for this particular constant is a lower case i (electrical engineers generally uses a lower case j since a lower case i represents a time varying electrical current). The defining relationship for this constant is therefore:
i2 = -1
This means that
i = (-1)1/2
The relationship between i and ln(-1) is therefore simply
ln(-1) = 2 ln(i)
As we will see later (meaning that it doesn't matter if you understand it now), this reduces to
ln(-1) = iπ
The square root of negative one (i.e., i) is called the "imaginary unit" to emphasize that it is not part of the set of "real numbers". An "imaginary number" is then the product of a real number and the imaginary unit.
In many respects, the use of the words "imaginary" and "real" is unfortunate since all numbers are abstract quantities and they only have relationships to physical things to the degree that we map those relationships. For instance, a negative force represents a downward force as opposed to an upward force only if we choose to interpret it as such. Several recommendations to use less connotative terms have been proposed, but these names are so engrained in the mathematical and engineering world that it is unlikely (but not impossible) that they will ever be supplanted.
But just as imaginary numbers do not exist within the set of real numbers, so too do real numbers not exist within the set of imaginary numbers. Certain operations jump the bounds in well defined ways - for instance the product or quotient of two imaginary numbers is a real number while the square root of a negative real number is an imaginary number. But other operations result in values that are not contained in either set. For instance, the simple sum of a real number and an imaginary number is not in either set. So we need to define yet another set of numbers that encompasses both real and imaginary numbers as subsets -- just as the real numbers include rational and irrational numbers and rational numbers include integers as a subset. This new set is the set of "complex numbers".
Taking our cue from the addition operation, we can define our new set of numbers to be those numbers that can be expressed as the sum of a real number and an imaginary number:
z = a + ib
Where a and b are real numbers and i is the imaginary constant.
As we shall soon discover, a complex number can be expressed in a number of ways. The form shown above is usually referred to as the rectangular or component form. It is also referred to as the Cartesian form, although this is a bit of a misnomer.
This set of numbers is called the "complex numbers" and it can be obviously seen that the real numbers is simply the subset of complex numbers for which b (the imaginary component of z) is zero and the imaginary numbers is simply the subset for which a (the real component of z) is zero.
Two functions that come to mind immediately are:
If z = a + ib then
Re(z) = a
Im(z) = b
These are known as the "real component of z" and the "imaginary component of z", respectively.
Likewise, any complex number can be written in the form:
z = Re(z) + iIm(z)
This last expression might appear to be a bit circular, but what it emphasizes is that, in general, a complex number has a real component and an imaginary component, both of which are real numbers, and one way of expressing the number as a whole is as the sum of the two components provided that the imaginary component is multiplied by the imaginary constant.
If our new set of numbers is to be meaningful, it must adhere to all of the
operations already defined for the reals and produce the same results when the
imaginary component of z is zero. Hence
Given two complex numbers w and v:
w + v = ( Re(w) + iIm(w) ) + ( Re(v) + iIm(v) )
w + v = ( Re(w) + Re(v) ) + i( Im(w) + Im(v) )
w - v = ( Re(w) - iIm(w) ) + ( Re(v) - iIm(v) )
w - v = ( Re(w) - Re(v) ) + i( Im(w) - Im(v) )
w ? v = ( Re(w) ? Re(v) ) + ( iIm(w) ? iIm(v) ) + ( Re(w)?iIm(v) ) + ( Re(v)?iIm(w) )
w ? v = ( Re(w)?Re(v) - Im(w)?Im(v) ) + i( Re(w)?Im(v) + Re(v)?Im(w) )
w / v = ( Re(w) + iIm(w) ) / ( Re(v) +i Im(v) )
w / v = [( Re(w) + iIm(w) )( Re(v) - iIm(v) )] / [( Re(v) + iIm(v) )( Re(v) - iIm(v) ) ]
w / v = [( Re(w) + iIm(w) )( Re(v) - iIm(v) )] / [ ( Re(v) )2 + ( Im(v) )2 ]
w / v = [( Re(w)?Re(v)+Im(w)?Im(v) ) + i( Re(v)?Im(w)-Re(w)?Im(v) )] / [ Re(v)2 + Im(v)2 ]
To go from the second line to the third line of the above derivation, we multiplied both the numerator and the denominator by the "complex conjugate" of the original denominator. The complex conjugate finds many uses and so is worthy of its own operator and an exploration of its basic properties:
z* = Re(z) - iIm(z)
The definition of a "complex conjugate" is, like so many others, simply to provide a shorthand notation for a common operation - namely doing nothing more than taking the additive inverse of the imaginary component while leaving the real component unchanged. Notice that the common notation for this operation is to use a superscripted asterisk.
Some of the properties of a number combined with its complex conjugate are:
z + z* = 2 Re(z)
z - z* = -i2 Im(z)
z z* = ( Re(z) )2 + ( Im(z) )2 = ( Mag(z) )2
z / z* = 2 Arg(z)
Inverting these expressions, we have:
Re(z) = ( 1/2 ) ( z + z* )
Im(z) = ( i/2 ) ( z - z* )
Mag(z)2 = z z*
Arg(z) = ( 1/2 ) ( z / z*)
Some other useful relationships are:
Re(z*) = Re(z)
Im(z*) = -Im(z)
Mag(z*) = Mag(z)
Arg(z*) = -Arg(z)
The Mag(z) and Arg(z) functions are described later.
A Taylor series expansion of the exponential function shows that:
ex = 1 + x + x2/2! + x3/3! + x4/4! + ..... xn/n! + .....
In fact, this is one of the ways that exponential constant could have been defined since any other base will have more complicated coefficients for each term.
Similarly, Taylor series expansions for sin(x) and cos(x) reveal that:
cos(x) = 1 - x2/2! + x4/4! + ..... (-1)nx2n/2n! + .....
sin(x) = x - x3/3! + x5/5! + ..... (-1)nx(2n+1)/(2n+1)! + .....
Using the above expansions we quickly discover the following relationship:
eix = cos(x) + i sin(x)
The above relationship, known as Euler's formula, gives us a geometric way of representing a complex number. In a standard x-y plane, where the x-axis is the horizontal axis and the y-axis is the vertical axis, then a two-dimensional vector <x,y> has a magnitude:
z = x x + y y
where x and y are unit vectors in the positive x- and y- directions respectively.
Magnitude(z) = sqrt( x2 + y2 )
and an angle relative to the x-axis of:
Angle(z) = arctan(y/x)
where the arctan() function takes into account the sign of both x and y making it a full four-quadrant inverse tangent function.
Expressing our vector as the sum of an x- and a y-component is called the Rectangular or Cartesian form. Another means of expressing our vector is the Polar form, which generally looks something like:
z = r / theta
where r is the magnitude of the vector and theta is the angle between the vector and the positive x-axis.
We the immediately get the relationships between the Cartesian and Polar forms:
z = r / theta = r cos(theta) x + r sin(theta) y
z = x x + y y = sqrt( x2 + y2 ) / Angle(z)
This bears such a striking resemblance to our complex exponential that we define a variant of the x-y plane, known as the Complex Plane (also known as the Argand Plane) where the horizontal axis represents the real component and the vertical axis represents the imaginary component. From this definition, the magnitude and complex argument functions follow directly as follows:
The complex magnitude of a point within the complex plane is the absolute magnitude of the distance from the origin of the complex plane to that point. Hence:
Mag(z) = sqrt( Re(z)2 + Im(z)2 )
The complext argument of a point within the complex plane is the angle between the positive real axis of the complex plane and the line connecting the origin to that point. Unless indicated otherwise, the units are radians. Hence:
Arg(z) = arctan( Im(z) / Re(z) )
z = Re(z) + iIm(z)
z = Mag(z) / Arg(z)
z = Mag(z) e i Arg(z)
The relationship between the polar and exponential forms of a complex number is obvious. Applying Euler's Rule to the exponential form immediately gives us the rectangular form:
z = Mag(z) e i Arg(z)
z = Mag(z) [cos(Arg(z)) + i sin(Arg(z)]
z = Mag(z) cos(Arg(z) + i Mag(z) sin(Arg(z)
The exponential form also gives us very compact and powerful means of performing multiplication and division of complex numbers as well as a means of performing logarithmic and exponential operations on complex numbers.
w ? v = (Mag(w) ? Mag(v)) / ( Arg(w) + Arg(v) )
w / v = ( Mag(w) / Mag(v) ) / ( Arg(w) - Arg(v) )
Since any complex number can be written in exponential form, computing the logarithm of a complex number because very straightforward:
z = Mag(z) e i Arg(z)
ln(z) = ln( Mag(z) ) + ln( e i Arg(z) )
ln(z) = ln( Mag(z) ) + i Arg(z)
Recall that earlier we saw that i and ln(-1) were related by π. This relationship becomes obvious when -1 is written in exponential form:
-1 = eiπ
ln(-1) = iπ
Another result also becomes obvious:
eiπ + 1 = 0
This is known as the Beautiful Theorem because it relates the five fundamental constants of mathemantics, 0, 1, e, i, and π, to each other in an extremely simple fashion.
wv = [ Mag(w) e i Arg(w) ] ( Re(v) + i Im(v) )
The expansion of the above expression is a bit messy by very straightforward yielding the following:
Mag(wv) = Mag(w)Re(b) ? e -Im(v)?Arg(w)
Arg(wv) = Im(v) ? ln(Mag(w)) + Re(v) ? Arg(v)
If w and v are both real, then Mag(w) = w and Re(v) = v while Arg(w) = Im(v) = 0. Under these conditions, the above relations reduce immediately to:
Mag(wv) = Mag(w)Re(b) ? e -0?0 = wv
Arg(wv) = 0 ? ln(Mag(w)) + Re(v) ? 0 = 0