The Moon pulls the near ocean harder than the Earth and the far ocean less, so two bulges of water form, one facing the Moon and one opposite. Earth turns through them, so a town sees two high tides a day. The Sun adds a smaller pair of bulges.
Drag the Moon to new Moon and full Moon: the two bulges line up with the Sun's and the town's range peaks. Drag to a quarter: the Sun's bulges sit sideways to the Moon's, so the range shrinks. Switch the Sun off to see how much it adds to the Moon alone. Move the Moon closer: its tide grows with the cube of the distance. Raise the coast amplification to see why a funnel-shaped bay has huge tides. Export the Moon-distance sweep to get range against distance as a CSV. Equilibrium tide theory (Newton 1687, Laplace 1775; Pugh, Tides, Surges and Mean Sea-Level, 1987). A body of mass M at distance d raises a surface bulge of height (M/Me)(R⁴/d³)·(3cos²ψ − 1)/2 on Earth of radius R, where ψ is the angle between the body and the zenith. That gives amplitude 0.357 m for the Moon at 384,400 km and 0.164 m for the Sun at 149.6 million km, a ratio of 46%. For a town at latitude φ with both bodies in the equatorial plane, the time-varying part is 0.75·A·cos²φ·cos(2H) for hour angle H, summed for Moon and Sun; the Moon's hour angle falls behind the Sun's by 2π t / 29.5306 days, which gives a lunar day of 24 h 50 min and high water every 12 h 25 min. Tidal range is 1.5·cos²φ·√(Am² + As² + 2·Am·As·cos 2e), where e is the Sun-Moon angle: spring at 0° and 180°, neap at 90°, a ratio of about 2.7. The coast factor multiplies the result to stand in for resonance and funnelling in real bays. Simplified: Moon and Sun over the equator (no declination), circular orbits, no continents, no friction, no ocean-basin resonance, so real tides differ in size and timing. The sweep varies the Moon's distance and records the spring range, the neap range and the Moon-only range.