RudinShapiro[n]
gives the n
term in the Rudin–Shapiro sequence.
RudinShapiro
RudinShapiro[n]
gives the n
term in the Rudin–Shapiro sequence.
Details
- RudinShapiro[n] is 1 if n has an even number of possibly overlapping 11 sequences in its base-2 digits, and is -1 otherwise.
- RudinShapiro automatically threads over lists.
Examples
open all close allBasic Examples (2)
The sixth element of the Rudin–Shapiro sequence:
RudinShapiro[6]The number 6 has an odd number of 11 sequences in its binary form:
BaseForm[6, 2]The first ten elements of the sequence:
Table[RudinShapiro[n], {n, 0, 9}]Display the values alongside the binary expansion:
Table[{n, BaseForm[n, 2], RudinShapiro[n]}, {n, 0, 10}]//GridScope (2)
RudinShapiro threads over lists:
RudinShapiro[{3, 5, 8, 11}]RudinShapiro[999 ^ 999]Applications (2)
Properties & Relations (3)
The Rudin–Shapiro sequence has a nested structure:
Grid[Partition[Table[ListLinePlot[Accumulate[Array[RudinShapiro, 2 ^ k, 0]]], {k, 12}], 4]]The Rudin–Shapiro sequence satisfies a recurrence relation:
Module[{f}, f[0] = 1;f[n_] := f[n] = (-1) ^ Mod[(1 - f[Quotient[n, 2]]) / 2 + Quotient[n, 2] * n, 2];
Array[f, 32, 0]]The Rudin–Shapiro sequence is the result of a substitution system:
Characters[Nest[StringReplace[#, {"AB" -> "ABAD", "AD" -> "ABCB", "CB" -> "CDAD", "CD" -> "CDCB"}]&, "AB", 4]] /. {"A" | "B" -> 1, "C" | "D" -> -1}Related Guides
History
Text
Wolfram Research (2015), RudinShapiro, Wolfram Language function, https://reference.wolfram.com/language/ref/RudinShapiro.html.
CMS
Wolfram Language. 2015. "RudinShapiro." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RudinShapiro.html.
APA
Wolfram Language. (2015). RudinShapiro. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RudinShapiro.html
BibTeX
@misc{reference.wolfram_2026_rudinshapiro, author="Wolfram Research", title="{RudinShapiro}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/RudinShapiro.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_rudinshapiro, organization={Wolfram Research}, title={RudinShapiro}, year={2015}, url={https://reference.wolfram.com/language/ref/RudinShapiro.html}, note=[Accessed: 13-June-2026]}