|
-
Nov 21st, 2009, 06:37 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Complex Numbers
How can I take the square root of complex numbers? Am I to square the complex number, and take the fourth root? How would I do that?
I also need to multiply two complex numbers.
VBNetDude - Thinking Programmatically
By Silver Seal Software
Don't forget to mark your thread as "Resolved" using the Thread Tools menu on top. And don't forget to rate the answers that help you the most! 
-
Nov 22nd, 2009, 05:04 AM
#2
Re: Complex Numbers
Squaring a complex number generally results in another complex number, so that wouldn't really help much. To understand roots of complex numbers you need to understand polar notation for complex numbers, which gets a bit involved.
Start with a complex number a + bi. This is the usual way people are introduced to complex numbers. Now try to take the square root of (a+bi): Sqrt(a+bi) = (a+bi)^(1/2) = ...uh, stuck. We need to change (a+bi) into an equivalent form that we can manipulate more easily. Polar coordinates in the complex plane are that equivalent form.
Make a 2D plane, with the x-axis being the "real" axis and the y-axis being the "imaginary" axis. Convert any complex number a + bi into (a, b) and graph it. Find the radius of the circle (centered around the origin) that the point lies on. Call that radius R. Now find the angle, measured from the positive x-axis, of the point--for instance, the complex number 0 + 2i has R = 2, angle = 90 degrees. It may be helpful to graph this point if your mental picture isn't clear (I don't know how much you've done with complex numbers). Less trivially, the point 1 + i has radius Sqrt(2) with angle 45 degrees.
You can see without much trouble that a radius and an angle uniquely determine each complex number. That is, we can convert from a+bi to [radius, angle] without losing anything, and convert back. What are the conversions?
R = Sqrt(a^2 + b^2)
angle = "theta" = atan2(b, a) = (up to a sign and ignoring some edge cases) arctan(b/a)
The first comes from the Pythagorean Theorem. The second comes from basic trigonometry; the Wikipedia article gives more specifics on atan2.
Alrighty, how does this help us take square roots? First we need a magical formula known as Euler's formula. I can derive it from extending the exponential function on the reals through analytic continuation to the complex plane and applying the Maclaurin expansion to the result... or you can take my word for it . As intro, we know, more or less, what it means to compute, say, 2^n for integer n's--you might get 4, 8, 16, 1, 1/2, 1/32, .... We can do the same for rational n's--4^(2/3) = (4^2)^(1/3) = (16)^(1/3) = something long and decimal-ish. Extending this a few more times, we can take a^x for any positive real number a and any real number x. One particular a ends up popping up through tons of advanced calculus--e, Euler's constant (he did a lot). There's a lot of significance to e (~= 2.71828183, if you were curious), but I won't go into it.
Now we can state Euler's formula. It connects the real and imaginary parts of a complex number to the radius (R) and angle (call it "theta", the traditional name) of that number, by use of trig functions and the exponential function, e^x, which has properties we can readily handle. It says, using my notation above,
a + bi = R e^(i * theta) = R*cos(theta) + i*R*sin(theta),
where theta is taken in radians instead of degrees. [There are 2*pi radians in 360 degrees; to convert from deg to rad, take deg and multiply it by pi/180.]
The importance of this formula shouldn't be ignored. We could get to the right hand side on our own--it's just a little bit of trigonometry in the complex plane. But we don't know how to get from there to anything useful for taking square roots. You might be able to find a number that, when squared, gives the right hand side, but you would largely be guessing and checking. So, we instead use the exponential function, which has very well-known properties. To continue...
Why did we bother? So that we could take a square root. Remember from the properties of rational roots that taking the square root of a number with an exponent is the same as dividing the exponent in two. That is, Sqrt(c^d) = (c^d)^(1/2) = c^(d/2). Conveniently, we can do the same to our R e^(i theta) form:
Sqrt(R e^(i theta)) = Sqrt(R)*Sqrt(e^(i theta)) = Sqrt(R) e^(i theta/2).
We seem to be stuck again, since we usually don't report numbers in polar form. But we do know that the complex number that is the square root of (R e^(i theta)) has a radius that's just Sqrt(R) and an angle that's just (theta / 2). We can use Euler's formula to convert back. Then,
Sqrt(a + bi) = Sqrt(R e^(i theta)) = Sqrt(R) e^(i theta/2) = Sqrt(R) cos(theta/2) + i Sqrt(R) sin(theta/2).
To compute this in the first place, we need to compute R and theta, but I've given formulas for that. So in all we've found that taking complex square roots is just...
1. Calculate R = Sqrt(a^2 + b^2) for input a + bi [a and b real]
2. Calculate theta = atan2(b, a)
3. Return Sqrt(R) cos(theta/2) + i Sqrt(R) sin(theta/2).
Multiplying two complex numbers is much easier. In fact, if you go far enough in math, you find that they were invented to have some of the best properties possible. If you remember multiplying real numbers, say (a+b)*(c+d), you just distribute across the *. That is,
(a+b)*(c+d) = a*(c+d) + b*(c+d) = a*c+a*d + b*c+b*d
or
(a+b)*(c+d) = (a+b)*c + (a+b)*d = a*c+b*c + a*d+b*d
Both are equal up to swapping order, which is fine. We can do the same for complex numbers (actually, they're *defined* so that the same operation works, i.e. so that we can distribute in both of the ways I showed above). So, for complex numbers a+bi and c+di [a, b, c, d real], we have simply (I'll stop writing most *'s)
(a+bi)*(c+di) = a(c+di) + (bi)(c+di) = ac+adi + bic+bidi = ac + adi+bci + bdi^2 = ac + (ad+bc)i - bd = (ac-bd) + (ad+bc)i
In short, (a+bi)*(c+di) = (ac-bd) + (ad+bc)i
I would note that multiplication of complex numbers in polar form is actually significantly easier:
R1 e^(i theta1) * R2 e^(i theta2) = (R1*R2) e^(i [theta1 + theta2])
I could definitely see someone implementing a Complex Number class that stored complex numbers in their polar form, converting only for input/output purposes. Then again, addition is pretty bad in polar form, so *meh*.
Last edited by jemidiah; Nov 22nd, 2009 at 05:22 AM.
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
-
Nov 22nd, 2009, 05:31 AM
#3
Re: Complex Numbers
Since the above got lengthy, I wanted to set off the exact answers to your questions.
(1) Square roots of complex numbers:
- Calculate R = Sqrt(a^2 + b^2) for input a + bi [a and b real]
- Calculate theta = atan2(b, a)
- Return Sqrt(R) cos(theta/2) + i Sqrt(R) sin(theta/2).
(2) Multiply complex numbers:
Code:
(a+bi)*(c+di) = (ac-bd) + (ad+bc)i
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
-
Jan 24th, 2010, 06:34 PM
#4
Thread Starter
Addicted Member
Re: Complex Numbers
Boy, this took a while for me to look at, but Thanks!
VBNetDude - Thinking Programmatically
By Silver Seal Software
Don't forget to mark your thread as "Resolved" using the Thread Tools menu on top. And don't forget to rate the answers that help you the most! 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|