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

Latest data pull 72 rows
Aug 3, 2026 - Aug 6, 2026 (pulled Aug 6, 2026 UTC)
Sample index
Water level (m, MLLW)
0
0.851
1
0.576
2
0.435
3
0.436
4
0.596
5
0.82
6
1.087
7
1.399
8
1.664
9
1.83
10
1.825
11
1.686
12
1.413
13
1.072
14
0.791
15
0.662
16
0.65
17
0.766
18
0.908
19
1.114
20
1.28
21
1.424
22
1.456
23
1.346
24
1.146
25
0.905
26
0.697
27
0.595
28
0.663
29
0.81
30
1.051
31
1.336
32
1.585
33
1.822
34
1.911
35
1.822
36
1.631
37
1.32
38
0.969
39
0.738
40
0.572
41
0.532
42
0.627
43
0.762
44
0.928
45
1.116
46
1.252
47
1.326
48
1.274
49
1.148
50
0.987
51
0.83
52
0.785
53
0.876
54
1.003
55
1.241
56
1.486
57
1.713
58
1.941
59
1.977
60
1.877
61
1.61
62
1.282
63
0.913
64
0.643
65
0.467
66
0.399
67
0.436
68
0.571
69
0.752
70
0.971
71
1.132

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