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: Nov 13, 2026 - Nov 16, 2026 (pulled Nov 16, 2026 UTC)

Latest data pull 72 rows
Nov 13, 2026 - Nov 16, 2026 (pulled Nov 16, 2026 UTC)
Sample index
Water level (m, MLLW)
0
2.266
1
2.137
2
1.836
3
1.478
4
1.105
5
0.801
6
0.583
7
0.52
8
0.575
9
0.743
10
0.967
11
1.169
12
1.459
13
1.69
14
1.746
15
1.813
16
1.704
17
1.656
18
1.578
19
1.577
20
1.612
21
1.649
22
1.822
23
1.948
24
2.026
25
2.014
26
1.869
27
1.592
28
1.216
29
0.883
30
0.633
31
0.469
32
0.431
33
0.531
34
0.723
35
0.984
36
1.211
37
1.453
38
1.633
39
1.743
40
1.739
41
1.699
42
1.612
43
1.524
44
1.489
45
1.539
46
1.641
47
1.756
48
1.857
49
1.911
50
1.883
51
1.695
52
1.445
53
1.133
54
0.865
55
0.672
56
0.55
57
0.53
58
0.654
59
0.853
60
1.062
61
1.339
62
1.535
63
1.697
64
1.763
65
1.74
66
1.64
67
1.572
68
1.487
69
1.441
70
1.447
71
1.516

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