Diophantine Approximation
For irrational alpha, the best rational approximations are given by its continued fraction convergents. Let p_k/q_k be the k -th convergent of sqrt(2). Find sum_(k=0)^50 (p_k^2 - 2q_k^2).
Problem Statement
This archive keeps the full statement, math, and original media on the page.
There is a plane on which all points are initially white, except three red points and two blue points.
On each day, every line passing through a red point and a blue point is constructed. Then every white point, where two different such lines meet, turns blue.
Let \(g(n)\) be the maximal possible number of blue points after \(n\) days.
For example, \(g(1)=8\) and \(g(2)=28\).</p>
Find \(g(16)\).
Problem 957: Diophantine Approximation
Mathematical Analysis
Continued Fraction of
The continued fraction expansion of is purely periodic after the integer part:
This is one of the simplest infinite continued fractions. The partial quotients are all 2 (except the first, which is 1).
Convergent Recurrence
The convergents satisfy the standard recurrence:
with , for , and initial conditions (or equivalently ).
The first several convergents are:
| 0 | 1 | 1 | 1.000 | |
| 1 | 3 | 2 | 1.500 | |
| 2 | 7 | 5 | 1.400 | |
| 3 | 17 | 12 | 1.4167 | |
| 4 | 41 | 29 | 1.4138 | |
| 5 | 99 | 70 | 1.41429 |
The Fundamental Identity
Theorem. For all :
Proof by induction.
Base cases: . . Both check out.
Inductive step: Assume and . Using and :
By a separate identity for convergents: satisfies , and after algebraic manipulation:
Connection to Pell’s Equation
The identity means that the convergents provide all solutions to the Pell equations . Specifically:
- Even : solves (the negative Pell equation).
- Odd : solves (the positive Pell equation).
Computing the Sum
For (51 terms):
- even (): 26 terms, each contributing .
- odd (): 25 terms, each contributing .
Derivation
Editorial
Method 1 (closed form): By the identity, the sum is .
Method 2 (verification): Compute convergents using the recurrence and verify each directly.
Proof of Correctness
Theorem. For the continued fraction with convergents , the identity holds for all .
The proof is given above by strong induction on .
Corollary. , which equals if is even and if is odd.
Proof. For even , there are even values of and odd values. The sum is . For odd , there are terms of each sign, summing to .
Complexity Analysis
with the closed-form result. with explicit computation of convergents (using -digit arithmetic for the exact convergent values).
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
/*
* Problem 957: Diophantine Approximation
*
* Convergents of sqrt(2) = [1; 2, 2, ...] satisfy p_k^2 - 2*q_k^2 = (-1)^{k+1}.
* Sum for k = 0..50 = -1 (closed form).
*
* Verification: compute convergents using arbitrary-precision integers
* (or just use the closed-form answer).
*
* Complexity: O(1) closed form, O(N) with verification.
*/
#include <bits/stdc++.h>
using namespace std;
int main() {
// Closed-form: sum_{k=0}^{50} (-1)^{k+1}
// 26 even k's contribute -1, 25 odd k's contribute +1
// Total = -26 + 25 = -1
// Verification with __int128 (convergents grow as (1+sqrt(2))^k)
__int128 p_prev = 0, p_curr = 1;
__int128 q_prev = 1, q_curr = 1;
long long total = 0;
// k = 0
__int128 val = p_curr * p_curr - 2 * q_curr * q_curr;
total += (long long)val;
for (int k = 1; k <= 50; k++) {
__int128 p_next = 2 * p_curr + p_prev;
__int128 q_next = 2 * q_curr + q_prev;
p_prev = p_curr; p_curr = p_next;
q_prev = q_curr; q_curr = q_next;
val = p_curr * p_curr - 2 * q_curr * q_curr;
total += (long long)val;
}
cout << total << endl;
return 0;
}
"""
Problem 957: Diophantine Approximation
Convergents p_k/q_k of sqrt(2) = [1; 2, 2, 2, ...] satisfy p_k^2 - 2*q_k^2 = (-1)^{k+1}.
Sum for k=0..50: sum of (-1)^{k+1} = -1 (26 terms of -1, 25 terms of +1).
Verification by direct computation of convergents.
"""
def convergents_sqrt2(N: int) -> list[tuple[int, int]]:
"""Compute convergents p_k/q_k of sqrt(2) for k = 0, 1, ..., N."""
result = []
p_prev, p_curr = 0, 1 # p_{-1}, p_0
q_prev, q_curr = 1, 1 # q_{-1}, q_0
# a_0 = 1, so p_0 = 1, q_0 = 1
result.append((p_curr, q_curr))
for k in range(1, N + 1):
a_k = 2
p_next = a_k * p_curr + p_prev
q_next = a_k * q_curr + q_prev
p_prev, p_curr = p_curr, p_next
q_prev, q_curr = q_curr, q_next
result.append((p_curr, q_curr))
return result
def solve(N: int = 50) -> int:
"""Compute sum of (p_k^2 - 2*q_k^2) for k = 0 to N."""
convs = convergents_sqrt2(N)
return sum(p * p - 2 * q * q for p, q in convs)
# --- Compute answer ---
N = 50
convs = convergents_sqrt2(N)
# Verify identity p_k^2 - 2*q_k^2 = (-1)^{k+1}
for k, (p, q) in enumerate(convs):
val = p * p - 2 * q * q
expected = (-1) ** (k + 1)
assert val == expected, f"k={k}: {val} != {expected}"
answer = sum(p * p - 2 * q * q for p, q in convs)
# Closed form check
assert answer == -1, f"Expected -1, got {answer}"
print(answer)