Stern's Diatomic Sequence
mathematics
integer sequences
combinatorics
number theory

First appearance in Stern's Diatomic Sequence

Data Structures & Algorithms practice on Codemia

Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.

Practice algorithms

The concept of Stern's Diatomic Sequence, also known as Stern's Sequence or the Stern-Brocot Sequence, is a fascinating topic in number theory that involves a unique recursive process to generate a surprisingly regular yet complex sequence of integers. This article dives into the history, construction, and properties of the sequence, providing a thorough understanding for mathematicians and enthusiasts alike.

Understanding Stern's Diatomic Sequence

Stern's Diatomic Sequence is a sequence of non-negative integers that unfolds in the following manner:

  1. Initial Conditions: The sequence begins with the two terms 0 and 1.
  2. Recursive Definition: • For any positive integer nn, the value S(n)S(n) is given by: • S(2n)=S(n)S(2n) = S(n)S(2n+1)=S(n)+S(n+1)S(2n + 1) = S(n) + S(n + 1)

This simple recursive formula generates a sequence that has significant implications and applications in number theory and digital circuits.

Construction of the Sequence

The starting terms of Stern's Diatomic Sequence are simply S(0)=0S(0) = 0 and S(1)=1S(1) = 1. Using the recursive definitions, subsequent terms can be calculated:

S(2)=S(1)=1S(2) = S(1) = 1S(3)=S(1)+S(2)=1+1=2S(3) = S(1) + S(2) = 1 + 1 = 2S(4)=S(2)=1S(4) = S(2) = 1S(5)=S(2)+S(3)=1+2=3S(5) = S(2) + S(3) = 1 + 2 = 3S(6)=S(3)=2S(6) = S(3) = 2S(7)=S(3)+S(4)=2+1=3S(7) = S(3) + S(4) = 2 + 1 = 3S(8)=S(4)=1S(8) = S(4) = 1 • ...and so forth.

The first few terms of the sequence are as follows: 0, 1, 1, 2, 1, 3, 2, 3, 1, 4, ...

Properties and Characteristics

The sequence bears some intriguing mathematical properties:

  1. Symmetry: Stern's Sequence has a palindromic nature when viewed at powers of 2. Specifically, the sequence from S(2m)S(2^m) to S(2m+11)S(2^{m+1}-1) mirrors itself in many respects. This implies the values are symmetrical about the midpoint.
  2. Farey Sequence Connection: The sequence is related to Farey sequences, helping generate terms of the Farey sequence of order nn through mediant operations.
  3. Binary Trees: Another intriguing aspect of Stern's Diatomic Sequence is its connection to binary trees. The sequence emerges when nodes in a binary tree are labeled according to specific mediant rules.
  4. Growth Behavior: The sequence grows slowly compared to linear or exponential sequences. For large nn, the values of Stern's Sequence are much smaller than nn.

Example Application: Constructing Rational Approximations

One notable application of Stern's Sequence is in generating rational approximations of irrational numbers. The values help index nodes in the Farey tree, offering a systematic approach to approximating irrationals with fractions that have small denominators.

Summary Table

Below is a summary table listing the first few terms of Stern's Diatomic Sequence and their properties:

nnStern's Diatomic Sequence S(n)S(n)Binary Representation of nn \lvert Notes \rvert
000Starting condition
111Starting condition
2110S(2)=S(1)S(2) = S(1)
3211S(3)=S(1)+S(2)S(3) = S(1) + S(2)
41100S(4)=S(2)S(4) = S(2)
53101S(5)=S(2)+S(3)S(5) = S(2) + S(3)
62110S(6)=S(3)S(6) = S(3)
73111S(7)=S(3)+S(4)S(7) = S(3) + S(4)
811000S(8)=S(4)S(8) = S(4)

Conclusion

Stern's Diatomic Sequence might appear simple at a glance due to its concise recursive definition, yet it unveils a myriad of connections within mathematics. Its properties are pivotal to understanding various numerical structures and systems. Whether it's aiding in constructing Farey sequences or its relationship to rational approximations, Stern's Sequence provides an excellent subject of study for both theoretical examinations and practical applications.


Related reading
Course
Intermediate
27 lessons
15 hours
DSA Fundamentals

Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Data Structures & Algorithms practice on Codemia

Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.

Practice algorithms

All Rights Reserved.