Chapter 3 of The Nature of Code, Oscillation, covers simple harmonic motion and the sum of sinusoids. Ocean tides are a physical sum of sinusoidal harmonic constituents.

Ocean tides are that sum of sinusoids in the wild, so I plot NOAA water levels at San Francisco against a two-constituent M2+S2 model.

The page plots three days of measured water level from NOAA station 9414290 (San Francisco) and overlays a two-term demo model: the principal lunar semidiurnal constituent M2 and the principal solar semidiurnal constituent S2, with fixed amplitudes and a phase that nudges toward the series. Two sinusoids recover the main beat of the measured curve, which is Chapter 3’s point about how far a small sum of sines extends.

Each constituent is simple harmonic motion \(x(t) = A\sin(\omega t + \phi)\) with \(\omega = 2\pi/T\), and the overlay is \(h(t) = Z_0 + A_1\sin(\omega_{\mathrm{M2}} t + \phi_1) + A_2\sin(\omega_{\mathrm{S2}} t + \phi_2)\) (sine phase convention, equivalent to a cosine form up to a phase shift). The periods are M2 \(T = 12.42\) h and S2 \(T = 12.00\) h. Their beat frequency \(f_{S2} - f_{M2}\) has a period near 14.8 days and produces the spring-neap cycle.

Data source: NOAA CO-OPS (Tides & Currents) API
Endpoint: https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?station=9414290&product=water_level&...
Access: Public, no key. Loaded from an hourly server-side refresh when possible, with a bundled snapshot fallback, and a live browser fetch only when the API allows CORS. Data window: Sep 13, 2026 - Sep 16, 2026 (pulled Sep 16, 2026 UTC)

Latest data pull 72 rows
Sep 13, 2026 - Sep 16, 2026 (pulled Sep 16, 2026 UTC)
Sample index
Water level (m, MLLW)
0
0.664
1
0.929
2
1.256
3
1.558
4
1.824
5
1.981
6
1.902
7
1.66
8
1.235
9
0.837
10
0.504
11
0.353
12
0.365
13
0.553
14
0.823
15
1.091
16
1.373
17
1.588
18
1.67
19
1.588
20
1.353
21
1.051
22
0.803
23
0.706
24
0.774
25
0.953
26
1.222
27
1.521
28
1.777
29
1.985
30
2.023
31
1.845
32
1.506
33
1.093
34
0.713
35
0.471
36
0.381
37
0.409
38
0.609
39
0.853
40
1.109
41
1.347
42
1.511
43
1.608
44
1.5
45
1.331
46
1.082
47
0.94
48
0.909
49
0.997
50
1.182
51
1.409
52
1.651
53
1.85
54
1.973
55
1.904
56
1.695
57
1.35
58
0.975
59
0.67
60
0.494
61
0.419
62
0.466
63
0.647
64
0.868
65
1.09
66
1.298
67
1.452
68
1.52
69
1.466
70
1.322
71
1.186

Station: San Francisco. Series start (GMT): 2026-09-13 15:30. All 72 water-level samples are listed below.