Contents
, , , , , , ,
Deep Breakdown
What it tells me (Situation Awareness): The powers of cycle with period 4: . This is a direct consequence of Euler's formula: , so , which completes a full rotation () every 4 steps. In DA/DS, the cyclic pattern of -powers is the algebraic foundation for: simplifying complex arithmetic, understanding why the DFT has period , and working with roots of unity. It is also the pattern you use every time you simplify (without a calculator).
Flowchart
Real-world use
Where it is used
Simplifying complex expressions: . Roots of unity: the 4th roots of unity are (the four powers of ). FFT butterfly: for are the "twiddle factors" of the length-4 DFT. Signal rotation: multiplying by rotates by 90°, multiplying by rotates by 180°.
Problem it solves
When computing large powers of , the cyclic pattern gives the answer instantly: compute and read the table. Without the cyclic pattern, you'd need to expand all the multiplications. With it: .
How it solves the problem
Since , any power .
The four values are:
- :
- :
- :
- : This is a finite cyclic group under modular arithmetic, and is the corresponding group of 4th roots of unity.
Example in a business
DFT twiddle factors for : the matrix is built from . For , the twiddle factors are powers of , which follows the same 4-cycle. FFT algorithms rely on the fact that these twiddle factors cycle with period 4 (or generally), enabling the divide-and-conquer recursion.
The formula, piece by piece
Breaking the notation:
- : to the first power is .
- : the defining property (, definition of ).
- .
- .
- .
- .
- .
- . Compact rule: , with the table .
Negative powers:
- .
- .
- In general: (just go backwards in the cycle).
The formula in words
"The imaginary unit cycles through four values when you raise it to successive powers: , , , , then back to . It's like a clock with four positions. To find any power of : divide the exponent by 4, look at the remainder, and look up the result in the four-entry table."
Critical Concepts
- Quick computation rule:
n % 4gives the remainder. Map , , , . - 4th roots of unity: are exactly the four 4th roots of unity: each when raised to the 4th power equals 1. These form a cyclic group of order 4.
- Unit circle connection: sits at 90° on the unit circle. Multiplying by is a 90° counter-clockwise rotation. Four such rotations complete a full circle and return to the original point.
- Python:
(1j)**nworks for integer .
Note that Python returns exact complex results for small integer powers of 1j.
Step-by-step calculation (tiny example)
Task: find and .
Step 1: . .
Step 2: Verify by factoring . Confirmed.
Step 3: : , so . . Alternatively: . Confirmed.
Code examples
Beginner example (Python)
# Powers of i: cycle of length 4
# i^1=i, i^2=-1, i^3=-i, i^4=1, then repeats
import numpy as np # Compute and display first 12 powers of i
print("Powers of i (1j in Python):")
print(f"{'n':>4} {'i^n':>10} {'n mod 4':>8} {'formula':>8}")
for n in range(1, 13):
power = (1j)**n
remainder = n % 4
formula = {0: "1", 1: "i", 2: "-1", 3: "-i[["}[remainder]
print(f"]] {n:>2} {str(power):>10} {remainder:>8} {formula:>8}") # Fast rule: i^n = i^(n mod 4)
def power_of_i(n: int) -> complex:
"""Fast computation of i^n using cyclic property."""
lookup = {0: 1+0j, 1: 0+1j, 2: -1+0j, 3: 0-1j}
return lookup[n % 4] # Test large powers
test_powers = [43, 100, -7, 1001, 0]
print("\nLarge power lookup:")
for n in test_powers:
fast = power_of_i(n)
direct = (1j)**n
print(f" i^{n:>5} = {fast:>7} (direct: {direct:>7}) match: {abs(fast-direct)<1e-10}") # DFT 4-point twiddle factors W = e^(-i*2π/N) for
N=4
N = 4
W = np.exp(-1j * 2 * np.pi / N) # = e^(-iπ/2) = -i
print(f"\n4-point DFT twiddle base: W_4 = e^(-iπ/2) = {W:.4f}")
print("Twiddle factors W_4^k:")
for k in range(N):
wk = W**k
print(f" W_4^{k} = {wk:.4f} = i^{(-k)%4} = {power_of_i(-k):.4f}")Beginner example (R)
# Powers of i in R
power_of_i <- function(n) { lookup <- list("0"=1+0i, "1"=0+1i, "2"=-1+0i, "3"=0-1i)
key <- as.character(n %% 4)
return(lookupkey)
}
cat("Powers of i:\n")
for (n in 1:8) { p <- (1i)^n
f <- power_of_i(n)
cat(sprintf(" i^%d = %s (n%%4=%d, fast=%s)\n", n, p, n%%4, f))
}
cat("\nLarge powers:\n")
for (n in c(43, 100, -7, 1001)) { fast <- power_of_i(n)
cat(sprintf(" i^%d = %s\n", n, fast))
}Professional example (Python)
import numpy as np # Scenario: 4-point DFT matrix built from powers of i
# Demonstrates cyclic structure in Fourier analysis
N = 4
print("4-Point DFT Matrix (DFT_4) built from powers of i")
print("=" * 50)
print(" DFT_4[j,k] = e^(-i·2π·j·k/4) = (e^(-iπ/2))^(j·k) = (-i)^(j·k)")
print() # Build DFT matrix
W_base = np.exp(-1j * 2 * np.pi / N) # = -i (base twiddle)
DFT_4 = np.array([[W_base**(j*k) for k in range(N)] for j in range(N)])
print(" DFT_4 matrix:")
for row in DFT_4:
row_str = " [" + " ".join(f"{v.real:+.0f}{v.imag:+.0f}j" for v in row) + " ]"
print(row_str)
print() # Verify: each entry is a power of (-i) = i^3 = i^{4n+3}
print(" Entries as powers of i (via j*k mod 4 lookup):")
lookup = {0: " 1", 1: " i", 2: "-1", 3: "-i"}
for j in range(N):
row_strs = []
for k in range(N):
exponent = (j * k) % N # power of W = power of (-i) # W_base = e^(-iπ/2) = -i = i^3; so W^(j*k) = (-i)^(j*k)
row_strs.append(f"(-i)^{j*k}={lookup[(j*k*3)%4]}")
print(f" j={j}: [{', '.join(row_strs)}]")
print()
# Apply DFT to a simple signal and verify
signal = np.array([1.0, 0.0, 1.0, 0.0]) # alternating 1, 0, 1, 0
X_matrix = DFT_4 @ signal
X_fft = np.fft.fft(signal)
print("DFT of [1, 0, 1, 0] via matrix vs. np.fft.fft:")
for k, (m, f) in enumerate(zip(X_matrix, X_fft)):
print(f" X[{k}]: matrix={m:.3f} fft={f:.3f} match: {abs(m-f)<1e-10}")Professional example (R)
# DFT via matrix (powers of i in entries) vs fft()
signal <- c(1, 0, 1, 0)
N <- 4
k <- 0:(N - 1)
n <- 0:(N - 1)
W <- outer(k, n, function(k, n) exp(-2i * pi * k * n / N))
X_matrix <- as.vector(W %*% signal)
X_fft <- fft(signal)
cat("DFT of [1,0,1,0] via matrix vs fft():\n")
for (i in seq_along(X_matrix)) { cat(sprintf(" X[%d]: matrix=%.3f fft=%.3f match: %s\n", i-1, X_matrix[i], X_fft[i], abs(X_matrix[i] - X_fft[i]) < 1e-10))
}Source: domain knowledge