Complete Technical Guide to Generate Rudin-Shapiro Sequence
The Golay–Rudin–Shapiro sequence (OEIS A020985) assigns +1 or −1 to each non-negative integer n based on the parity of overlapping '11' substrings in the binary expansion of n. Remarkably, its trigonometric polynomials have ultra-flat Fourier spectra bounded tightly by √(2N)!
Switch between classical ±1 notation (OEIS A020985) and binary 0/1 parity form (OEIS A020987), inspect the exact partial sum bound, and export up to 4,096 terms cleanly.
Bitwise Overlapping-'11' Formula
e₂(n) = popcount(n AND (n >> 1)) (counts overlapping '11' blocks in binary n) A020985: a(n) = (-1)^(e₂(n)) (+1, +1, +1, -1, +1, +1, -1, +1, ...) A020987: b(n) = e₂(n) mod 2 (0, 0, 0, 1, 0, 0, 1, 0, ...)
Because `n & (n >> 1)` sets a bit precisely wherever two adjacent bits of n are both 1, the popcount gives the exact count of overlapping '11' pairs in O(1) bit operations.
How to Use Generate Rudin-Shapiro Sequence
- 1Choose count (1–4,096) and +1/-1 or 0/1 format.
- 2Review the exact partial sum (proven bounded by √(6N)).
- 3Copy or export JSON/TXT.
Reference Examples & Worked Benchmarks
| n | Binary | '11' Count | A020985 | A020987 |
|---|---|---|---|---|
| 0 | 0 | 0 | +1 | 0 |
| 3 | 11 | 1 | -1 | 1 |
| 6 | 110 | 1 | -1 | 1 |
| 7 | 111 | 2 | +1 | 0 |
Practical Applications & Engineering Workflows
Signal Processing & Radar
Golay complementary sequences derived from Rudin–Shapiro minimize peak-to-average power ratio (PAPR) in OFDM and radar pulse compression.
Accuracy, Edge Cases & Best Practices
- Partial sums of the ±1 sequence are always strictly positive for every N >= 1.
All calculations execute locally inside your browser using JavaScript with zero server round-trips, guaranteeing instant responsiveness and complete data privacy.