# Exercise 1: peaks of the toy curve with and without the 100 kyr cycle import math def peaks_of(periods, limit=400, threshold=1.0): def f(t): return sum(math.cos(2 * math.pi * t / p) for p in periods) return [t for t in range(1, limit) if f(t) > f(t - 1) and f(t) > f(t + 1) and f(t) > threshold] for label, periods in (("tilt + wobble", (41, 23)), ("all three", (100, 41, 23))): pk = peaks_of(periods) gaps = [b - a for a, b in zip(pk, pk[1:])] print(f"{label:14s} peaks: {len(pk):2d} average gap: {sum(gaps) / len(gaps):5.1f} kyr first five peaks: {pk[:5]}") # tilt + wobble peaks: 9 average gap: 40.4 kyr first five peaks: [45, 90, 117, 162, 207] # all three peaks: 8 average gap: 39.9 kyr first five peaks: [90, 116, 162, 206, 279] # Notes: dropping the 100 kyr cycle barely changes the average gap, which stays near 40 kyr, because tilt and wobble dominate the spacing. # The 100 kyr cycle mainly changes which peaks are strong enough to count. Adding it removes a peak at 45 kyr and reshuffles the rest.