You should look at the US Naval Observatory's "NOVAS" code (C and
Fortran source available), and Jean Meeuse's "Astronomical Algorithms"
book. Those two sources will get you 90% of the way there (take it
from one who's done it!). For the remaining 10%, hope you were paying
attention in your math classes

Actually, there's a published
"Explanatory Supplement" to the nautical almanac (jointly published by
the same two hydrographic offices that do the nautical almanac) which
contains a good bit of (quite technical) exposition. I've also found
Charles Cotter's book "History of Nautical Astronomy" quite useful
(out of print, but in many libraries). I may be mangling these titles
a bit, but I'm sure of the authors.
--
Hal Mueller Get MapTap for PalmOS!
Seattle, Washington
http://www.mobilegeographics.com/maptap/