Complex Numbers and Trigonometry
Thomas J. Sargent and John Stachurski March 9, 2021
1 Contents
β’ Overview2
β’ De Moivreβs Theorem 3
β’ Applications of de Moivreβs Theorem4
2 Overview
This lecture introduces some elementary mathematics and trigonometry.
Useful and interesting in its own right, these concepts reap substantial rewards when studying dynamics generated by linear difference equations or linear differential equations.
For example, these tools are keys to understanding outcomes attained by Paul Samuelson (1939) [1] in his classic paper on interactions between the investment accelerator and the Keynesian consumption function, our topic in the lecture Samuelson Multiplier Accelerator.
In addition to providing foundations for Samuelsonβs work and extensions of it, this lec- ture can be read as a stand-alone quick reminder of key results from elementary high school trigonometry.
So letβs dive in.
2.1 Complex Numbers
A complex number has a real part π₯ and a purely imaginary part π¦.
The Euclidean, polar, and trigonometric forms of a complex number π§ are:
π§ = π₯ + ππ¦ = ππππ= π(cos π + π sin π) The second equality above is known as Eulerβs formula
β’ Euler contributed many other formulas too!
The complex conjugate Μπ§ of π§ is defined as
Μ
π§ = π₯ β ππ¦ = ππβππ= π(cos π β π sin π) The value π₯ is the real part of π§ and π¦ is the imaginary part of π§.
The symbol |π§| =β
Μ
π§ β π§ = π represents the modulus of π§.
The value π is the Euclidean distance of vector (π₯, π¦) from the origin:
π = |π§| = βπ₯2+ π¦2 The value π is the angle of (π₯, π¦) with respect to the real axis.
Evidently, the tangent of π is (π₯π¦).
Therefore,
π = tanβ1(π¦ π₯) Three elementary trigonometric functions are
cos π = π₯
π = πππ+ πβππ
2 , sin π = π¦
π = πππβ πβππ
2π , tan π = π¦ π₯ Weβll need the following imports:
In [1]: import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline from sympy import *
2.2 An Example
Consider the complex number π§ = 1 +β 3π.
For π§ = 1 +β
3π, π₯ = 1, π¦ =β 3.
It follows that π = 2 and π = tanβ1(β
3) = π3 = 60π.
Letβs use Python to plot the trigonometric form of the complex number π§ = 1 +β 3π.
In [2]: # Abbreviate useful values and functions Ο = np.pi
zeros = np.zeros ones = np.ones
# Set parameters r = 2
ΞΈ = Ο/3
x = r * np.cos(ΞΈ)
x_range = np.linspace(0, x, 1000) ΞΈ_range = np.linspace(0, ΞΈ, 1000)
# Plot
fig = plt.figure(figsize=(8, 8))
ax = plt.subplot(111, projection='polar')
ax.plot((0, ΞΈ), (0, r), marker='o', color='b') # Plot r ax.plot(zeros(x_range.shape), x_range, color='b') # Plot x ax.plot(ΞΈ_range, x / np.cos(ΞΈ_range), color='b') # Plot y ax.plot(ΞΈ_range, ones(ΞΈ_range.shape) * 0.1, color='r') # Plot ΞΈ ax.margins(0) # Let the plot starts at origin
ax.set_title("Trigonometry of complex numbers", va='bottom', fontsize='x-large')
ax.set_rmax(2)
ax.set_rticks((0.5, 1, 1.5, 2)) # Less radial ticks
ax.set_rlabel_position(-88.5) # Get radial labels away from plotted line ax.text(ΞΈ, r+0.01 , r'$z = x + iy = 1 + \sqrt{3}\, i$') # Label z
ax.text(ΞΈ+0.2, 1 , '$r = 2$') # Label r
ax.text(0-0.2, 0.5, '$x = 1$') # Label x
ax.text(0.5, 1.2, r'$y = \sqrt{3}$') # Label y ax.text(0.25, 0.15, r'$\theta = 60^o$') # Label ΞΈ ax.grid(True)
plt.show()
3 De Moivreβs Theorem
de Moivreβs theorem states that:
(π(cos π + π sin π))π = ππππππ= ππ(cos ππ + π sin ππ)
To prove de Moivreβs theorem, note that
(π(cos π + π sin π))π= (ππππ)π
and compute.
4 Applications of de Moivreβs Theorem
4.1 Example 1
We can use de Moivreβs theorem to show that π = βπ₯2+ π¦2. We have
1 = ππππβππ
= (cos π + π sin π)(cos (-π) + π sin (-π))
= (cos π + π sin π)(cos π β π sin π)
= cos2π + sin2π
= π₯2 π2 +π¦2
π2 and thus
π₯2+ π¦2= π2 We recognize this as a theorem of Pythagoras.
4.2 Example 2
Let π§ = ππππ and Μπ§ = ππβππ so that Μπ§ is the complex conjugate of π§.
(π§, Μπ§) form a complex conjugate pair of complex numbers.
Let π = ππππ and Μπ = ππβππ be another complex conjugate pair.
For each element of a sequence of integers π = 0, 1, 2, β¦ ,.
To do so, we can apply de Moivreβs formula.
Thus,
π₯π = ππ§π+ Μπ Μπ§π
= ππππ(ππππ)π+ ππβππ(ππβππ)π
= πππππ(π+ππ)+ ππππβπ(π+ππ)
= πππ[cos (π + ππ) + π sin (π + ππ) + cos (π + ππ) β π sin (π + ππ)]
= 2πππcos (π + ππ)
4.3 Example 3
This example provides machinery that is at the heard of Samuelsonβs analysis of his multiplier-accelerator model [1].
Thus, consider a second-order linear difference equation
π₯π+2= π1π₯π+1+ π2π₯π
whose characteristic polynomial is
π§2β π1π§ β π2= 0 or
(π§2β π1π§ β π2) = (π§ β π§1)(π§ β π§2) = 0 has roots π§1, π§1.
A solution is a sequence {π₯π}βπ=0that satisfies the difference equation.
Under the following circumstances, we can apply our example 2 formula to solve the differ- ence equation
β’ the roots π§1, π§2 of the characteristic polynomial of the difference equation form a com- plex conjugate pair
β’ the values π₯0, π₯1 are given initial conditions
To solve the difference equation, recall from example 2 that
π₯π = 2πππcos (π + ππ)
where π, π are coefficients to be determined from information encoded in the initial conditions π₯1, π₯0.
Since π₯0= 2π cos π and π₯1= 2ππ cos (π + π) the ratio of π₯1to π₯0is π₯1
π₯0 = π cos (π + π) cos π
We can solve this equation for π then solve for π using π₯0= 2ππ0cos (π + ππ).
With the sympy package in Python, we are able to solve and plot the dynamics of π₯π given different values of π.
In this example, we set the initial values: - π = 0.9 - π = 14π - π₯0= 4 - π₯1= π β 2β
2 = 1.8β 2.
We first numerically solve for π and π using nsolve in the sympy package based on the above initial condition:
In [3]: # Set parameters r = 0.9
ΞΈ = Ο/4 x0 = 4
x1 = 2 * r * sqrt(2)
# Define symbols to be calculated Ο, p = symbols('Ο p', real=True)
# Solve for Ο
## Note: we choose the solution near 0 eq1 = Eq(x1/x0 - r * cos(Ο+ΞΈ) / cos(Ο), 0) Ο = nsolve(eq1, Ο, 0)
Ο = np.float(Ο)
print(f'Ο = {Ο:1.3f}')
# Solve for p
eq2 = Eq(x0 - 2 * p * cos(Ο), 0) p = nsolve(eq2, p, 0)
p = np.float(p)
print(f'p = {p:1.3f}')
Ο = 0.000 p = 2.000
Using the code above, we compute that π = 0 and π = 2.
Then we plug in the values we solve for π and π and plot the dynamic.
In [4]: # Define range of n max_n = 30
n = np.arange(0, max_n+1, 0.01)
# Define x_n
x = lambda n: 2 * p * r**n * np.cos(Ο + n * ΞΈ)
# Plot
fig, ax = plt.subplots(figsize=(12, 8)) ax.plot(n, x(n))
ax.set(xlim=(0, max_n), ylim=(-5, 5), xlabel='$n$', ylabel='$x_n$')
# Set x-axis in the middle of the plot ax.spines['bottom'].set_position('center') ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none') ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position('left')
ticklab = ax.xaxis.get_ticklabels()[0] # Set x-label position trans = ticklab.get_transform()
ax.xaxis.set_label_coords(31, 0, transform=trans)
ticklab = ax.yaxis.get_ticklabels()[0] # Set y-label position trans = ticklab.get_transform()
ax.yaxis.set_label_coords(0, 5, transform=trans) ax.grid()
plt.show()
4.4 Trigonometric Identities
We can obtain a complete suite of trigonometric identities by appropriately manipulating po- lar forms of complex numbers.
Weβll get many of them by deducing implications of the equality
ππ(π+π) = ππππππ For example, weβll calculate identities for
cos (π + π) and sin (π + π).
Using the sine and cosine formulas presented at the beginning of this lecture, we have:
cos (π + π) = ππ(π+π)+ πβπ(π+π) 2
sin (π + π) = ππ(π+π)β πβπ(π+π) 2π
We can also obtain the trigonometric identities as follows:
cos (π + π) + π sin (π + π) = ππ(π+π)
= ππππππ
= (cos π + π sin π)(cos π + π sin π)
= (cos π cos π β sin π sin π) + π(cos π sin π + sin π cos π) Since both real and imaginary parts of the above formula should be equal, we get:
cos (π + π) = cos π cos π β sin π sin π sin (π + π) = cos π sin π + sin π cos π
The equations above are also known as the angle sum identities. We can verify the equa- tions using the simplify function in the sympy package:
In [5]: # Define symbols
Ο, ΞΈ = symbols('Ο ΞΈ', real=True)
# Verify
print("cos(Ο)cos(ΞΈ) - sin(Ο)sin(ΞΈ) =",
simplify(cos(Ο)*cos(ΞΈ) - sin(Ο) * sin(ΞΈ))) print("cos(Ο)sin(ΞΈ) + sin(Ο)cos(ΞΈ) =",
simplify(cos(Ο)*sin(ΞΈ) + sin(Ο) * cos(ΞΈ)))
cos(Ο)cos(ΞΈ) - sin(Ο)sin(ΞΈ) = cos(ΞΈ + Ο) cos(Ο)sin(ΞΈ) + sin(Ο)cos(ΞΈ) = sin(ΞΈ + Ο)
4.5 Trigonometric Integrals
We can also compute the trigonometric integrals using polar forms of complex numbers.
For example, we want to solve the following integral:
β«
π
βπ
cos(π) sin(π) ππ Using Eulerβs formula, we have:
β« cos(π) sin(π) ππ = β«(πππ+ πβππ) 2
(πππβ πβππ)
2π ππ
= 1
4πβ« π2ππβ πβ2ππππ
= 1 4π(βπ
2 π2ππβ π
2πβ2ππ+ πΆ1)
= β1
8[(πππ)
2
+ (πβππ)
2
β 2] + πΆ2
= β1
8(πππβ πβππ)2+ πΆ2
= 1
2(πππβ πβππ
2π )
2
+ πΆ2
= 1
2sin2(π) + πΆ2 and thus:
β«
π
βπ
cos(π) sin(π) ππ = 1
2sin2(π) β1
2sin2(βπ) = 0
We can verify the analytical as well as numerical results using integrate in the sympy package:
In [6]: # Set initial printing init_printing()
Ο = Symbol('Ο')
print('The analytical solution for integral of cos(Ο)sin(Ο) is:') integrate(cos(Ο) * sin(Ο), Ο)
The analytical solution for integral of cos(Ο)sin(Ο) is:
Out[6]: sin2(π) 2
In [7]: print('The numerical solution for the integral of cos(Ο)sin(Ο) \ from -Ο to Ο is:')
integrate(cos(Ο) * sin(Ο), (Ο, -Ο, Ο))
The numerical solution for the integral of cos(Ο)sin(Ο) from -Ο to Ο is:
Out[7]: 0
4.6 Exercises
We invite the reader to verify analytically and with the sympy package the following two equalities:
β«
π
βπ
cos(π)2ππ =π 2
β«
π
βπ
sin(π)2ππ =π 2
References
[1] Paul A. Samuelson. Interactions between the multiplier analysis and the principle of accel- eration. Review of Economic Studies, 21(2):75β78, 1939.