BRAGA

02 Writing02-02 Notes02-02-059

Powers of i

Published 16 Apr 20268 min read
Contents
  1. 01Deep Breakdown
  2. 02Flowchart
  3. 03Real-world use
  4. 04The formula, piece by piece
  5. 05The formula in words
  6. 06Critical Concepts
  7. 07Step-by-step calculation (tiny example)
  8. 08Code examples
i1=ii^1 = i
(1)

, i2=−1i^2 = -1, i3=−ii^3 = -i, i4=1i^4 = 1, i4n=1i^{4n} = 1, i4n+1=ii^{4n+1} = i, i4n+2=−1i^{4n+2} = -1, i4n+3=−ii^{4n+3} = -i

Deep Breakdown

What it tells me (Situation Awareness): The powers of ii cycle with period 4: {i,−1,−i,1,i,−1,−i,1,…}\{i, -1, -i, 1, i, -1, -i, 1, \ldots\}. This is a direct consequence of Euler's formula: i=eiπ/2i = e^{i\pi/2}, so in=einπ/2i^n = e^{in\pi/2}, which completes a full rotation (2π2\pi) every 4 steps. In DA/DS, the cyclic pattern of ii-powers is the algebraic foundation for: simplifying complex arithmetic, understanding why the DFT has period NN, and working with roots of unity. It is also the pattern you use every time you simplify i35i^{35} (without a calculator).

Flowchart

i^1 = i (angle90°)i^2 = i×i = -1(angle 180°)i^3 = i²×i = -1×i =-i (angle 270°)i^4 = i³×i = -i×i =-i²= 1 (angle360°=0°)i^5 = i^4 × i =1×i = i (back tostart)Cycle of length4: i, -1, -i, 1, i,-1, -i, 1, ...i^n: find n mod4, look up table

Real-world use

Where it is used

Simplifying complex expressions: i43=i4×10+3=(i4)10⋅i3=110⋅(−i)=−ii^{43} = i^{4 \times 10 + 3} = (i^4)^{10} \cdot i^3 = 1^{10} \cdot (-i) = -i. Roots of unity: the 4th roots of unity are 1,i,−1,−i1, i, -1, -i (the four powers of ii). FFT butterfly: iki^k for k=0,1,2,3k = 0, 1, 2, 3 are the "twiddle factors" of the length-4 DFT. Signal rotation: multiplying by ii rotates by 90°, multiplying by i2=−1i^2 = -1 rotates by 180°.

Problem it solves

When computing large powers of ii, the cyclic pattern gives the answer instantly: compute n mod 4n \bmod 4 and read the table. Without the cyclic pattern, you'd need to expand all the multiplications. With it: i1000=i4×250=(i4)250=1i^{1000} = i^{4 \times 250} = (i^4)^{250} = 1.

How it solves the problem

Since i4=1i^4 = 1, any power in=in mod 4i^n = i^{n \bmod 4}.

The four values are:

  • n mod 4=0n \bmod 4 = 0: in=1i^n = 1
  • n mod 4=1n \bmod 4 = 1: in=ii^n = i
  • n mod 4=2n \bmod 4 = 2: in=−1i^n = -1
  • n mod 4=3n \bmod 4 = 3: in=−ii^n = -i This is a finite cyclic group Z4={0,1,2,3}\mathbb{Z}_4 = \{0, 1, 2, 3\} under modular arithmetic, and {1,i,−1,−i}\{1, i, -1, -i\} is the corresponding group of 4th roots of unity.

Example in a business

DFT twiddle factors for N=4N = 4: the matrix is built from W4jk=e−i2πjk/4=e−iπjk/2=(−i)jkW_4^{jk} = e^{-i2\pi jk/4} = e^{-i\pi jk/2} = (-i)^{jk}. For j,k∈{0,1,2,3}j, k \in \{0,1,2,3\}, the twiddle factors are powers of −i-i, which follows the same 4-cycle. FFT algorithms rely on the fact that these twiddle factors cycle with period 4 (or NN generally), enabling the divide-and-conquer recursion.

The formula, piece by piece

Breaking the notation:

  • i1=ii^1 = i: ii to the first power is ii.
  • i2=−1i^2 = -1: the defining property (i2=−1i^2 = -1, definition of ii).
  • i3=i2⋅i=−1⋅i=−ii^3 = i^2 \cdot i = -1 \cdot i = -i.
  • i4=i3⋅i=(−i)⋅i=−i2=−(−1)=1i^4 = i^3 \cdot i = (-i) \cdot i = -i^2 = -(-1) = 1.
  • i4n=(i4)n=1n=1i^{4n} = (i^4)^n = 1^n = 1.
  • i4n+1=i4n⋅i=1⋅i=ii^{4n+1} = i^{4n} \cdot i = 1 \cdot i = i.
  • i4n+2=i4n⋅i2=1⋅(−1)=−1i^{4n+2} = i^{4n} \cdot i^2 = 1 \cdot (-1) = -1.
  • i4n+3=i4n⋅i3=1⋅(−i)=−ii^{4n+3} = i^{4n} \cdot i^3 = 1 \cdot (-i) = -i. Compact rule: in=in mod 4i^n = i^{n \bmod 4}, with the table {0→1, 1→i, 2→−1, 3→−i}\{0 \to 1,\ 1 \to i,\ 2 \to -1,\ 3 \to -i\}.

Negative powers:

  • i−1=1/i=i/i2=i/(−1)=−i=i3i^{-1} = 1/i = i/i^2 = i/(-1) = -i = i^3.
  • i−2=(i2)−1=(−1)−1=−1=i2i^{-2} = (i^2)^{-1} = (-1)^{-1} = -1 = i^2.
  • In general: i−n=i4−n mod 4i^{-n} = i^{4-n \bmod 4} (just go backwards in the cycle).

The formula in words

"The imaginary unit cycles through four values when you raise it to successive powers: ii, −1-1, −i-i, 11, then back to ii. It's like a clock with four positions. To find any power of ii: divide the exponent by 4, look at the remainder, and look up the result in the four-entry table."

Critical Concepts

  1. Quick computation rule: n % 4 gives the remainder. Map 0→10 \to 1, 1→i1 \to i, 2→−12 \to -1, 3→−i3 \to -i.
  2. 4th roots of unity: {1,i,−1,−i}\{1, i, -1, -i\} 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.
  3. Unit circle connection: i=eiπ/2i = e^{i\pi/2} sits at 90° on the unit circle. Multiplying by ii is a 90° counter-clockwise rotation. Four such rotations complete a full circle and return to the original point.
  4. Python: (1j)**n works for integer nn.

Note that Python returns exact complex results for small integer powers of 1j.

Step-by-step calculation (tiny example)

Task: find i43i^{43} and i−7i^{-7}.

Step 1: i43i^{43} 43 mod 4=43−4×10=43−40=343 \bmod 4 = 43 - 4 \times 10 = 43 - 40 = 3. i43=i3=−ii^{43} = i^3 = -i.

Step 2: Verify by factoring i43=i40⋅i3=(i4)10⋅(−i)=110⋅(−i)=−ii^{43} = i^{40} \cdot i^3 = (i^4)^{10} \cdot (-i) = 1^{10} \cdot (-i) = -i. Confirmed.

Step 3: i−7i^{-7} −7 mod 4-7 \bmod 4: −7=4×(−2)+1-7 = 4 \times (-2) + 1, so −7≡1(mod4)-7 \equiv 1 \pmod 4. i−7=i1=ii^{-7} = i^1 = i. Alternatively: i−7=i−8⋅i=(i4)−2⋅i=1⋅i=ii^{-7} = i^{-8} \cdot i = (i^4)^{-2} \cdot i = 1 \cdot i = i. Confirmed.

Code examples

Beginner example (Python)

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)

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)

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)

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

#foundations#number-sets-and-logic#complex-numbers-foundations

Keyboard shortcuts

Single keys, ignored while typing in a field or with Cmd, Ctrl or Alt held.

0
Home
1 2 3 4
Work, Writing, Tools, About
j / k
Next / previous section on this page
n / p
Next / previous project or essay
u
Up one level
l
Deutsch
t
Light or dark theme
?
This list
Esc
Close