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: Oct 3, 2026 - Oct 6, 2026 (pulled Oct 6, 2026 UTC)

Latest data pull 72 rows
Oct 3, 2026 - Oct 6, 2026 (pulled Oct 6, 2026 UTC)
Sample index
Water level (m, MLLW)
0
1.389
1
1.333
2
1.36
3
1.451
4
1.633
5
1.796
6
1.972
7
2.043
8
1.979
9
1.762
10
1.408
11
1.005
12
0.675
13
0.408
14
0.242
15
0.276
16
0.418
17
0.658
18
0.941
19
1.214
20
1.466
21
1.651
22
1.724
23
1.676
24
1.529
25
1.366
26
1.245
27
1.211
28
1.292
29
1.454
30
1.661
31
1.842
32
1.961
33
1.978
34
1.793
35
1.457
36
1.05
37
0.693
38
0.407
39
0.251
40
0.241
41
0.396
42
0.651
43
0.946
44
1.249
45
1.506
46
1.714
47
1.768
48
1.689
49
1.5
50
1.257
51
1.09
52
1.056
53
1.15
54
1.34
55
1.57
56
1.79
57
1.983
58
2.015
59
1.884
60
1.563
61
1.123
62
0.728
63
0.429
64
0.266
65
0.281
66
0.446
67
0.729
68
1.074
69
1.391
70
1.678
71
1.835

Station: San Francisco. Series start (GMT): 2026-10-03 17:18. All 72 water-level samples are listed below.