Complex numbers in polar form: Euler's formula, De Moivre and roots of unity
Ten problems on complex numbers in polar form: the modulus and argument of −1 + √3i and −2 − 2i, polar back to rectangular, a product and a quotient that give cos(5π/12) exactly, (1 + i)^10 and (1 − √3i)^6 by De Moivre, the three cube roots of 8i, the fifth roots of unity and cos(2π/5), the triple-angle formulas for cos 3θ and sin 3θ, the integral of e^x cos x from the real part of e^((1+i)x), a rotation about a point other than the origin, and the rotary position embeddings that make an attention score depend only on the distance between positions, with worked solutions and the mistakes of taking arctan(b/a) in the wrong quadrant, adding the moduli of a product, keeping only one of the n roots, raising the real and imaginary parts to a power separately and taking the modulus of a sum as the sum of the moduli.
Before you start
A complex number a+bi is a point in the plane, and like any point it can be given by its distance from the origin and its angle instead of by its coordinates. In that polar form, ,z=reiθ, the hard operations become easy: multiplying multiplies the distances and adds the angles, a power is a power of the distance and a multiple of the angle, and the n-th roots of a number sit evenly around a circle. Euler's formula eiθ=cosθ+isinθ is what connects the two forms, and it turns trigonometry into algebra: triple-angle formulas, sums of cosines and integrals of excosx all come out of the rules for exponents. The same rotations are inside the discrete Fourier transform, the solutions of oscillating differential equations and the rotary position embeddings of transformer models. These ten problems convert between the forms, multiply, take powers and roots, and use the result.
Polar form.,z=a+bi=r(cosθ+isinθ)=reiθ, with modulus r=∣z∣=a2+b2 and argument .θ. Angles on this page are in radians.
The argument needs the quadrant.tanθ=b/a does not decide :θ:arctan(b/a) lies in ,(−π/2,π/2), so when a<0 add or subtract .π. Always check that cosθ has the sign of a and sinθ the sign of .b.
Euler's formula.,eiθ=cosθ+isinθ, so ,∣eiθ∣=1,eiπ=−1 and .ei(θ+2π)=eiθ. Conversely cosθ=21(eiθ+e−iθ) and .sinθ=2i1(eiθ−e−iθ).
Products and quotients.r1eiθ1⋅r2eiθ2=r1r2ei(θ1+θ2) and :r2eiθ2r1eiθ1=r2r1ei(θ1−θ2): moduli multiply, arguments add.
De Moivre.,(reiθ)n=rneinθ, that is .(cosθ+isinθ)n=cosnθ+isinnθ.
Roots. The equation zn=reiθ with r>0 has exactly n solutions, zk=r1/nei(θ+2πk)/n for ,k=0,1,…,n−1, spaced 2π/n apart on a circle. The n-th roots of unity e2πik/n add up to 0 for .n≥2.
Rotation. Multiplying by eiα rotates a point by α counterclockwise about the origin; zˉ reflects it in the real axis, and .zzˉ=∣z∣2.
Write z=−1+3i and w=−2−2i in polar form ,reiθ, with .−π<θ≤π.
·
Write ,4e5πi/6,3e−iπ/2 and eiπ+1 in the form .a+bi.
··
Let z=1+i and .w=3+i. Find zw and z/w in polar form, then multiply zw out in rectangular form and use it to find cos125π exactly.
··
Compute (1+i)10 and (1−3i)6 with De Moivre's theorem.
··
Find all solutions of z3=8i in polar and rectangular form, and check that they add up to .0.
··
Let .ω=e2πi/5. Show that ,1+ω+ω2+ω3+ω4=0, and use its real part to find cos52π exactly.
··
Expand (cosθ+isinθ)3 and use De Moivre's theorem to write cos3θ in terms of cosθ and sin3θ in terms of .sinθ. Check both at .θ=π/9.
···
Compute ∫0πexcosxdx and ∫0πexsinxdx at once, as the real and imaginary parts of .∫0πe(1+i)xdx.
··
Rotate the point P=(4,2) by 60∘ counterclockwise about the point .C=(1,1). Check that its distance from C does not change.
···
Rotary position embeddings (RoPE) treat each pair of coordinates of a query or key as a complex number and rotate the vector at position m by the angle .mθ. Take the pair ,q=(1,2), the pair k=(3,−1) and .θ=π/6. Show that the score Re(qmkn) between the rotated query qm=qeimθ and the rotated key kn=keinθ is the ordinary dot product when ,m=n, and find it for (m,n)=(5,2) and .(8,5).
Answers
z=2e2πi/3 and w=22e−3πi/4
,−23+2i≈−3.464+2i,,−3i, and eiπ+1=0
,zw=22e5πi/12,,z/w=22eiπ/12, and cos125π=223−1=46−2≈0.2588
(1+i)10=32i and (1−3i)6=64
,z=3+i,,−3+i,;−2i; their sum is 0
cos52π=45−1≈0.3090
cos3θ=4cos3θ−3cosθ and sin3θ=3sinθ−4sin3θ
∫0πexcosxdx=−2eπ+1≈−12.07 and ∫0πexsinxdx=2eπ+1≈12.07
P′=(25−3,23+33)≈(1.634,4.098)
The score is Re((1+7i)i)=Re(−7+i)=−7 for both (5,2) and (8,5)
Worked solutions
Problem 1
Write z=−1+3i and w=−2−2i in polar form ,reiθ, with .−π<θ≤π.
∣z∣=1+3=2The distance from the origin to .(−1,3).
,cosθ=−21,sinθ=23Divide the coordinates by .r. Cosine negative and sine positive: the second quadrant.
θ=32πThe reference angle is ;π/3; in the second quadrant that is .π−π/3.
,∣w∣=4+4=22, and θ=−43πBoth coordinates negative: the third quadrant, reference angle ,π/4, measured clockwise from the positive real axis.
z=2e2πi/3 and w=22e−3πi/4A calculator's arctan(3/(−1))=−π/3 points the opposite way, into the fourth quadrant (Mistake 1). The angle 5π/4 for w is also right; it is the same direction outside the range asked for.
Problem 2
Write ,4e5πi/6,3e−iπ/2 and eiπ+1 in the form .a+bi.
4e5πi/6=4(cos65π+isin65π)Euler's formula.
=4(−23+21i)=−23+2i5π/6 is in the second quadrant, reference angle .π/6.
3e−iπ/2=3(0−i)=−3iA quarter turn clockwise from the positive real axis lands on the negative imaginary axis.
eiπ=cosπ+isinπ=−1Half a turn.
,−23+2i≈−3.464+2i,,−3i, and eiπ+1=0Check the first: .(23)2+22=16=42.
Problem 3
Let z=1+i and .w=3+i. Find zw and z/w in polar form, then multiply zw out in rectangular form and use it to find cos125π exactly.
,z=2eiπ/4,w=2eiπ/6Both are in the first quadrant: arctan1=π/4 and .arctan(1/3)=π/6.
zw=22e5πi/12Multiply the moduli, ,2⋅2, and add the arguments, .π/4+π/6=5π/12.
z/w=22eiπ/12Divide the moduli and subtract the arguments: .π/4−π/6=π/12.
zw=(3−1)+(3+1)iDirectly: .3+i+3i+i2.
,zw=22e5πi/12,,z/w=22eiπ/12, and cos125π=223−1=46−2≈0.2588The real part of zw is ;22cos125π; divide by .22. Adding the moduli instead gives ,2+2≈3.414, not 22≈2.828 (Mistake 2).
Problem 4
Compute (1+i)10 and (1−3i)6 with De Moivre's theorem.
1+i=2eiπ/4Modulus ,2, first quadrant.
(1+i)10=(2)10e10πi/4=32e5πi/2Raise the modulus to the power, multiply the angle by it.
e5πi/2=eiπ/2=iSubtract a full turn, .2π.
,1−3i=2e−iπ/3, so (1−3i)6=64e−2πiFourth quadrant, reference angle ;π/3;.26=64.
(1+i)10=32i and (1−3i)6=64.e−2πi=1. Check the first by squaring: ,(1+i)2=2i, and .(2i)5=32i5=32i. Taking 110+i10=0 instead is Mistake 4.
Problem 5
Find all solutions of z3=8i in polar and rectangular form, and check that they add up to .0.
8i=8eiπ/2On the positive imaginary axis.
zk=2ei(π/2+2πk)/3 for k=0,1,2The cube root of the modulus, and the argument divided by 3 after adding .2πk.
z0=2eiπ/6=3+i:π/6:2cos6π=3 and .2sin6π=1.
z1=2e5πi/6=−3+i and z2=2e3πi/2=−2iEach root is 2π/3 further around the circle of radius .2.
,z=3+i,,−3+i,;−2i; their sum is 0The real parts cancel and .1+1−2=0. Check one: .(−2i)3=−8i3=8i. Stopping at z0 loses two of the three roots (Mistake 3).
Problem 6
Let .ω=e2πi/5. Show that ,1+ω+ω2+ω3+ω4=0, and use its real part to find cos52π exactly.
(ω−1)(1+ω+⋯+ω4)=ω5−1=0The telescoping product, and .ω5=e2πi=1.
1+ω+⋯+ω4=0,ω=1, so the other factor is .0.
1+2cos52π+2cos54π=0Real parts: ω4=ωˉ and ω3=ω2 pair up, and each pair contributes twice a cosine.
With :c=cos52π:,1+2c+2(2c2−1)=0, so 4c2+2c−1=0The double-angle formula .cos2x=2cos2x−1.
cos52π=45−1≈0.3090The positive root of the quadratic, since .2π/5<π/2. The five roots each have modulus ,1, yet their sum has modulus ,0, not 5 (Mistake 5).
Problem 7
Expand (cosθ+isinθ)3 and use De Moivre's theorem to write cos3θ in terms of cosθ and sin3θ in terms of .sinθ. Check both at .θ=π/9.
(c+is)3=c3+3ic2s−3cs2−is3The binomial expansion with ,c=cosθ,;s=sinθ;i2=−1 and .i3=−i.
cos3θ=c3−3cs2De Moivre: the left side is .cos3θ+isin3θ. Match real parts.
cos3θ=4c3−3cReplace s2 by .1−c2.
sin3θ=3c2s−s3=3s−4s3Match imaginary parts and replace c2 by .1−s2.
cos3θ=4cos3θ−3cosθ and sin3θ=3sinθ−4sin3θAt ,θ=π/9,cosθ≈0.9397 gives ,4(0.8298)−2.8191≈0.5=cos3π, and sinθ≈0.3420 gives .≈0.8660=sin3π.
Problem 8
Compute ∫0πexcosxdx and ∫0πexsinxdx at once, as the real and imaginary parts of .∫0πe(1+i)xdx.
e(1+i)x=excosx+iexsinxEuler's formula, times the real factor .ex.
∫0πe(1+i)xdx=1+ie(1+i)π−1The exponential rule works with a complex constant: the derivative of ekx is .kekx.
e(1+i)π=eπeiπ=−eπSo the numerator is .−(eπ+1).
1+i1=21−iMultiply top and bottom by the conjugate: .(1+i)(1−i)=2.
∫0πexcosxdx=−2eπ+1≈−12.07 and ∫0πexsinxdx=2eπ+1≈12.07−(eπ+1)21−i has real part −2eπ+1 and imaginary part .+2eπ+1. Integrating by parts twice gives the same, with more work.
Problem 9
Rotate the point P=(4,2) by 60∘ counterclockwise about the point .C=(1,1). Check that its distance from C does not change.
P−C=3+iMove C to the origin first: rotation by eiα only turns about .0.
P′=(25−3,23+33)≈(1.634,4.098)Its distance from C is ∣3+i∣=10 before and after, since :∣eiπ/3∣=1:.0.6342+3.0982≈10. Rotating 4+2i itself would turn it about the origin instead.
Problem 10
Rotary position embeddings (RoPE) treat each pair of coordinates of a query or key as a complex number and rotate the vector at position m by the angle .mθ. Take the pair ,q=(1,2), the pair k=(3,−1) and .θ=π/6. Show that the score Re(qmkn) between the rotated query qm=qeimθ and the rotated key kn=keinθ is the ordinary dot product when ,m=n, and find it for (m,n)=(5,2) and .(8,5).
Re(zwˉ)=ac+bd for ,z=a+bi,w=c+di(a+bi)(c−di) has real part :ac+bd: the dot product of the two pairs.
qmkn=qkˉei(m−n)θ,einθ=e−inθ, so the two rotations combine into one by the difference of the angles.
qkˉ=(1+2i)(3+i)=1+7i.3+i+6i+2i2. With m=n the score is .Re(1+7i)=1=1⋅3+2⋅(−1).
(m−n)θ=3⋅6π=2π for both pairs.5−2=8−5=3.
The score is Re((1+7i)i)=Re(−7+i)=−7 for both (5,2) and (8,5)It depends only on the offset ,m−n, not on where the pair sits in the sequence, which is why RoPE encodes relative position. The rotations keep ∣q∣=5 and ,∣k∣=10, so the norms are unchanged.
Where this goes wrong
1. arctan(b/a) in the wrong quadrant
The argument satisfies ,tanθ=b/a, so the inverse tangent looks like it gives the angle directly.
,z=−1+3i,∣z∣=2Right so far: Problem 1.
“.θ=arctan−13.”arctan only returns angles in ,(−π/2,π/2), the right half of the plane, but z has a negative real part.
z=2e−iπ/3,2e−iπ/3=1−3i, which is ,−z, the point directly opposite. Adding π gives the right angle, ,−π/3+π=2π/3, and .2e2πi/3=−1+3i.
2. Adding the moduli of a product
Arguments add when complex numbers are multiplied, and it is easy to add the moduli along with them.
,z=2eiπ/4,,w=2eiπ/6, and the argument of zw is 5π/12Right so far: Problem 3.
“The moduli add too.”Only the exponents add: .eiθ1eiθ2=ei(θ1+θ2). The moduli are ordinary positive factors in front, and they multiply.
,zw=(2+2)e5πi/12, modulus ≈3.414zw=(3−1)+(3+1)i has modulus .(3−1)2+(3+1)2=8=22≈2.828.
3. Only one of the n roots
A calculator or a single application of the root formula returns one cube root, and it looks like the answer.
8i=8eiπ/2Right so far: Problem 5.
“,z=81/3eiπ/6, and that is the solution.”The argument of 8i is also π/2+2π and ;π/2+4π; divided by 3 these give different directions.
z3=8i has the one solution 3+iA cubic has three roots: ,3+i,−3+i and ,−2i, spaced 2π/3 apart. Adding 2πk for k=3 or more only repeats them.
4. Raising the real and imaginary parts to the power separately
Powers of a product split into powers of the factors, and the same move gets applied to a sum.
(1+i)10Right so far: Problem 4.
“.(1+i)10=110+i10.”(a+b)n is not :an+bn: the binomial expansion has all the cross terms. Powers split over products, which is why polar form helps.
(1+i)10=1+(−1)=0The right value is :32i:,∣1+i∣10=32, not ,0, and no power of a nonzero number is .0.
5. The modulus of a sum taken as the sum of the moduli
The modulus of a product is the product of the moduli, and the same rule seems to hold for sums.
∣ωk∣=1 for each of the fifth roots of unityRight so far: Problem 6.
“.∣1+ω+ω2+ω3+ω4∣=1+1+1+1+1.”That is only an upper bound, the triangle inequality. It is an equality only when all the nonzero terms point in the same direction.
The sum has modulus 5The five roots point in five evenly spaced directions and cancel: the sum is .0. Likewise ,∣1+i∣+∣3+i∣≈3.414, but .∣(1+3)+2i∣≈3.386.