Investigating the Behaviour of a Recursively Defined Sequence
Given the function: f(x) = floor(2^(30.403243784 - x^2)) * 10^(-9) and the sequence u_0 = -1, u_(n+1) = f(u_n), find u_n + u_(n+1) for n = 10^12, written with 9 digits after the decimal point.
Problem Statement
This archive keeps the full statement, math, and original media on the page.
Given is the function $f(x) = \lfloor 2^{30.403243784 - x^2}\rfloor \times 10^{-9}$ ($\lfloor \, \rfloor$ is the floor-function),
the sequence $u_n$ is defined by $u_0 = -1$ and $u_{n + 1} = f(u_n)$.
Find $u_n + u_{n + 1}$ for $n = 10^{12}$.
Give your answer with $9$ digits after the decimal point.
Problem 197: Investigating the Behaviour of a Recursively Defined Sequence
Mathematical Development
Theorem 1. (2-Cycle Convergence.) The sequence converges to a 2-cycle: there exist constants with such that and . Moreover, for all sufficiently large :
Proof. Define . We show is a contraction on a suitable interval .
Step 1: Existence of a 2-cycle. The function maps into for some constant (since is bounded). Thus , so maps to itself. By the Brouwer fixed-point theorem, has a fixed point in , giving , i.e., . Setting , we have .
Step 2: (not a fixed point). A fixed point of would require . Numerical evaluation shows no such solution exists: the equation has solutions near and , but the floor function prevents either from being exact. Instead, maps one neighbourhood to the other.
Step 3: Contraction. The derivative of at is . Ignoring the floor function (which is locally constant almost everywhere), . Numerical evaluation gives and , so . By the contraction mapping principle (Banach fixed-point theorem), exponentially.
Theorem 2. (Stability of the Sum.) For all sufficiently large , the sum is independent of the parity of :
Proof. For even : . For odd : .
Lemma 1. (Convergence Rate.) The convergence is exponentially fast. After iterations, is stable to the full precision of IEEE 754 double-precision arithmetic ( decimal digits).
Proof. The error after iterations of satisfies . With , after 100 iterations the error is bounded by , well below double precision.
Editorial
The important observation is that the recursion does not need to be simulated anywhere near 10^12 steps. The sequence rapidly falls into a stable 2-cycle, so after the transient disappears, consecutive terms just alternate between two values and their sum stops changing.
That makes the numerical solution straightforward: iterate the map a generous fixed number of times, such as 1000, compute one more term, and format the stabilized sum. The mathematical part guarantees that once the 2-cycle has been reached, the parity of n no longer matters for u_n + u_{n+1}.
Pseudocode
Start with u = -1.
Repeat the recurrence a fixed number of times, for example 1000 iterations.
Let v be the next term f(u).
Compute floor((u + v) * 10^9).
Print that scaled value as a decimal with 9 digits after the point.
Complexity Analysis
- Time: where iterations. Each iteration requires one floating-point exponentiation ( with hardware support).
- Space: — only two floating-point variables.
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
int main() {
double u = -1.0;
for (int i = 0; i < 1000; i++)
u = floor(pow(2.0, 30.403243784 - u * u)) * 1e-9;
double u_n = u;
double u_n1 = floor(pow(2.0, 30.403243784 - u * u)) * 1e-9;
long long ans = (long long)floor((u_n + u_n1) * 1e9);
assert(ans == 1710637717LL);
cout << fixed << setprecision(9) << ans / 1e9 << endl;
return 0;
}
"""
Problem 197: Recursively Defined Sequence
The sequence converges quickly to a 2-cycle, so a modest fixed iteration count
is enough to recover the final 9-digit decimal answer.
"""
import math
def f(x):
return math.floor(2 ** (30.403243784 - x * x)) * 1e-9
def solve_scaled(iterations=1000):
u = -1.0
for _ in range(iterations):
u = f(u)
v = f(u)
return math.floor((u + v) * 1e9)
if __name__ == "__main__":
scaled = solve_scaled()
assert scaled == 1710637717
print(f"{scaled / 1e9:.9f}")