Canonical sources on the NOS tide prediction methodology (including a mathematical explanation from first principles in SP98):
Manual of Harmonic Analysis and Prediction of Tides. Special Publication No. 98, Revised (1940) Edition (reprinted 1958 with corrections; reprinted again 1994). United States Government Printing Office, 1994.
Computer Applications to Tides in the National Ocean Survey. Supplement to Manual of Harmonic Analysis and Prediction of Tides (Special Publication No. 98). National Ocean Service, National Oceanic and Atmospheric Administration, U.S. Department of Commerce, January 1982.
Those can be ordered from NOAA for $5 or $10, depending on the phase of the moon.
My sources for X-windows programming reference:
Kimball, Paul E. The X Toolkit Cookbook. Prentice Hall P T R, New Jersey, 1995.
Nye, Adrian. Xlib Programming Manual. O'Reilly & Associates, Inc., Volume 1, Third Edition, July 1993.