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 23, 2026 - Oct 26, 2026 (pulled Oct 26, 2026 UTC)

Latest data pull 72 rows
Oct 23, 2026 - Oct 26, 2026 (pulled Oct 26, 2026 UTC)
Sample index
Water level (m, MLLW)
0
2.026
1
1.881
2
1.609
3
1.169
4
0.832
5
0.625
6
0.577
7
0.7
8
0.918
9
1.21
10
1.469
11
1.708
12
1.84
13
1.817
14
1.579
15
1.252
16
0.935
17
0.726
18
0.715
19
0.825
20
1.097
21
1.403
22
1.721
23
1.989
24
2.136
25
2.086
26
1.817
27
1.39
28
0.962
29
0.616
30
0.43
31
0.413
32
0.561
33
0.875
34
1.192
35
1.488
36
1.741
37
1.867
38
1.811
39
1.587
40
1.242
41
0.963
42
0.831
43
0.857
44
1.063
45
1.366
46
1.688
47
1.985
48
2.23
49
2.275
50
2.108
51
1.69
52
1.189
53
0.714
54
0.395
55
0.22
56
0.274
57
0.509
58
0.849
59
1.182
60
1.482
61
1.752
62
1.845
63
1.794
64
1.539
65
1.243
66
1.003
67
0.94
68
1.041
69
1.283
70
1.602
71
1.904

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