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: Aug 24, 2026 - Aug 27, 2026 (pulled Aug 27, 2026 UTC)

Latest data pull 72 rows
Aug 24, 2026 - Aug 27, 2026 (pulled Aug 27, 2026 UTC)
Sample index
Water level (m, MLLW)
0
1.897
1
1.798
2
1.517
3
1.158
4
0.755
5
0.454
6
0.252
7
0.195
8
0.277
9
0.475
10
0.739
11
0.981
12
1.249
13
1.438
14
1.543
15
1.485
16
1.393
17
1.243
18
1.1
19
1.1
20
1.187
21
1.356
22
1.572
23
1.762
24
1.92
25
1.891
26
1.747
27
1.397
28
0.982
29
0.604
30
0.288
31
0.135
32
0.152
33
0.284
34
0.516
35
0.817
36
1.104
37
1.356
38
1.511
39
1.527
40
1.425
41
1.264
42
1.07
43
0.976
44
1.014
45
1.153
46
1.352
47
1.594
48
1.798
49
1.895
50
1.85
51
1.598
52
1.203
53
0.762
54
0.405
55
0.166
56
0.068
57
0.136
58
0.351
59
0.661
60
0.947
61
1.234
62
1.456
63
1.561
64
1.511
65
1.352
66
1.1
67
0.917
68
0.869
69
0.978
70
1.159
71
1.407

Station: San Francisco. Series start (GMT): 2026-08-24 04:12. All 72 water-level samples are listed below.